Discuss Scratch

Infusion77
Scratcher
18 posts

Individual Clone Sizes!

Is it possible to give clones independent sizes? when I try to change a certain clone's size through their ID, They change every clone's size.
PGBear73
Scratcher
100+ posts

Individual Clone Sizes!

Infusion77 wrote:

Is it possible to give clones independent sizes? when I try to change a certain clone's size through their ID, They change every clone's size.
when I start as a clone
forever
set size to (var) %
end

“var” has to be a “this sprite only” variable.
Xx_InfiniteGame_xX
Scratcher
35 posts

Individual Clone Sizes!

Hello!

You can try using list. Create a for-this-sprite-only variable called “ID” (or whatever name that represent an ID for your clones). Then, create a list called “Clones' Size” (or whatever name that represent the size of your clones). Each number (the left side) on the list represent the ID's of your clone. Everytime you create a clone, make sure to give it an ID by :

set [ID v] to [(any number here)]
add [] to [Clones' Size v] // Add nothing so there's a space for your clones' size data

Now, create two global variable called “set to” and “est size” (these variable names is up to you actually). Everytime you wanna change a clone's size, just run this block :

replace item ((the clone's ID here) v) of [Clones' Size v] with [(the size you want to set here)] // Actually the "the clone's ID here" isn't a variable, Scratch's Forum thinks it is

And make sure there's this block in your clone's loop :

set size to (item (ID v) of [Clones' Size v] :: list)

Phew! This takes me a long time. hope this helps!
Yusei-Fudo
Scratcher
1000+ posts

Individual Clone Sizes!

The answer is Yes. You can hold individual clone sizes by creating a variable whatever you want to call it. Make it “For this sprite Only”. Before you clone, set that variable to something, and they broadcast a message or something, as long as you get a new script running after you do all the clones. Look inside this demo I made: https://scratch.mit.edu/projects/518722192/editor

CST1229
Scratcher
1000+ posts

Individual Clone Sizes!

If you want to use broadcasts:

set [target clone id v] to [123] // for all sprites, this will be the clone you want to change size of
set [target size v] to [50] // for all sprites, the size to set the clone to

when I receive [set size of clone v]
if <(clone id) = (target clone id)> then
set size to (target size)
end

//make sure to use clone ids when spawning clones! example:
set [clone id v] to [1] // reset
repeat (10)
create clone of [myself v]
change [clone id v] by (1) // this variable must be for this sprite only
end
set [clone id v] to [0] // id 0 will be the original sprite
TheCodingLamp
Scratcher
49 posts

Individual Clone Sizes!

You need to use lists. Every time you make a clone, you can add a new item to a list. like so:
when green flag clicked
set [count v] to [0]
repeat (100)
change [count v] by (1) //By the way, "count" is a private variable.
create clone of [myself v]
end

And in the clone's script, you need to make sure that you change the size accordingly, like so:
when I start as a clone
forever
set size to (item (count) of [list v] :: list) //note how the count, as a private variable, is used to access the specific clone's spot in the list.
end

And now, for extra clarity, you can add a custom function like so:

define Change Size of Clone No.(number) with (value)
replace item (number) of [list v] with (value)

Last edited by TheCodingLamp (April 21, 2021 12:43:14)

Powered by DjangoBB