I have completed the core functions of my game and want the player to be able to restart the game easily. I have two ideas on how this can be accomplished but I have not had very much luck with either one:
- Call some sort of restart function/method. I have been looking for a clear cut way to just restart my game similar to loading it in the simulator but I have not been able to find anything that makes sense to me. What I would want is something like your traditional reset button on a classic NES console, something like that that is executed when the crank is turned. I think this is the preferred way to go.
- I could just remove all the sprites, animations, etc. in my game and call the initialize function I have that would readd the sprites, set the variables again, etc. This would function the same way as when the game is started initially but would have to reset everything to their default values since the player could have changed them by playing the game (or not if they crank right away, either way).
I am stuck on how to remove all my sprites at once, here is what I have so far:
-- if the player turns the crank to 6 or 12 o'clock then... if ((crankTurns == 1) or (crankTurns == -1)) then -- it's supposed to remove all versions of a particular sprite but only removes those the -- player has touched self:remove() -- print crankTurns for testing purposes print(crankTurns) end
I set crankTurns equal to this: crankTurns = playdate.getCrankTicks(2)
so a player could crank in either direction and "blow up the game" so it restarts at 6 and 12 o'clock. How would I remove all the sprites that I have instead of removing one at a time? Sprites only drop when they come into contact with the player when I test it right now. I thought calling self:remove() would remove ALL copies/versions of the sprite but that is not the case here. I'm looking for a solution to #1 or #2 above but understanding both would be ideal.