Discuss Scratch

RCPD93
Scratcher
86 posts

How to make a sprite go to the previous costume

How do you do this?
_DragonLover_
Scratcher
58 posts

How to make a sprite go to the previous costume

You could either:

switchcostumetowhatever costume you want

or you could:

switchcostumetocostume#-1

Hopefully it shows correctly.

Last edited by _DragonLover_ (Feb. 17, 2016 21:35:38)

x_beast
Scratcher
49 posts

How to make a sprite go to the previous costume

well its a easy script theres 2 optoins
whenclicked
switchcostumetoprevouis

or you can do this, costume 1 is the current costume 2 the previous
whenclicked
switchcostumetocostume 2
hope this helps if you want it done for you visit this linkhttps://scratch.mit.edu/discuss/topic/183792/
RCPD93
Scratcher
86 posts

How to make a sprite go to the previous costume

Ok! Thanks. How do you close a forum discussion? And Check this forum if your interested in beta testing an online racing game! https://scratch.mit.edu/discuss/topic/183950/?page=1#post-1797351
_DragonLover_
Scratcher
58 posts

How to make a sprite go to the previous costume

RCPD93 wrote:

Ok! Thanks. How do you close a forum discussion? And Check this forum if your interested in beta testing an online racing game! https://scratch.mit.edu/discuss/topic/183950/?page=1#post-1797351
Well, I don't know how to close a discussion, but you could change the title to add (FIXED) or something like that. I think the Scratch Team will then delete the discussion.
RCPD93
Scratcher
86 posts

How to make a sprite go to the previous costume

How do I do that?
SuperMarioFan4
Scratcher
100+ posts

How to make a sprite go to the previous costume

Once the topic is 24 hours old, there will be a “Close Topic” button at the bottom of the page.
RCPD93
Scratcher
86 posts

How to make a sprite go to the previous costume

ok
gtoal
Scratcher
1000+ posts

How to make a sprite go to the previous costume

the suggestions above are not a good general solution. Create a ‘max costume number’ variable. Do ‘next costume’ until costume# wraps back to 1. Note what the highest value was. Then you can find the previous costume by adding (number of costumes -1) MOD number of costumes (taking care to correct for 0-base of MOD and 1-base of costume numbers)
_TigerJack21_
Scratcher
83 posts

How to make a sprite go to the previous costume

Generally, you could use:
defineLastCostumeswitchcostumetocostume#-1
Then, you could just drag
LastCostume
over to where you want to switch the costume back. Hope this helped!
RCPD93
Scratcher
86 posts

How to make a sprite go to the previous costume

Thanks everyone, But I'm closing this forum. Thanks!
gtoal
Scratcher
1000+ posts

How to make a sprite go to the previous costume

_TigerJack21_ wrote:

Generally, you could use:
defineLastCostumeswitchcostumetocostume#-1
Then, you could just drag
LastCostume
over to where you want to switch the costume back. Hope this helped!
doesn't work if you're on the first costume
_TigerJack21_
Scratcher
83 posts

How to make a sprite go to the previous costume

gtoal wrote:

_TigerJack21_ wrote:

Generally, you could use:
defineLastCostumeswitchcostumetocostume#-1
Then, you could just drag
LastCostume
over to where you want to switch the costume back. Hope this helped!
doesn't work if you're on the first costume

defineLastCostumeifnotcostume#=1thenswitchcostumetocostume#-1
EDIT:
I don't think I understood this - do you want it to go to the last costume when it gets to costume 1?

Last edited by _TigerJack21_ (Feb. 18, 2016 02:00:00)

gtoal
Scratcher
1000+ posts

How to make a sprite go to the previous costume

_TigerJack21_ wrote:

gtoal wrote:

_TigerJack21_ wrote:

Generally, you could use:
defineLastCostumeswitchcostumetocostume#-1
Then, you could just drag
LastCostume
over to where you want to switch the costume back. Hope this helped!
doesn't work if you're on the first costume

defineLastCostumeifnotcostume#=1thenswitchcostumetocostume#-1
EDIT:
I don't think I understood this - do you want it to go to the last costume when it gets to costume 1?

yes - thats why you add (N-1) rather than subtract 1. Using MOD reduces the larger number back into the proper range.
_TigerJack21_
Scratcher
83 posts

How to make a sprite go to the previous costume

gtoal wrote:

_TigerJack21_ wrote:

gtoal wrote:

_TigerJack21_ wrote:

Generally, you could use:
defineLastCostumeswitchcostumetocostume#-1
Then, you could just drag
LastCostume
over to where you want to switch the costume back. Hope this helped!
doesn't work if you're on the first costume

defineLastCostumeifnotcostume#=1thenswitchcostumetocostume#-1
EDIT:
I don't think I understood this - do you want it to go to the last costume when it gets to costume 1?

yes - thats why you add (N-1) rather than subtract 1. Using MOD reduces the larger number back into the proper range.
Oh! OK! That makes sense
WalrusGamez
Scratcher
1 post

How to make a sprite go to the previous costume

Thank you! This was helpful!!!
Foxboy1213
Scratcher
13 posts

How to make a sprite go to the previous costume

In scratch 3.0, the codes you are used to have won't work.
switchcostumeto:

Last edited by Foxboy1213 (Nov. 13, 2020 18:05:21)

Powered by DjangoBB