I'm working on adding a pause function to my game (here), but the code I used for the movement of the enemies makes it so that it will always do that movement
The script for enemy movement is:
Forever
---Glide [pick random 3 to 5] secs to x [pick random -225 to 225] and y [pick random -40 to 180]
So that they glide around the screen randomly, but that code overwrites anything else, so even if I tell it to wait for "pause" variable to be true, it still moves. Does anyone have any code idea that either a) make the enemies do the same movement but will stop when it's paused or b) a way to make the current code respond to "pause" being true.
Thanks
Offline
SD7 wrote:
I'm working on adding a pause function to my game (here), but the code I used for the movement of the enemies makes it so that it will always do that movement
The script for enemy movement is:
Forever
---Glide [pick random 3 to 5] secs to x [pick random -225 to 225] and y [pick random -40 to 180]
So that they glide around the screen randomly, but that code overwrites anything else, so even if I tell it to wait for "pause" variable to be true, it still moves. Does anyone have any code idea that either a) make the enemies do the same movement but will stop when it's paused or b) a way to make the current code respond to "pause" being true.
Thanks
Foreverifpause=trueGlide
Offline
That's exactly what I have, but takes about a second and a half to actually stop them. And then they don't all stop at once- you click pause and (there's three enemies), first stops, then second one stops, then the third, not all at once.
Offline
ForeverGlideifpause=truestop all
Last edited by shiguy101 (2012-05-03 12:18:55)
Offline
But then if you click the pause button again, will it resume where it left off? I figured it would restart the game, like clicking the flag again (well, he11, I figured since it says stop all, the pause button wouldn't work anymore, because it's stopped)
Offline
shiguy101 wrote:
ForeverGlideifpause=truestop script
this is what I meant
Offline
Tried that, didn't do anything.
I did try
Forever
-- if <(PAUSE) = [0]>
------- if <(Red 1 Move) = [true]>
---------------Glide
But again, that didn't stop them instantly, they glided around for about a second before coming to a stop
Offline
you may also need
WhenSprite1Clickedsetpause ▼totruebroadcaststart ▼When I receivestart ▼Glide
Last edited by shiguy101 (2012-05-03 12:40:46)
Offline
The problem is that the glide block takes the full 3 to 5 seconds before moving on to the next block in the stack -- so if you set pause to true when the sprite has just started gliding, it can take a full 5 seconds before it actually stops.
To avoid this, you can make your own glide method that mimics the block, but also checks for the pause variable every so often.
Offline
Fixed it SD7
ForeverifBomber Move=TrueSetX Destintopick random-170to170SetY Destintopick random50to150repeat untiland<abs ▼ofx position-X Destin5=abs ▼ofy position-Y Destin5Change the equal sign to less than. Somehow I couldn't when typing scratch blocksifPAUSE=0ifx position<X DestinChange x by1.5ifx position>X DestinChange x by-1.5ify position>Y DestinChange y by-1.5ify position<Y DestinChange y by1.5
Last edited by itsmomito (2012-05-03 14:40:19)
Offline