If a layer has 10*6 sprites,how to get the selected the sprite?


#1

If a layer has 10*6 sprites,how to get the selected the sprite ??


#2

Hi,

What do you mean by “get”, you want to detect which sprite should react for a touch event or you want just retrieve the sprite from layer’s children?
In the first case, you can listen the events in layer, and check every sprite’s position in order to know which one should respond
In the last case, you can add the sprite to layer with a tag, and later you can retrieve it with this tag.

Huabin


#3

Hi,

What does “get the selected the sprite” mean?
Does it mean get the selected the sprite by click or touch?

If it is right, please reference /samples/tests/TouchesTest/Paddle.js

Bests
David


#4

i mean get the selected the sprite by touch