MarzSocks

Drawing a circle health bar around a sprite

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

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.

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...

  • Recently Browsing   0 members

    No registered users viewing this page.