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?
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.
Would this work for multiple instances of the coin?
If I have multiple coins collected by player, would this work?
it should, just make sure the instance variable is on the sprite and not created in the event sheet.
Use CoinsCollected variable and add 1 every time player picks up a coin. When the player selects level 1 set CoinsCollected to 0.
What i would do is add an instance variable to the coin, and if the var = 0 then destroy coin.
Develop games in your browser. Powerful, performant & highly capable.
Ah yeah I misunderstood the help wanted actually. Do what BACLog said, that's good..
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.
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.
Yes 'IsCollected' instance variable true/false on the coin with Persist behaviour sounds gooooooood
yes Plinkie---however if you use the Persist behaviour--you don't even need to have an instance variable at all! That's why I like that behaviour--it's all built in.
I never used the persist behavior and I have a habit of doing most of my C2 stuff with variables as they tend to always do what I want of them, so when thinking of how to do something without having the program open in front of me I default to Boolean variables.
Always multiple ways to achieve the same results in C2
Another way would be to have an invisible "coin spawner sprite" at the locations of all the coins with a variable on the spawner and
At start of layout >
For each Spawn sprite>
Spawn sprite "collected" = false > spawn coin.
then on collision with the spawn sprite set the variable to true so when the layout restarts the coin no longer spawns.
Ah yeah I guess you can just set to invisible or destroyed when collected and if it's Persist it remains gone
Yes, Persist has one hangup, in that when objects present on the layout on startup are destroyed, the object is gone even on game restart. (not a problem if they are all spawned by the events.)
Thanks folks for the feedback, will be testing the methods today.