Need some help with the scratch catch game

Hello people,
So I’ve been doing the Scratch course, and I am working on a (tid more complex) version of the Classic Catch game. After doing what was said in the course I decided to change it in such a way that you need to grab a total amount as quickly as possible. I tried a couple of different ways of telling it to stop spawning in an apple after catching 3, but it just keeps on falling even if it goes above 3. I tried using the repeat until, the if and the forever ones to keep the item falling for a while before stopping it… but it just never stops >.<

Anyone know what I’m doing wrong?
As an example of the apple item I have;

when flag clicked
Set size to 25%
show
go to x: random number Y; 175
Repeat until Apple = 3
repeat until y position < -179
change y by -5
go to random number y; 175
go to x; 0 y; 175
hide

As well as the counter for catching it;

when flag clicked
forever
if touching player then
change apple by 1
change score by 1
go to random number y; 175

Hello,

In your above example, I don’t see a place where you set your variable apple. If the variable isn’t set, it appears to continue from when it last stopped. In one run I made it stop at 3. When I started another run of the game, the variable still contained the number 3.

I did try a couple of attempts to accomplish this though, and I was able to do it using both forever and repeat until blocks.

The following is setup in my good sprite, a baseball. Each of these accomplish the goal of stopping spawns, hiding the sprite, and stopping the changes made to the sprite. In my own attempt with this section of the course, I attempted to create a title screen. That is why I have When backdrop switches to Jurassic.

when flag clicked
set spawnNumber to 0
hide

when backdrop switches to Jurassic
forever
if touching player ? then
change score by 10
go to x: pick random -215 to 215 y: 160
if on edge bounce
change spawnNumber by 1
change hiddenScore by 1
if spawnNumber > 2 then
hide
set good thing speed to 0
end if
end if

when flag clicked
forever
if spawnNumber < 3 then
if y position < -180 then
change score by -5
go to x: pick random -215 to 215 y: 160
end if
change y by good thing speed
turn left 15 degrees
end if

I hope this helps.

edit: made it a bit more compact.

My apologies, the reset for all numbers is set in the player as suggested in the making more variables video. It does indeed work now and they disappear when they are supposed to, thank you very much ^^
Would you have any idea why it wouldn’t stop at said points before? When using the while, else and forever with stop script if were used?

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms