Discuss Scratch

jkoke
New to Scratch
1 post

change background when reaching the border

Hello,

I'm having an issue changing the background when hitting the border, I don't know why is not changing the background, actually if I stop the program showing a message for a couple of seconds, it changes the background, but it disappears so fast and shows the same again, how can I avoid this behavior? Also somebody knows how to control that this only happens when I hit the right border and do nothing if I hit the other ones?

https://scratch.mit.edu/projects/167887142/

Thanks in advance!
gor-dee
Scratcher
1000+ posts

change background when reaching the border

What is happening is when you touch the edge the variable fondo is changed to 2 but then the next bit of script “if fondo = 2” comes into effect and changes it to 3 and so on…. Try using
if <> then 



else

end

edit:

actually, better still, replace the four IF THEN blocks with
if <(fondo) = [4]> then 
set [fondo v] to [1]
switch backdrop to [1 v]


else
change [fondo v] by (1)
next backdrop
end
go to x: (-175) y: (0)

also make sure that the helicopter isn't touching the edge at X = -175

Last edited by gor-dee (July 2, 2017 20:09:23)

gavinskycastle
Scratcher
85 posts

change background when reaching the border

Is there any
forever

end
blocks changing the background every time?
I'm sorry i'm answering a question with a question, but it had to be done.

Also, here is a script telling it to change the background when it hits the right border:
forever
if <(x position) = [240]> then
switch backdrop to [example]
end
end

You're welcome.

Last edited by gavinskycastle (July 2, 2017 19:56:06)


when green flag clicked
forever
if <someone is looking at this signature> then
ask [Why are you here?] and wait
if <(answer) = [I'm bored]> then
open link [https://scratch.mit.edu/users/gavinskycastle]
end
end
end
gor-dee
Scratcher
1000+ posts

change background when reaching the border

For the second part of your question use
<(x position) > [280]>
instead of
<touching [edge v] ?>
you can then go back to -258 too

Last edited by gor-dee (July 2, 2017 20:21:47)

asivi
Scratcher
1000+ posts

change background when reaching the border

Powered by DjangoBB