-life IF collision with block

Get help using Construct 2

Post » Sat Aug 17, 2013 6:56 pm

i am working on some stuff and i cant figure out how to implement the following.
the game has a ground where the player walks on wich is grey . there are red sprites sometimes. when player is on collision with red block = -life (1)

but nothing happens.

any tips?

screenshots :
http://puu.sh/445Ri.png
B
27
S
7
G
3
Posts: 300
Reputation: 4,563

Post » Sat Aug 17, 2013 7:18 pm

EDIT = i now made a detector sprite and made it to lay 2 pixels over the ground. then the substraction of life works BUT it substracts ALL lifes not one ..
B
27
S
7
G
3
Posts: 300
Reputation: 4,563

Post » Sat Aug 17, 2013 7:23 pm


This is my event system for doing life system

http://puu.sh/446RE.png

Simple = greenblock = +1 life
Red block = -1 life

but all this does is restarting the layout when i touch a red blockburningcake2013-08-17 19:24:27
B
27
S
7
G
3
Posts: 300
Reputation: 4,563

Post » Sat Aug 17, 2013 11:02 pm

What is the default value of 'lifes' set to?
Posting a .capx would help a lot.
B
46
S
16
G
77
Posts: 2,155
Reputation: 45,823

Post » Sun Aug 18, 2013 12:11 am

try this:

Add new globel Variable namend Is_hit from type Number = 0

Event (Condition)                    Action

player is overlapping red sprite --> Substract 1 from Lifes
(Is_hit = 0)                         Set Is_hit = 1
(Lives >=0)                          wait 0.5 seconds
                                    Set Is_hit = 0 yonda2013-08-18 00:15:35
B
19
S
6
G
3
Posts: 197
Reputation: 4,154

Post » Sun Aug 18, 2013 12:26 am

I was thinking that too, it could just be draining all the lives when overlapping once as there's nothing to stop it detecting. Would have to see the .capx to make sure though.
B
46
S
16
G
77
Posts: 2,155
Reputation: 45,823

Post » Sun Aug 18, 2013 12:33 am

Always remember how events work : events are tested EVERY tick, and also executed EVERY tick when true.

In your example, at 60 FPS, your "life" value ends at -60 at the end of 1 second of collision.

Either use a "Trigger once while true" condition, or prefer using a trigger condition "On collision". Or add other conditions to precisely time when the action of substracting is to happen.

I wouldn't use wait actions as it might end up in unwanted behavior, and will only stack those actions as explained in this tutorial.Kyatric2013-08-18 00:34:50
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
291
S
114
G
95
Posts: 7,293
Reputation: 70,144

Post » Sun Aug 18, 2013 4:13 am

Add Trigger once while true subevent to both events and move the +1 and -1 actions there.
B
10
S
4
Posts: 133
Reputation: 1,543

Post » Sun Aug 18, 2013 7:49 pm

i solved it with your help thanks :)
B
27
S
7
G
3
Posts: 300
Reputation: 4,563


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo and 20 guests