MarzSocks Posted January 29, 2018 Share Posted January 29, 2018 How does one animate the gain or loss in degree's of an arc drawn around a sprite ( based on how much health the spite has. ) E.g. 50% = 180 degree arc. Gain 25% health, grow the arc to 75 degrees. Loose 50% health, reduce ark down to 25 degrees. Link to comment Share on other sites More sharing options...
samme Posted January 29, 2018 Share Posted January 29, 2018 Phaser.Graphics#arc Link to comment Share on other sites More sharing options...
samid737 Posted January 29, 2018 Share Posted January 29, 2018 interpolateColor changes the color according to health, samme 1 Link to comment Share on other sites More sharing options...
MarzSocks Posted January 30, 2018 Author Share Posted January 30, 2018 8 hours ago, samid737 said: interpolateColor changes the color according to health, Thank you for this, it is what I am looking for. Q: How does the tween end up being applied to the arc? There seems to be no reference connecting the two? Link to comment Share on other sites More sharing options...
tokumaru Posted January 30, 2018 Share Posted January 30, 2018 The tween is modifying a property of the "angle" object, and this property is being used to draw the arc and to calculate its color. Link to comment Share on other sites More sharing options...
MarzSocks Posted January 30, 2018 Author Share Posted January 30, 2018 11 hours ago, tokumaru said: The tween is modifying a property of the "angle" object, and this property is being used to draw the arc and to calculate its color. I thought that might be the case, so does that mean every arc that is drawn will have the tween? Regardless of if one wants the tween on that arc or not? Link to comment Share on other sites More sharing options...
tokumaru Posted January 30, 2018 Share Posted January 30, 2018 You could simply update the arc's angle and color based on the current health value and it would change instantaneously to that configuration, but if you plan on animating the changes you'll have to modify the color and the angle gradually over time. Tweening is one way to do it (and was probably used in the example for simplicity's sake), but you could just as well use your own logic every frame to make the arc's angle "catch up" with the current health value. Link to comment Share on other sites More sharing options...
Recommended Posts