hyude Posted November 17, 2014 Share Posted November 17, 2014 Hello. I need some idea to implement feature in my game. 1. When player gain score, I want the gained score to be added gradually, so the animation will look smoother. I have the idea to use Phaser Tween class for this. However, the tween process results in the score being a floating number when in process. Is there any way to use implement this so it only tween integer value? I know I can manually use timer for this, but it seems costly, and might create many trash object afterwards. 2. Does Phaser have a Shape-object which can act like sprite? For example a rectangle, circle, or triangle which can be rotated, scaled, moved, tweened as easily as sprite does. I need those shape to achieve a circular status bar. Thank you. Link to comment Share on other sites More sharing options...
lewster32 Posted November 17, 2014 Share Posted November 17, 2014 1. Tweens will use floats just because of how they work, but so long as you round the value before you display it, it should be fine. If absolutely necessary, GSAP can round tween properties.2. Yes, you can use Graphics or a BitmapData object, the former uses vectors, the latter is basically a wrapper for a HTML5 canvas which accepts all of the usual canvas drawing methods. I created a simple circular progress bar here if you'd like to see how to do it with BitmapData: http://jsfiddle.net/lewster32/f6tf8ue9/ hyude 1 Link to comment Share on other sites More sharing options...
hyude Posted November 17, 2014 Author Share Posted November 17, 2014 Thank you for your help. Another question : Regarding sprite pixel masking, let say I want to mask a sprite with a rectangle/circle, which rotated with tween.How can I do that? In simple term, how can I able to rotate masking area? Link to comment Share on other sites More sharing options...
lewster32 Posted November 17, 2014 Share Posted November 17, 2014 I've not really used masks myself yet, but the pixi example for masks has the mask animating, so I assume it's possible? Link to comment Share on other sites More sharing options...
hyude Posted November 19, 2014 Author Share Posted November 19, 2014 Thank you for your help, I have been able to create what I need to using Sprite.mask and Pivot from Phaser.Graphics. And also, your pie progress class is awesome! Link to comment Share on other sites More sharing options...
leonidas-3nt Posted July 17, 2020 Share Posted July 17, 2020 Hi @lewster32, you are indeed a helpy man, as I've seen throught this forum. Your link http://jsfiddle.net/lewster32/f6tf8ue9/ does not work, neither on jsFiddle, nor on my local server. There is an error in the console that says "dat is not defined". I am on Phaser 2.6.2. Could you kindly what the error may be? I would really love to see your example. Thank you. Link to comment Share on other sites More sharing options...
Recommended Posts