How do I charge a bar with 8 frames

Get help using Construct 2

Post » Fri Jan 27, 2017 4:20 pm

Hi everyone,

I'm working on a "special attack" bar that has 8 frames. You have to fill up the frames by attacking enemies and getting points.

I'm trying to figure out how to convert the numbers so I can get the bar animations (0 to 7) using a percentage of the points acquired.

So for instance, if you need 15.000 points to get the special attack, getting 1.875 points would change the bar sprite to frame 1, if you got 3.750 points the bar would go to frame 2 and so on.

Any help is appreciated!
B
125
S
43
G
41
Posts: 849
Reputation: 28,260

Post » Fri Jan 27, 2017 4:41 pm

maybe:

set frame to int(points/1500)

so..if you have
poits<1500;frame=0
1500-2999;frame=1 ...(getting 1.875 points would change the bar sprite to frame 1)
3000-4499;frame=2 ...(if you got 3.750 points the bar would go to frame 2)
etc..
B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072

Post » Fri Jan 27, 2017 5:04 pm

@korbaach thanks that's exactly what I needed.
I wanted the full needed points to be variable though so I used int(current_points/(points_needed/8)).
B
125
S
43
G
41
Posts: 849
Reputation: 28,260


Return to How do I....?

Who is online

Users browsing this forum: Google [Bot] and 19 guests