Invencible when flashing

Get help using Construct 2

Post » Mon Apr 23, 2012 6:19 pm

Hello, good afternoon :). How do I this?

In some platform games when you touch an enemy, your character flashes for 2 seconds for example, and in that 2 seconds the enemy can't touch again. I tried with variables, "wait" events and doesn't work :(.

Please can you help me?

Thanks a lot.
B
23
S
3
G
3
Posts: 26
Reputation: 1,832

Post » Mon Apr 23, 2012 8:06 pm

Variables/wait actions should work fine. It is probably a simple problem, we can help you if you share your capx!
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,644

Post » Mon Apr 23, 2012 9:03 pm

Hello, here is the capx https://www.dropbox.com/s/xlnxcuxbswd08xv/Platform%20Capx.capx.

The game it's in spanish because it's a large project. However I deleted some objects to make file size smaller and I just keep the important ones (the bee and the player)

As you can see in the events, when you touch the bee you lose a heart and the variable "invencible" is set to 1.

When that variable is 1, the group "Player" is deactivated and there is a wait 2 seconds action, then the variable is set to 0

When the variable is 0, the group is activated again.

I tried at this way, and when I touch the bee my character flashes for 2 seconds an he becomes invencible while he flashes, but then I can touch the bee constantly and I lose all my hearts, I think it ignores the "wait" action after the first 2 seconds but I'm not sure.

What are your suggestions? :)

Thank you very much.
B
23
S
3
G
3
Posts: 26
Reputation: 1,832

Post » Tue Apr 24, 2012 5:13 am

A simple example: invul example01lifeleft2012-04-24 05:22:41
B
41
S
11
G
5
Posts: 174
Reputation: 6,295

Post » Tue Apr 24, 2012 5:07 pm

Would adding the condition:
(player.invincible = 0)
to the collision between bee and player condition help?
B
51
S
13
G
8
Posts: 194
Reputation: 7,311

Post » Wed Apr 25, 2012 4:08 pm

Hello, I tried with that condition, but still doesn't work.

Suggestions?

Thank you very much :)
B
23
S
3
G
3
Posts: 26
Reputation: 1,832

Post » Wed Apr 25, 2012 4:38 pm

Actually it's a simple fix.

Go to where your conditions are for hurting the player. Should be:

PlayerBox On Collision with Bee
PlayerBox is on floor
---> hurt player
---> set invincible to 1, etc...

Just add "Player private variable "invencible" is = 0. That way each time the bee collides with the player it checks to make sure the player is invincible before doing anything.

PlayerBox on collision with Bee
PlayerBox private variable "invencible" = 0
PlayerBox is on floor
---> hurt player
---> set playerbox.invencible = 1, etc...TL222012-04-25 16:39:37
B
82
S
30
G
8
Posts: 308
Reputation: 10,487

Post » Thu Apr 26, 2012 11:34 am

I did similar to @Tl22 but used a bollean.






B
28
S
2
Posts: 69
Reputation: 1,491


Return to How do I....?

Who is online

Users browsing this forum: alajajm, imhotep22, Solomon, Yahoo [Bot] and 12 guests