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

#1 2012-11-05 14:32:53

Fernandop91
New Scratcher
Registered: 2012-10-30
Posts: 8

How do I get the sprite to come out of the repeat loop and stop moving

As you can see below in the forever and repeat loop, the forever is forever spawning and pointing towards sprite 1 and repeat is only supposed to deal with movement. The problem is once the bird is hit with a fireball, it goes back to its original location and continues to move and go towards sprite 1 while hidden, thus making it impossible to respawn. How can i stop this and make it hold position once it is hit?

when gf clicked
forever if <touching fireball>
     play sound
     change <Bird> by (1)



when i receive <start>
hide
go to x:(195) y:(126)
forever
     wait <pick random(1) to (1)> secs
     play sound
     go to x:(195) y:(126)
     show
     repeat until <touching sprite1>
         wait (0.5) secs
          point towards <sprite1>
          move (30) steps

when gf clicked
hide
forever if <touching fireball>
     wait(0.5) secs
     go to x:(195) y:(126)
     hide

Offline

 

#2 2012-11-05 15:02:05

Fernandop91
New Scratcher
Registered: 2012-10-30
Posts: 8

Re: How do I get the sprite to come out of the repeat loop and stop moving

bump

Offline

 

#3 2012-11-05 15:27:36

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: How do I get the sprite to come out of the repeat loop and stop moving

Fernandop91 wrote:

As you can see below in the forever and repeat loop, the forever is forever spawning and pointing towards sprite 1 and repeat is only supposed to deal with movement. The problem is once the bird is hit with a fireball, it goes back to its original location and continues to move and go towards sprite 1 while hidden, thus making it impossible to respawn. How can i stop this and make it hold position once it is hit?

when gf clicked
forever if <touching [fireball v]?>
     play sound
     change [Bird v] by (1)



when i receive [start v]
hide
go to x:(195) y:(126)
forever
     wait<pick random(1)to(1)>secs//You do know that this is the same as 1?
     play sound
     go to x:(195) y:(126)
     show
     repeat until <touching [sprite1 v]?>
         wait (0.5) secs
          point towards [sprite1 v]
          move (30) steps
    end
    wait until (ready?)//The added block.

when gf clicked
hide
forever if (touching [fireball v]?)
     wait (0.5) secs
     go to x:(195) y:(126)
     hide

I fixed your script and added a block that might fix your problem.

Last edited by ErnieParke (2012-11-05 15:29:45)


http://i46.tinypic.com/35ismmc.png

Offline

 

#4 2012-11-05 15:55:38

Fernandop91
New Scratcher
Registered: 2012-10-30
Posts: 8

Re: How do I get the sprite to come out of the repeat loop and stop moving

ErnieParke wrote:

Fernandop91 wrote:

As you can see below in the forever and repeat loop, the forever is forever spawning and pointing towards sprite 1 and repeat is only supposed to deal with movement. The problem is once the bird is hit with a fireball, it goes back to its original location and continues to move and go towards sprite 1 while hidden, thus making it impossible to respawn. How can i stop this and make it hold position once it is hit?

when gf clicked
forever if <touching [fireball v]?>
     play sound
     change [Bird v] by (1)



when i receive [start v]
hide
go to x:(195) y:(126)
forever
     wait<pick random(1)to(1)>secs//You do know that this is the same as 1?
     play sound
     go to x:(195) y:(126)
     show
     repeat until <touching [sprite1 v]?>
         wait (0.5) secs
          point towards [sprite1 v]
          move (30) steps
    end
    wait until (ready?)//The added block.

when gf clicked
hide
forever if (touching [fireball v]?)
     wait (0.5) secs
     go to x:(195) y:(126)
     hide

I fixed your script and added a block that might fix your problem.

Is ready a new variable? I know the 1 to 1 was just to test it out, The problem is the bird goes back to the spot but it doesn't go out of the loop.

Offline

 

#5 2012-11-05 16:03:43

Willpower
Scratcher
Registered: 2012-01-26
Posts: 1000+

Re: How do I get the sprite to come out of the repeat loop and stop moving

Fernandop91 wrote:

ErnieParke wrote:

Fernandop91 wrote:

As you can see below in the forever and repeat loop, the forever is forever spawning and pointing towards sprite 1 and repeat is only supposed to deal with movement. The problem is once the bird is hit with a fireball, it goes back to its original location and continues to move and go towards sprite 1 while hidden, thus making it impossible to respawn. How can i stop this and make it hold position once it is hit?

when gf clicked
forever if <touching [fireball v]?>
     play sound
     change [Bird v] by (1)



when i receive [start v]
hide
go to x:(195) y:(126)
forever
     wait<pick random(1)to(1)>secs//You do know that this is the same as 1?
     play sound
     go to x:(195) y:(126)
     show
     repeat until <touching [sprite1 v]?>
         wait (0.5) secs
          point towards [sprite1 v]
          move (30) steps
    end
    wait until (ready?)//The added block.

when gf clicked
hide
forever if (touching [fireball v]?)
     wait (0.5) secs
     go to x:(195) y:(126)
     hide

I fixed your script and added a block that might fix your problem.

Is ready a new variable? I know the 1 to 1 was just to test it out, The problem is the bird goes back to the spot but it doesn't go out of the loop.

ready is a new variable, but then you need something setting ready to when you want the bird to appear. Maybe you could repeat until touching your sprite instead of forever? would that work?


http://i49.tinypic.com/e84kdj.png

Offline

 

#6 2012-11-05 16:04:23

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: How do I get the sprite to come out of the repeat loop and stop moving

No, it's not a new variable; it's just what you would use to detect when the bird should appear again.

Last edited by ErnieParke (2012-11-05 16:04:54)


http://i46.tinypic.com/35ismmc.png

Offline

 

#7 2012-11-05 18:15:39

Fernandop91
New Scratcher
Registered: 2012-10-30
Posts: 8

Re: How do I get the sprite to come out of the repeat loop and stop moving

I solved my problem, its a noobie fix but i just added like 8 more bird spawns and make them wait 10-70 seconds.

Offline

 

Board footer