0penS0urce Posted June 16, 2015 Share Posted June 16, 2015 I want to make an arc spin in a circular motion by adding 1 to the angle from and the angle to params. When I try to run the code, only one side of the arc moves, so I am guessing that it it's redrawing on itself. Here's the JFiddle link to make it easier.Thanks in Advance! var game = new Phaser.Game(640, 480, Phaser.AUTO, '', { preload: preload, create: create, update: update });var x;var y;var oldx;function preload() { x = 0; y = 10; oldx = 0; }function create() { }function update() { oldx = x; x=x+1; y=y+1 var graphics = game.add.graphics(game.world.centerX, game.world.centerY); graphics.lineStyle(1, 0xffd900); graphics.arc(0, 0, 135, game.math.degToRad(x), game.math.degToRad(oldx+y), false);} Link to comment Share on other sites More sharing options...
XekeDeath Posted June 16, 2015 Share Posted June 16, 2015 You probably don't want to be creating a new graphics object every update frame.Your arc is actually lots of arcs. Move your creation of the graphics object out of the update function into create, and then use the clear() function it has to clear it before redrawing the arc.function create() { this.graphics = game.add.graphics(game.world.centerX, game.world.centerY);} function update() { oldx = x; x=x+1; y=y+1 this.graphics.clear(); this.graphics.lineStyle(1, 0xffd900); this.graphics.arc(0, 0, 135, game.math.degToRad(x), game.math.degToRad(oldx+y), false); } Link to comment Share on other sites More sharing options...
Recommended Posts