Discuss Scratch

SHR3K4L1FE
Scratcher
23 posts

how do i make it so when i click a button one time a sprite shows and if i click it again the sprite disappears?

i only need help with the second time i click the button and how im gonna code it
Theo_1er
Scratcher
500+ posts

how do i make it so when i click a button one time a sprite shows and if i click it again the sprite disappears?

pigger9
Scratcher
0 posts

how do i make it so when i click a button one time a sprite shows and if i click it again the sprite disappears?

I think this can help. The variable foo can just be called # or variable
when this sprite clicked
if <(foo) = [0]> then
set [foo] to [1]
else
set [foo] to [0]
end
if <(foo) = [0]> then
show
else
hide
end
Yusei-Fudo
Scratcher
1000+ posts

how do i make it so when i click a button one time a sprite shows and if i click it again the sprite disappears?

pigger9 wrote:

I think this can help. The variable foo can just be called # or variable
when this sprite clicked
if <(foo) = [0]> then
set [foo] to [1]
else
set [foo] to [0]
end
if <(foo) = [0]> then
show
else
hide
end

We can shorten the scripts a little, it's also easier to make.
Don't mind my block colors, I'm using Scratch Addon and changed the color of Scratch on my screen.
SHR3K4L1FE
Scratcher
23 posts

how do i make it so when i click a button one time a sprite shows and if i click it again the sprite disappears?

Yusei-Fudo wrote:

pigger9 wrote:

I think this can help. The variable foo can just be called # or variable
when this sprite clicked
if <(foo) = [0]> then
set [foo] to [1]
else
set [foo] to [0]
end
if <(foo) = [0]> then
show
else
hide
end

We can shorten the scripts a little, it's also easier to make.
Don't mind my block colors, I'm using Scratch Addon and changed the color of Scratch on my screen.
i need a code where if a sprite is clicked one time variable 1 sets to 1 and variable 2 sets to 0 and when its clicked again variable 1 sets to 0 and variable 2 sets to 1
Theo_1er
Scratcher
500+ posts

how do i make it so when i click a button one time a sprite shows and if i click it again the sprite disappears?

when this sprite clicked
if <(foo) = [0]> then
set [foo v] to [1]
set [foo2 v] to [0]
else
set [foo v] to [0]
set [foo2 v] to [1]
end

Last edited by Theo_1er (May 22, 2021 21:54:38)

Powered by DjangoBB