How To NOT Load Sprite If Collected/Destroyed?

Get help using Construct 2

Post » Fri Sep 20, 2013 1:13 am

I am curious on how to do the following:

I have 3 levels... Player can go back to lvl 1 or lvl 2 or lvl 3 to replay using a level select menu.

My challenge is:

If Player Collects Coins In Lvl 1
Then player goes to Level Select Menu.

Player goes back to play Lvl 1 to play again...
Is there a way to not populate the coins the player already has picked up?

Thanks
B
5
Posts: 11
Reputation: 247

Post » Fri Sep 20, 2013 1:34 am

set the coin sprite as global, add a variable to the coin, when the player touches the coin set the variable to true, and when variable is true have the coin destroyed.
B
25
S
7
G
1
Posts: 83
Reputation: 2,550

Post » Fri Sep 20, 2013 2:00 am

Would this work for multiple instances of the coin?

If I have multiple coins collected by player, would this work?

Thanks
B
5
Posts: 11
Reputation: 247

Post » Fri Sep 20, 2013 2:34 am

it should, just make sure the instance variable is on the sprite and not created in the event sheet.
B
25
S
7
G
1
Posts: 83
Reputation: 2,550

Post » Fri Sep 20, 2013 2:44 am

Use CoinsCollected variable and add 1 every time player picks up a coin. When the player selects level 1 set CoinsCollected to 0.
B
46
S
16
G
74
Posts: 2,089
Reputation: 44,187

Post » Fri Sep 20, 2013 2:48 am

What i would do is add an instance variable to the coin, and if the var = 0 then destroy coin.
B
20
S
8
G
2
Posts: 122
Reputation: 3,202

Post » Fri Sep 20, 2013 2:51 am

Ah yeah I misunderstood the help wanted actually. Do what BACLog said, that's good..
B
46
S
16
G
74
Posts: 2,089
Reputation: 44,187

Post » Fri Sep 20, 2013 2:58 am

You do NOT want to make your coins global--or else they will carry through and appear on every level.

What you want to do is click on the coin sprite, then add behaviour, then click on the + symbol, then click on the "persist" attribute.

This will give your coin a persistance that will remember that it is destroyed so that when you return to the same level it wont be there again.

Here is a very basic cap showing you what I mean.
Be sure to experiment and make the coin global to see what I mean about it going through to the next level.
Also--there is a persistant layer cap included in the software.

https://dl.dropboxusercontent.com/u/15587147/persistant.capxpersistant caphoneben2013-09-20 02:59:09
B
19
S
6
G
3
Posts: 9
Reputation: 1,755

Post » Fri Sep 20, 2013 3:08 am

BACLog was right too, as long as you be sure to have the coin destroyed, but why not make use of a good feature---that's why its there. And when your coding and games gets more complicated, you will want to do things the most efficient way to cut down on CPU usage.
B
19
S
6
G
3
Posts: 9
Reputation: 1,755

Post » Fri Sep 20, 2013 3:13 am

Yes 'IsCollected' instance variable true/false on the coin with Persist behaviour sounds gooooooood
B
46
S
16
G
74
Posts: 2,089
Reputation: 44,187

Next

Return to How do I....?

Who is online

Users browsing this forum: DharmaOne, Yahoo [Bot] and 5 guests