This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-09-04 11:19:45

M303MTL
New Scratcher
Registered: 2010-09-03
Posts: 12

Hide vs Destroy

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

 

#2 2010-09-04 11:22:14

Sunrise-Moon
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Hide vs Destroy

I think you're looking for this block:


<stop script>

Last edited by Sunrise-Moon (2010-09-04 11:22:29)


http://i1067.photobucket.com/albums/u427/HulKDzN/RebornBlade.png

Offline

 

#3 2010-09-04 11:24:40

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Hide vs Destroy

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.


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#4 2010-09-04 11:32:45

M303MTL
New Scratcher
Registered: 2010-09-03
Posts: 12

Re: Hide vs Destroy

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

 

#5 2010-09-04 11:43:03

M303MTL
New Scratcher
Registered: 2010-09-03
Posts: 12

Re: Hide vs Destroy

Nevermind that.

Offline

 

#6 2010-09-04 11:48:59

johnnydean1
Scratcher
Registered: 2010-02-12
Posts: 1000+

Re: Hide vs Destroy

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)


You can now reach me on Twitter @johnnydean1_

Offline

 

Board footer