Discuss Scratch

Yeorgi3
Scratcher
16 posts

Clone XY position

I am working on a cell direction decider, and for that, I need to have the XY position for each individual clone. How do I set clone specific variables to track the XY position?
deck26
Scratcher
1000+ posts

Clone XY position

Each clone has it's own x and y position variable. If you need to pass that to other sprites the easiest option is to have a local cloneID variable so each clone can be identified and you can store its position in x and y lists.
juicykiwi
Scratcher
86 posts

Clone XY position

deck26 wrote:

Each clone has it's own x and y position variable. If you need to pass that to other sprites the easiest option is to have a local cloneID variable so each clone can be identified and you can store its position in x and y lists.

Please elaborate, I am having the same problem.
deck26
Scratcher
1000+ posts

Clone XY position

To give each clone it's own ID use a local (this sprite only) variable.

hide      // don't use the sprite, just the clones
set [cloneID v] to [1 ]
repeat (5) // we'll create 5 clones at once but don't have to do it this way
create clone of [myself v]
change [cloneID v] by [1]
end


when I start as a clone
show // assuming we want clones to show at this point
replace item (cloneID) of [xlist v] with (x position)

Obviously the xlist has to contain enough items before you can use replace. You can then replace the xlist value with the x position whenver it changes (so a loop or do it when the value changes). You'd probably want the y values as well.
asivi
Scratcher
1000+ posts

Clone XY position

first create a variable

(cloneID)

second create two lists one for Xpos and one for Ypos

(Xclone :: list)
(Yclone :: list)

then

when green flag clicked
set [cloneID v] to [0 ]
hide
repeat (number of clones to create)
change [cloneID v] by (1)
go to x: (x position desired) y: (y position desired)
insert (x position) at ((cloneID)) of [ (Xclone :: list)]
insert (y position) at ((cloneID)) of [ (Yclone :: list)]
create clone of [ myself or the sprite you want v]
and so...
end





edit: sorry, deck 26 did respond while i was writing this

Last edited by asivi (Nov. 22, 2015 22:21:00)

Havoc_Studios
Scratcher
9 posts

Clone XY position

Would the clone tracking work for a tower defence game?
RokCoder
Scratcher
1000+ posts

Clone XY position

Havoc_Studios wrote:

Would the clone tracking work for a tower defence game?

Yes, it would work fine. You actually responded to a thread that ended over two years ago though. If you have any more questions about this, you should really start your own (new) thread.
Havoc_Studios
Scratcher
9 posts

Clone XY position

Oh…Ok thanks though!!!
FlawlessAlias
Scratcher
9 posts

Clone XY position

Necromancy!
deck26
Scratcher
1000+ posts

Clone XY position

FlawlessAlias wrote:

Necromancy!
Please don't spam or necropost.
iron_Dense
New Scratcher
11 posts

Clone XY position

asivi wrote:

first create a variable

(cloneID)

second create two lists one for Xpos and one for Ypos

(Xclone :: list)
(Yclone :: list)

then

when green flag clicked
set [cloneID v] to [0 ]
hide
repeat (number of clones to create)
change [cloneID v] by (1)
go to x: (x position desired) y: (y position desired)
insert (x position) at ((cloneID)) of [ (Xclone :: list)]
insert (y position) at ((cloneID)) of [ (Yclone :: list)]
create clone of [ myself or the sprite you want v]
and so...
end





edit: sorry, deck 26 did respond while i was writing this


Wait,but this only takes note of the starting position of clones. I'd want a constant note of their position to be able to do things like…say… “Go to this clone” just like i would do “go to this sprite”
deck26
Scratcher
1000+ posts

Clone XY position

iron_Dense wrote:

asivi wrote:

first create a variable

(cloneID)

second create two lists one for Xpos and one for Ypos

(Xclone :: list)
(Yclone :: list)

then

when green flag clicked
set [cloneID v] to [0 ]
hide
repeat (number of clones to create)
change [cloneID v] by (1)
go to x: (x position desired) y: (y position desired)
insert (x position) at ((cloneID)) of [ (Xclone :: list)]
insert (y position) at ((cloneID)) of [ (Yclone :: list)]
create clone of [ myself or the sprite you want v]
and so...
end





edit: sorry, deck 26 did respond while i was writing this


Wait,but this only takes note of the starting position of clones. I'd want a constant note of their position to be able to do things like…say… “Go to this clone” just like i would do “go to this sprite”
I suggest you create your own topic. This topic is old.
finneroo
Scratcher
2 posts

Clone XY position

hi
finneroo
Scratcher
2 posts

Clone XY position

Oumuamua
Scratcher
1000+ posts

Clone XY position

finneroo wrote:

hi

finneroo wrote:


Pls, do not spam or necropost.
PokemonLevel_80
Scratcher
4 posts

Clone XY position

deck26 wrote:

iron_Dense wrote:

asivi wrote:

first create a variable

(cloneID)

second create two lists one for Xpos and one for Ypos

(Xclone :: list)
(Yclone :: list)

then

when green flag clicked
set [cloneID v] to [0 ]
hide
repeat (number of clones to create)
change [cloneID v] by (1)
go to x: (x position desired) y: (y position desired)
insert (x position) at ((cloneID)) of [ (Xclone :: list)]
insert (y position) at ((cloneID)) of [ (Yclone :: list)]
create clone of [ myself or the sprite you want v]
and so...
end





edit: sorry, deck 26 did respond while i was writing this


Wait,but this only takes note of the starting position of clones. I'd want a constant note of their position to be able to do things like…say… “Go to this clone” just like i would do “go to this sprite”
I suggest you create your own topic. This topic is old.
PokemonLevel_80
Scratcher
4 posts

Clone XY position

I need help with listing the clone's x and y, while replacing the old x with the new x, and replacing the old y with the new y!
theanonymousweirdo
Scratcher
500+ posts

Clone XY position

PokemonLevel_80 wrote:

I need help with listing the clone's x and y, while replacing the old x with the new x, and replacing the old y with the new y!
Make your own topic instead of posting on an old one
TariqjeMaakt
Scratcher
93 posts

Clone XY position

I'm sorry for the necropost, but you can now use these blocks
 (x position) (y position) 
to get the X & Y position of that clone. (if these are put inside of a “when i start as a clone” block)
AwesomeGamer22350
Scratcher
29 posts

Clone XY position

I know this is old (most posts are lol) but I usually come up with some mumbo jumbo and end up getting it to work, in this game: https://scratch.mit.edu/projects/377582701/editor I use it to keep track of their health using their ID and positions

Powered by DjangoBB