Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to change costumes when one sprite touches another
- emser
-
New Scratcher
2 posts
How to change costumes when one sprite touches another
I want my sprite to change costumes when it touches another sprite. So far, no problem, but there is an issue with changing back to the old costume once it again is touched by the other sprite. How would I go about this problem?
I've been stuck with this problem for three days and I'd really appreciate some help.
I've been stuck with this problem for three days and I'd really appreciate some help.
- shoresbeep
-
Scratcher
1000+ posts
How to change costumes when one sprite touches another
Can you share the code with us, so that I can see what is going on?
- Langdon35
-
Scratcher
500+ posts
How to change costumes when one sprite touches another
when green flag clickedHope this helps!
forever
wait until <touching [sprite1 v] ?>
switch costume to [costume1 v]
wait until <touching [sprite2 v] ?>
switch costume to [costume2 v]
end

- shoresbeep
-
Scratcher
1000+ posts
How to change costumes when one sprite touches another
maybe you are touching both sprites at the same time, so that when you touch the second, it switches then immediately switches to the other costume?
- Langdon35
-
Scratcher
500+ posts
How to change costumes when one sprite touches another
maybe you are touching both sprites at the same time, so that when you touch the second, it switches then immediately switches to the other costume?Then I would
when green flag clickedHope this helps!
forever
wait (0.1) secs
wait until <touching [sprite1 v] ?>
switch costume to [costume1 v]
wait (0.1) secs
wait until <touching [sprite2 v] ?>
switch costume to [costume2 v]
end
- shoresbeep
-
Scratcher
1000+ posts
How to change costumes when one sprite touches another
No, then you would take out the forever loop, and do that only once 

- Langdon35
-
Scratcher
500+ posts
How to change costumes when one sprite touches another
No, then you would take out the forever loop, and do that only onceWhy?
- peppermintpatty5
-
Scratcher
1000+ posts
How to change costumes when one sprite touches another
Your script should be
when green flag clickedHope this helps!
forever
wait until <touching [Sprite 2 v] ?>
switch to costume ((costume #) + (1))
wait until <not<touching [Sprite 2] ?>>
wait until <touching [Sprite 2 v] ?>
switch to costume ((costume #) - (1))
end
- Langdon35
-
Scratcher
500+ posts
How to change costumes when one sprite touches another
Your script should beNicewhen green flag clickedHope this helps!
forever
wait until <touching [Sprite 2 v] ?>
switch to costume ((costume #) + (1))
wait until <not<touching [Sprite 2] ?>>
wait until <touching [Sprite 2 v] ?>
switch to costume ((costume #) - (1))
end

- emser
-
New Scratcher
2 posts
How to change costumes when one sprite touches another
Wow! Thank you so much geniuses. You all helped me 

- magic748
-
Scratcher
89 posts
How to change costumes when one sprite touches another
You should close discussion because problem solved
- peppermintpatty5
-
Scratcher
1000+ posts
How to change costumes when one sprite touches another
You should close discussion because problem solvedAnd to prevent necroposts such as this.

(Actually, now I remember that New Scratchers can't close their own posts…)
I bet a whole bitcoin that Paddle2See will be the one to close this. :P
Last edited by peppermintpatty5 (July 29, 2015 21:56:44)
- Discussion Forums
- » Help with Scripts
-
» How to change costumes when one sprite touches another




