Discuss Scratch

-CoolIguana-
Scratcher
100+ posts

Jigsaw Puzzle

Do anyone help me with a code for my Jigsaw Puzzle code, I really don’t understand how do you do clones so each puzzle pieces it’s own kind.
theashbreather
Scratcher
100+ posts

Jigsaw Puzzle

Use a local/private variable. When creating a variable, select for this sprite only. That way, when the clone is created, it receives its own separate copy of the variable. This means you can increment the variable before creating a clone and therefore have setup a system that can keep track of clones and give them individuality.
-CoolIguana-
Scratcher
100+ posts

Jigsaw Puzzle

theashbreather wrote:

Use a local/private variable. When creating a variable, select for this sprite only. That way, when the clone is created, it receives its own separate copy of the variable. This means you can increment the variable before creating a clone and therefore have setup a system that can keep track of clones and give them individuality.

Thx but how do you make each puzzle different costume.
switch costume to [blah blah blah]
theashbreather
Scratcher
100+ posts

Jigsaw Puzzle

-CoolIguana- wrote:

theashbreather wrote:

Use a local/private variable. When creating a variable, select for this sprite only. That way, when the clone is created, it receives its own separate copy of the variable. This means you can increment the variable before creating a clone and therefore have setup a system that can keep track of clones and give them individuality.

Thx but how do you make each puzzle different costume.
switch costume to [blah blah blah]

Since you incremented the variable each clone has a different name corresponding to a number. So you can test what the clone's number is when it starts and if it's a certain number it should switch to a certain costume.
when green flag clicked
repeat (10)
change [var v] by (1)
create clone of [myself v]
end

when I start as a clone
if <(var) = [1]> then
switch costume to [1 v]
end
if <(var) = [2]> then
switch costume to [2 v]
end

Although a better way to implement this is to instead of testing for the clone's local variable value is to change the names of every costume to 1, 2, 3…etc and then set the clone's costume to local variable, so scratch tests for the variable's value and changes to the corresponding value, which saves you an entire headache and makes it easier to maintain stuff.
when green flag clicked
repeat (10)
change [var v] by (1)
create clone of [myself v]
end

when I start as a clone
switch costume to (var)

Powered by DjangoBB