Jump to content

Need help for some problem


hyude
 Share

Recommended Posts

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.

 

post-10598-0-40729400-1416208167.png

 

Thank you.

post-10598-0-40729400-1416208167.png

Link to comment
Share on other sites

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/

Link to comment
Share on other sites

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

  • 5 years later...

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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...