Trouble bringing player "back to life"

Get help using Construct 2

Post » Wed Oct 16, 2013 1:16 am

Hello all!

Having an issue bringing my player "back to life" after it is destroyed by enemy... I will start from the beginning... I'm making a platform game... Box sprite with the platform behavior, pinned to a graphic sprite of my design... Wasn't too hard getting that to work at all... Kudos to Scirra... Anyway here's the issue; I have a health variable(a hybrid design by yours truly and another person from the forum; can't remember the name ) and the code looks like this:
(event)
System;Every Tick
(subevent)
System;HeroHealth <1
(action)
Health bar = Set animation to empty
Hero Box = Destroy
Player Sprite = Set animation to defeated (playing from the beginning)
Player Sprite = Set Y to (Blah,Blah)
System = Wait for 4.0 sec
Player Sprite = Flash for 2.0 sec
Player Sprite = Destroy
System = Subtract 1 from PlayerLives

Then I have a subevent attached for "disabling the keyboard" for the defeated animation... It's a triggered event BTW...

I started another string under that event:
(Triggered event) Player Sprite; On Destroyed
System = Restart Layout
System = Create object: Hero Box on layer 1; 83,390

So as you can tell, I'm pretty much lost at this point... lol! Nothing operates(after my player "dies"... sorry had to update that)the way I thought it would so I didn't bother going any further until I get some feedback... I f anyone has a clue of what I need to do in order to get my player's "2nd chance" to work properly, I'm all ears...BLACKMASK CEO2013-10-16 01:18:38
Image
B
37
S
18
G
9
Posts: 103
Reputation: 8,281

Post » Wed Oct 16, 2013 1:57 am

Do you have a CAPX ? As I think I may be able to help.
Using R243 for all examples
B
69
S
20
G
6
Posts: 379
Reputation: 9,699

Post » Wed Oct 16, 2013 7:13 am

Did you reposition the player images an re pi it to the respawned herobox ? Check that first..from the sounds of what you wrote you didnt do that...so you can't see where your player images are...hope that helps...
When in doubt..or you are lost in a Zombie apocalypse or someone is giving you a hard time..Remember one thing..... Read the Construct 2 Manual..it will save your life.:)
B
35
S
13
G
8
Posts: 318
Reputation: 7,685

Post » Wed Oct 16, 2013 7:40 am

Is herohealth a global variable? If so, on restarting the layout it will still be less than one if you don't reset it first.

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 » Wed Oct 16, 2013 10:27 pm

@mystazsea

Sorry it took so long to reply; Had to work today... And yes sir, I did try the respawn player sprite with pin and still had "weird" results... I may have had the actions in the wrong places; not sure so I will give that another try...

@LittleStain

I did not try that... I will give that a go as well... Appreciate the replies guys!
Image
B
37
S
18
G
9
Posts: 103
Reputation: 8,281

Post » Wed Oct 16, 2013 10:40 pm

@LittleStain

I just had a thought: If I reset the Global variables, I run into another issue... I don't want my "Player Score" "Player Lives" GV(s) being affected by the reset... There has to be a way to perform this task without resetting the GV(s), or resetting the layout and still subtract from "Player Lives" => respawn player sprite+player box with health full...
Image
B
37
S
18
G
9
Posts: 103
Reputation: 8,281

Post » Wed Oct 16, 2013 10:45 pm

you only have to set the value of the health variable to what it should be after destroying player and before restarting layout.
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 » Wed Oct 16, 2013 11:23 pm

@LittleStain

.... "Well I feel like a genius... lol!" I had the Player Box and Player Sprite on the WRONG LAYER LOL!!! Thanks for the reply dude...
Image
B
37
S
18
G
9
Posts: 103
Reputation: 8,281

Post » Thu Oct 17, 2013 12:24 am

@LittleStain

Ok I'm running into another issue... Things seem to working, but as I'm moving left in the game, my player sprite "has a duplicate" attached to it... So it looks as if I have "two" player sprites just overlapping one another... I'm not sure how I can fix this; also the score "doubles" on the layout reset... I think I can fix this with events so I'll try some combinations I thought of recently..
Image
B
37
S
18
G
9
Posts: 103
Reputation: 8,281

Post » Thu Oct 17, 2013 4:34 pm

Well I seem to have remedied the Score duplicating it self by re-arranging some for the code... I think I'm good on that aspect, but the player sprite has a "copy" attached in the browser when the layout restarts... I have the hero box re-pinned to the player sprite(both objects have been "respawned" by the system Create event) so I'm not sure how to troubleshoot this problem... Hoping for a little help or insight on this... Thank you.
Image
B
37
S
18
G
9
Posts: 103
Reputation: 8,281

Next

Return to How do I....?

Who is online

Users browsing this forum: Artcadev and 5 guests