progress bar

For questions about using Classic.

Post » Fri Jul 13, 2012 4:18 pm

hello,
i want to have a working progress bar in my game...
for example i want to have a "mana" bar. if i cast a big spell, it will take 100 mana points (maximum), then mana will be automaticly restored for 2 minutes. when it will be full again (100 points), it will be possible to cast this spell again.

can you help me how can i do this?
B
4
S
2
G
1
Posts: 143
Reputation: 1,211

Post » Fri Jul 13, 2012 10:13 pm

Create a global variable called "mana". Set the value of that to 100, then make an always event that sets the value of a sprite to the value of global('mana'). You can then use a timer or some other mechanism for restoring mana over time. For this we will need to do some math. If you need to get 100 points in 120 seconds(2 minutes) then you need to divide 100 by 120. You end up with 0.83. So you set an event that every 120000 miliseconds, you add 0.83 to the global variable mana. Now when you want to cast a spell, just do a compare variable as one of the conditions. You want global('mana') to be greater than or equal too 100.
B
4
G
1
Posts: 50
Reputation: 652

Post » Fri Jul 13, 2012 10:34 pm

Heres an example. Left click to "cast" a spell. https://dl.dropbox.com/u/11232449/manacap.cap
B
4
G
1
Posts: 50
Reputation: 652

Post » Sat Jul 14, 2012 10:53 am

great! thanks very much, this is exactly what i need
B
4
S
2
G
1
Posts: 143
Reputation: 1,211

Post » Mon Jan 07, 2013 3:22 am

How can I make this in Construct 2??
B
8
S
2
G
3
Posts: 14
Reputation: 2,637


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 6 guests