I would like to make the player jump on a block more than once to break it. Right now it breaks if the player jumps once, but how can i create an event that makes the player jump a random amount of times (2 - 4) to break it?
Thank you for any help.
You should use instance variables for this. https://www.scirra.com/manual/73/instance-variables
Create an instance variable for the block and set it to 2 or 4. Then when the player collisions with the block, subtract 1 from that variable. And if the variable is less than 1 destroy the block.
Develop games in your browser. Powerful, performant & highly capable.
Thank you for the reply Xavier. Guess i'm finally gonna have to try and wrap my brain around instance variables.
Create an instance variable for the block and set it to 2 or 4.
Is it possible to add to that instance variable by the system picking a random number between 2 and 4? So it could be 2 hits, or 3, or 4?
Yes. You need to use the random() expression, you would use it like this: round(random(2,4))
The round expression will round a number, so if you get 4.2, it will show 4. More on: https://www.scirra.com/tutorials/77/nat ... onstruct-2
You should create an action at layout start to set the instance variable for the blocks to round(random(2,4))
Modify the numbers as you see fit.
Thank you once again, Xavier.
I just finished with the instance variable and it worked great, going back over the ghost shooter tutorial and subtracting the health.