I've got a problem with my scripting on a game that I'm working on. In this game the player starts off with 5 lives and when they crash their space shuttle into the walls the shuttle explodes (this consists of a few costume changes for the shuttle sprite) and 1 life is lost... or at least that is the intention. The problem I have is that the explosion sequence happens twice & two lives are lost.
I'm no good with Scratchblocks but I will try to explain the bits of code involved:
To call up the death sequence I have used...
if touching colour (red)?
set "SX" to 0
set "Thrust" to 0
set "Gravity" to 0
broadcast "Die"
stop script
and "Die" broadcast looks like this...
when I receive "Die"
switch to costume "Shuttle2"
wait 0.2 secs
switch to costume "Shuttle3"
wait 0.2 secs
switch to costume "Shuttle4"
wait 0.2 secs
set ghost effect to 50
wait 0.2 secs
hide
switch to costume "Shuttle1"
wai 0.6 secs
change "Lives Left" by -1
if "Lives Left" >1
set "Level" to 1 (sets the player back to the first level)
broadcast "BG" (this is the broadcast that draws the level)
broadcast "Start" (sends you back to the main loop)
else
set "Lives Left" to 0 (not sure if I need this line)
broadcast "Fin" (broadcast the "Game Over" message)
Can anyone help?
Offline
Change your
broadcast [Die v]to
broadcast [Die v] and waitIf that doesn't help, it's probably because your shuttle is still touching red /after/ the death sequence. Also, check for 2 scripts that may be doing the same thing.
Offline
Thanks Gravitation. Using...
broadcast "Die" and wait
...didn't make any difference but it gave me an idea of where the problem might lie.
I changed
broadcast "BG"
to
broadcast "BG" and wait
and that seems to have fixed it.
Offline