In my pong project, an object appears after playing for a little bit, and if hit it changes the background and makes it a 5-ball game instead of a 1-ball game and all the balls go faster.
I have the five balls set up with the scoring, bouncing etc. scripts, and then have this.
[blocks]
<when I receive[ switch ]
<show>
<set x to( 0 )
<set y to( 0 )
<point in direction( <pick random( 1 )to( 360 ) )
<forever>
<move( 30 )steps>
<end>
[/blocks]
It works, and after 10 seconds the game goes back. However, the balls don't disappear.
I've tried all these:
[blocks]
<when I receive[ Switch Back ]
<hide>
and
<when I receive[ Switch Back ]
<set x to( 500 )
<set y to( 500 )
<hide>
and
<when I receive[ Switch Back ]
<set x to( 500 )
<set y to( 500 )
<hide>
<move( -30 )steps>
and
<when I receive[ Switch Back ]
<set x to( 500 )
<set y to( 500 )
<hide>
<forever>
<move( -30 )steps>
<end>
At first the last script was working to stop the scoring, but then the object is programmed to loop its appearance every minute for 5 seconds so you get another chance to go to the 5-ball game. When you hit the object and go back to the 5-ball game, the balls start spazzing out because they have the programming for a forever 30 steps and a forever -30 steps. If I didn't have the forever -30 steps the balls would keep scoring while invisible.
Offline
I think you're looking for this block:
<stop script>
Last edited by Sunrise-Moon (2010-09-04 11:22:29)
Offline
If it's just supposed to disappear after ten seconds, replace the forever in the first script with a repeat block. Change around the number until it's about ten seconds. Then add a hide to the end.
Offline
I'm not exactly sure where I'm supposed to put the stop script block in there. I want to stop it when I receive the switch back broadcast, so I can't attach it to the other block for when I receive the switch broadcast.
Offline
When I recieve [switch]
set speed to 30
set expireTime to 10
show
set x to 0
set y yo 0
point in direction ( pick random( 1 )to (360) )
time set to (timer)
change time by expireTime
repeat until (time < (timer) )
| move speed steps
|___________________
hide
When I recieve [switch back]
time set to ( (timer) - expireTime)
Last edited by johnnydean1 (2010-09-04 11:49:23)
Offline