Restart Scene Glitch
-
Ok i havent noticed this glitch the entire time because i had my gameover play again button set as restart scene but with the refresh on. Now that my game has save and load features i noticed that the refresh button sets it up as if the label is played for the very first time. So the problem now is that when i untick the refresh button on restart scene. My scene is completely messed up when it restarts the scene. Animations are not playing. Certain layers are out of place. Its a complete mess. My only way around this is when i change restart scene to load previous scene. Then it will play correctly. Am i doing something wrong? Should i have refresh on? And if i should have refresh on how do i get hyperpad to load previous saved values?
-
I recommend refresh to be on.
What things are you trying to restore when the scene is restarted?
-
@Kamdroid doesnt refresh start the scene as it is brand new? Lets say i have already collected 20 coins. If i click refresh the scene would just load back at 0. Unless I am doing something wrong with save and load function
-
@SplitMindGaming yup just tested it out again with a simple interface. I have it save some coins. It was suppose to load it right on startup but with refresh on it doesnt do that.
-
@SplitMindGaming Just made a test project and it works fine, your behaviours must be wrong.
-
@Kamdroid would u mind sharing that test file. I want to see where i went wrong. Because i cannot load and save from a refresh scene for some reason.
-
@SplitMindGaming Here, open in Safari:
CoinSave.tap -
@Kamdroid ohh i see what i did wrong now. Thank you for that.
-
All logic is in the player.
Also supports having custom coin worth values for each individual coin.
-
@Kamdroid yes i seen you used dynamic. Its very smart.
-
@Kamdroid hey with the file you provided. How would you set it up so once it collects and adds 1 of the coins to the score. The next time it loads it will ignore that one certain coin and not add it to the score?
-
@SplitMindGaming Ignores the coins how?
Do you want any coins already collected to not show up on scene restart?
Or to still be visible, but not effect the score when collided with?
-
Personally, since we have object referencing (object IDs)
I'd store every coin ID the player collided with, in an array.
When colliding with a coin, I'd check if that coins ID is already saved in the coin collided array,
However, I remembered hyperPad doesn't even have an if array coins option (as far as I know). Previously I've used a loop to check all elements, but this has pretty bad performance. Ask @Hamed or @Murtaza
So I would just loop the array at the start, delete or set some attribute to "collected" of the coin object.
Or you could even try using a dictionary which lets you enter a key (the object ID), pretty sure it returns null key doesn't exist, so that can be like a workaround if contains.
-
@Kamdroid Thanks for that. Do you know if you can save to file a collision? So the next time the game starts it will load that collision then you can simply give it an ignore collision with that certain object? Or maybe even something similar.
-
The collided behaviour gives 2 outputs. Object A ID and object B ID
Object B would be the coin you collided with
Use modify array behaviour to append object B ID to an array (get coinsArray attribute).
Save that array to file and change coinsArray attribute to the array as well (set coinsArray attribute)
At the start, load collide array from save file and loop the array.
Use get array item with index "loop index"
That will be the coin ID. Set an attribute to tell it's already been collected, change the color, etc.