Discuss Scratch

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.
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 clicked
forever

wait until <touching [sprite1 v] ?>
switch costume to [costume1 v]
wait until <touching [sprite2 v] ?>
switch costume to [costume2 v]
end
Hope this helps!
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

shoresbeep wrote:

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

Langdon35 wrote:

when green flag clicked
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
Hope this helps!
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

shoresbeep wrote:

No, then you would take out the forever loop, and do that only once
Why?
peppermintpatty5
Scratcher
1000+ posts

How to change costumes when one sprite touches another

Your script should be
when green flag clicked
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
Hope this helps!
Langdon35
Scratcher
500+ posts

How to change costumes when one sprite touches another

peppermintpatty5 wrote:

Your script should be
when green flag clicked
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
Hope this helps!
Nice
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

magic748 wrote:

You should close discussion because problem solved
And 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)

Powered by DjangoBB