Discuss Scratch

melflorezzz
New Scratcher
3 posts

Click Sprite

Hey guys!
I am mostly done with my game, but I am running into 2 problems.

1. I added “when clicked” -> perform this action to 4 different sprites. When I am editing, they all work fine, but when I play as if I had posted the game, nothing happens when I click the sprites.

2. There is a part of the game where you have to bounce a ball off a bar, and every time the ball hits the bar, the score goes up by 1 until you reach 6 and can go to the next level. However, I tried adding a condition that if the ball touches the floor, then you lose. I tried adding if y< -130 (below the bar) then stop all other script in sprite and switch background, once you press the space key then you return to the game and can try again. I added this to the forever loop and the game glitched. I added it outside of the forever loop and it doesnt work.

I can post my game if necessary.
Thank you for the help!
InsertScreamofRage
New Scratcher
10 posts

Click Sprite

Posting the project would definitely help!
Is the space key condition in the same sprite as the stop this sprite block?
tidelgl
Scratcher
100+ posts

Click Sprite

try the broadcast

when this sprite clicked
broadcast [sprite clicked v] and wait
... // your action code here

when I receive [sprite clicked v]
... // all sprites should have this to handle the click event


// here is the example

when green flag clicked
set [score v] to (0)
forever
move (10) steps
if on edge, bounce
if <touching [bar v] ?> then
change [score v] by (1)
point in direction (pick random (-45) to (45))
end
if <(y position) < (-130)> then
stop [other scripts in sprite v]
switch backdrop to [game over v]
wait until <key [space v] pressed?>
switch backdrop to [game background v]
go to x: (0) y: (0)
set [score v] to (0)
start this script // restart the movement
end
end

Last edited by tidelgl (Sept. 15, 2025 04:06:42)

Powered by DjangoBB