How do I remove coins when layout restart?

Get help using Construct 2

Post » Mon Mar 23, 2015 10:28 am

Hello guys,

I'm new to C2 and I try to design a platform game but I encouter a problem with my scoring experience.

Basically, the player collects coins through the level and get a score. My problem arises when I restart the layout before the end of the level (for example, the player falls down or touches an enemy therefore the player is killed) so I need to restart the layout to try again). But, when I restart the layout, the coin already collected in the level will automatically reappear despite the fact I create an destroy event for the coin.

So in the event sheet I have:

Condition: Player on collision with coin, Action: Coin destroy, Action add 1 to Score (glob var) and Coin set invisible.

Thanks for your help! :)
B
4
Posts: 3
Reputation: 206

Post » Mon Mar 23, 2015 11:16 am

@Notorious406

Problem is, when you restart your layout everything on it is destroyed and then whole layout is recreated.
One way to solve this is to put UID of each coin player picks in an array, and then when you restart the layout pick each coin by UID number in array and destroy it.

Another way would be to avoid layout restart if you can.
B
12
S
6
G
2
Posts: 99
Reputation: 1,727

Post » Mon Mar 23, 2015 12:13 pm

Open a new project in C2 and search for persist.... template.

It use a behavior I believe. Much more simpler and no need to use special tricks :)
It's time for me to return the favor :)
B
32
S
9
G
8
Posts: 132
Reputation: 4,870

Post » Mon Mar 23, 2015 1:29 pm

@razorMonkey I avoid restart the layout and now it works perfectly (just played with player (set position , set disabled, wait x sec, set enabled)).

Thank you!
B
4
Posts: 3
Reputation: 206

Post » Mon Mar 23, 2015 5:06 pm

Or you use the Persistent-Behavior as ikke2902 said. That works also perfect and you don't have to set/change any variables.
B
21
S
5
G
2
Posts: 181
Reputation: 3,499


Return to How do I....?

Who is online

Users browsing this forum: ultrafop and 11 guests