How do I respawn a player after he dies?

Get help using Construct 2

Post » Thu Mar 20, 2014 1:53 am

I know how to reset the entire layout, but I can't figure out how to create an event where he spawns back to a safe spot. The game in question is a platformer. I also have instances where the player will be killed by enemies, and will need to spawn again. Any help would be so awesome :D
--

So Say We All
B
13
S
4
G
1
Posts: 37
Reputation: 1,330

Post » Thu Mar 20, 2014 2:58 am

What i would do is to actually never destroy the player. When he is suppose to be "dead" i would take him out of the screen (set x,y), and when i want him to be back, i would set his x,y back to wherever i want to.
This also allows you to manage better the instance variables of the player, if he has them.
B
43
S
12
G
6
Posts: 446
Reputation: 6,807

Post » Thu Mar 20, 2014 3:14 am

That sounds like a great idea. However, how do I set the x, y back to a safe point automatically? Or do I have to create safe points all across the map?
--

So Say We All
B
13
S
4
G
1
Posts: 37
Reputation: 1,330

Post » Thu Mar 20, 2014 6:44 am

What i would do is make a sprite called CheckpointNode or something of that nature
Then maybe a instance variable on the player like "Lives" (give it a number of course for example 3)
and when the player is supposed die/lose a life you can subtract a life and set the X/Y to CheckpointNode.

If you have multiple CheckpointNodes you can make a variable to hold which checkpoint the player touched last so you can send him back to the right checkpoint.

I probably said more that I should have hope I helped :P
B
19
S
4
Posts: 96
Reputation: 1,487

Post » Thu Mar 20, 2014 7:25 am

Haha how is that saying more than you should have? It helps quite a bit, thank you. I'll try to see how that would work.
--

So Say We All
B
13
S
4
G
1
Posts: 37
Reputation: 1,330

Post » Thu Mar 20, 2014 8:01 am

Went out my way for you bro here you are lol :D

https://dl.dropboxusercontent.com/u/258 ... ample.capx

Also I figured people searching the forums might come across a similar issue and want to know how to do it.
B
19
S
4
Posts: 96
Reputation: 1,487

Post » Thu Mar 20, 2014 8:10 pm

Holy. Crap. This is freaking perfect. Thanks so much dude! And I imagine it would work just fine even if I gave the player unlimited lives, correct? i.e. getting rid of the "subtract 1 life from player" line?
--

So Say We All
B
13
S
4
G
1
Posts: 37
Reputation: 1,330

Post » Thu Mar 20, 2014 8:38 pm

yea if you want unlimited lives just remove the instance variable on the player and delete that line (for optimization purpose)
B
19
S
4
Posts: 96
Reputation: 1,487

Post » Thu Mar 20, 2014 8:52 pm

Wonderful. Thanks so much man. This is a great headstart for me.
--

So Say We All
B
13
S
4
G
1
Posts: 37
Reputation: 1,330

Post » Thu Mar 20, 2014 9:48 pm

Quick question again. When my player spawns at the checkpoints he freaks out and shakes violently before landing on the ground and becoming playable again. Have I done something wrong? I basically copied everything from your event sheet and wrote it in mine.
--

So Say We All
B
13
S
4
G
1
Posts: 37
Reputation: 1,330

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 2 guests