sinanqd10 Posted March 3, 2015 Share Posted March 3, 2015 var diff, increase_end_angle = 0, start_angle = 1.5 * Math.PI,end_angle = 2 * Math.PI, startTime = (new Date()).getTime(), circleTimer; create: function { button = this.game.add.button(0,0,'btnNext', this.start,this); }, circleTimer: function () { var graphics = game.add.graphics(0, 0); diff = (new Date()).getTime() - startTime; diff = diff / 60000; //60000ms = 60s increase_end_angle = start_angle + end_angle * diff + reduce; graphics = game.add.bitmapData(80,80); graphics.context.fillStyle = '#D24545'; graphics.context.beginPath(); graphics.context.arc(x,y,radius,start_angle,increase_end_angle,false); graphics.context.lineTo(x,y); graphics.context.fill(); graphics.context.closePath(); game.add.image(13, 8, graphics); }, start: function () { circleTimer = setInterval(this.circleTimer, 200); }, update: function() { if(diff > 1 ) { clearInterval(circleTimer); } }, Link to comment Share on other sites More sharing options...
Abderrahmane TJ Posted March 3, 2015 Share Posted March 3, 2015 Because the `this` used inside create will be used py the phaser object, and thus will not be referring to your literal object. This is all just guess work since you did not show us all your code. Link to comment Share on other sites More sharing options...
Recommended Posts