How do I Change State for more than one Hit

Get help using Construct 2

Post » Sun Jul 13, 2014 7:20 pm

I am trying to make this bird take more than one hit from my bullet to die...not sure what I am doing wrong.
I have it going from birdHp=0 to birdhp=1 when hit, then when birdhp=1 and is hit again, destroy bird..

Eventsheet 1...code 287

http://www.dwbailey.com/images/birdHp.capx
Image
B
9
S
2
Posts: 272
Reputation: 1,632

Post » Sun Jul 13, 2014 7:30 pm

Give each bird an instance variable called "HitPoints" Numbers
Set the value to 3

On collision(hit) Bird > System Subtract -1 > from Bird "HitPoints"

Bird "Hitpoints" (less than or = 0) <0 or = 0 > Bird Destroy
Image
B
75
S
23
G
3
Posts: 673
Reputation: 9,273

Post » Sun Jul 13, 2014 7:48 pm

thanks ill try that
B
9
S
2
Posts: 272
Reputation: 1,632

Post » Sun Jul 13, 2014 10:05 pm

So now my issue is picking again. So I play it using the debugging mode. When the bullet hits the bird the var is subtracted 1 which is great..... but it doesnt store it per clone......so if i hit a bird only once it sets the hp=1 then i go to the next bird and hit it with a bullet it is destroyed because the info of the hp isnt being separated per bird.

Image
B
9
S
2
Posts: 272
Reputation: 1,632

Post » Sun Jul 13, 2014 10:17 pm

Use an instance variable on the bird instead of a global variable..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun Jul 13, 2014 10:20 pm

I'm also not quite sure why you'd need the pick nearest and the for each bird conditions, they don't do anything usefull here, I guess..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun Jul 13, 2014 10:50 pm

thanks stain. it worked, i never think about instance variables. Well I guess because never really fully understood what that was even for. I have a better understanding now. I guess i used global variable because i wanted the code to be used through out my different levels...
B
9
S
2
Posts: 272
Reputation: 1,632


Return to How do I....?

Who is online

Users browsing this forum: timoteomorelli and 1 guest