Sign in to follow this  
hyude

Need help for some problem

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

Share this post


Link to post
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/

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.