For Loop & Life Totals

Get help using Construct 2

Post » Wed Mar 13, 2013 1:53 am

So I am trying to learn and am building old school space invaders. So I want to show the remaining life (Number of Ships) the player has and I cant get it. I am for sure way over thinking, that is my MO, help please.

I would like to display an icon for each Life the player has remaining, start with 3. Each time player loses a life, remove an icon. Simple enough but in C2, How?

I first thought, oh easy just do a For loop create 3 icons, then remove 1 each time player loses life. BUT destroy removes all 3 in one swoop.

How can I post an img to show you my logic? I also don't also get how and when "System" is executed, it is every tick?

Thanks
Brett


jbmoyer2013-03-13 02:03:27
B
21
S
7
G
1
Posts: 128
Reputation: 3,076

Post » Wed Mar 13, 2013 3:01 am

You need to pick the specific instances of the icon you'd like to destroy. One way would be to set an instance variable on the icons as they're being created in the loop, and when you're ready to destroy one of them, choose the icon with a specific value in its instance variable to destroy.

However, I think there's a much more efficient way to do it using a global variable for lives, and running a function whenever the number of lives change.

Demo
Capx.

I hope this helps.zatyka2013-03-13 03:18:21
B
44
S
13
G
7
Posts: 338
Reputation: 10,379

Post » Wed Mar 13, 2013 3:36 am

Wow, outstanding you went above and beyond thank you. I totally forgot about Functions that makes total sense. Thank you, owe you

Brett
B
21
S
7
G
1
Posts: 128
Reputation: 3,076


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, Lordshiva1948 and 16 guests