Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to change the costume of a specific clone?
- Zarpi
-
23 posts
How to change the costume of a specific clone?
Can you change the costume of a clone? If so, can you tell me how to do it?
Help would be very much appreciated. It's for a very big project that I'm working on.
Thanks in advance.
Help would be very much appreciated. It's for a very big project that I'm working on.
Thanks in advance.
- cIoudyness
-
500+ posts
How to change the costume of a specific clone?
certainly! we just need to let scratch know which clone we want to have the costume
for this you can use clone ids. basically you create a local (for this sprite only) variable and change it to something different right before you create a clone. maybe increase it by 1.
then, you can just tell the clone with id of 1 to switch its costume.
another option is to switch the costume right before you create the clone, then switch it back again. only this one clone will have the special costume, while all the others have the costume of the parent sprite
for this you can use clone ids. basically you create a local (for this sprite only) variable and change it to something different right before you create a clone. maybe increase it by 1.
then, you can just tell the clone with id of 1 to switch its costume.
when I start as a clone
if <(id) = (1)> then
switch costume to [cow_dancing v]
end
another option is to switch the costume right before you create the clone, then switch it back again. only this one clone will have the special costume, while all the others have the costume of the parent sprite
- Zarpi
-
23 posts
How to change the costume of a specific clone?
Alright! Thanks! Now I have another problem. certainly! we just need to let scratch know which clone we want to have the costume
for this you can use clone ids. basically you create a local (for this sprite only) variable and change it to something different right before you create a clone. maybe increase it by 1.
then, you can just tell the clone with id of 1 to switch its costume.when I start as a clone
if <(id) = (1)> then
switch costume to [cow_dancing v]
end
another option is to switch the costume right before you create the clone, then switch it back again. only this one clone will have the special costume, while all the others have the costume of the parent sprite
Since I'm animating each body part as a clone and I want to change the costume of the body for the walking animation…
I'm confused on how to change it now that I've already made the clone.
And, since it's divided in head / body / legs / shoes there's clones after it.
Last edited by Zarpi (July 11, 2022 22:33:45)
- abcde1234qwe
-
500+ posts
How to change the costume of a specific clone?
Alright! Thanks! Now I have another problem.
Since I'm animating each body part as a clone and I want to change the costume of the body for the walking animation…
I'm confused on how to change it now that I've already made the clone.
And, since it's divided in head / body / legs / shoes there's clones after it.
when I start as a clone
if <(id) = (1)> then
forever
switch costume to ([costume # v] of [main sprite v])
end
end
- cIoudyness
-
500+ posts
How to change the costume of a specific clone?
both ways it should be pretty easy. stuff
first way: if all the clones have unique ids then you can just code them to do what you want
set [id v] to (0)
repeat (10)
change [id v] by (1)
create clone of [myself v]
when I start as a clone
if <(id) = (1)> then
// let’s pretend this is an arm
forever
do arm stuff :: sensing
end
end
if <(id) = (2)> then
//this could be the legs
forever
switch costume to [walking_1 v]
repeat (10)
next costume
end
end
if you’re using the second method above you should also be fine. just make sure no clones start on the same costume, and replace occurrences of the id variable above with the costume name or costume number reporters.
(in the same way make sure no clones start with the same id. if you’re using a local variable and the change by 1 script above this won’t be a problem)
Last edited by cIoudyness (July 11, 2022 22:40:25)
- Zarpi
-
23 posts
How to change the costume of a specific clone?
both ways it should be pretty easy. stuff
first way: if all the clones have unique ids then you can just code them to do what you wantset [id v] to (0)
repeat (10)
change [id v] by (1)
create clone of [myself v]
when I start as a clone
if <(id) = (1)> then
// let’s pretend this is an arm
forever
do arm stuff :: sensing
end
end
if <(id) = (2)> then
//this could be the legs
forever
switch costume to [walking_1 v]
repeat (10)
next costume
end
end
if you’re using the second method above you should also be fine. just make sure no clones start on the same costume, and replace occurrences of the id variable above with the costume name or costume number reporters.
(in the same way make sure no clones start with the same id. if you’re using a local variable and the change by 1 script above this won’t be a problem)
Thanks, both of you!Alright! Thanks! Now I have another problem.
Since I'm animating each body part as a clone and I want to change the costume of the body for the walking animation…
I'm confused on how to change it now that I've already made the clone.
And, since it's divided in head / body / legs / shoes there's clones after it.when I start as a clone
if <(id) = (1)> then
forever
switch costume to ([costume # v] of [main sprite v])
end
end
I will def credit you when I publish the project.
- BeMeebEth1030
-
2 posts
How to change the costume of a specific clone?
This will Help Me Alot with my Game!
- giraffeeproedmo
-
38 posts
How to change the costume of a specific clone?
Alright! Thanks! Now I have another problem.
Since I'm animating each body part as a clone and I want to change the costume of the body for the walking animation…
I'm confused on how to change it now that I've already made the clone.
And, since it's divided in head / body / legs / shoes there's clones after it.when I start as a clone
if <(id) = (1)> then
forever
switch costume to ([costume # v] of [main sprite v])
end
end
I use this one
- Discussion Forums
- » Help with Scripts
-
» How to change the costume of a specific clone?