Game Development Community

how to get CompositeSprite's child by world position?

by KevinYuen · in Torque 2D Beginner · 03/04/2013 (7:36 am) · 3 replies

I created a isometric map by CompositeSprite, now i want select tile sprite through world position.
but can't find any functions about that, call help... thanks!

#1
03/04/2013 (8:15 am)
Right now you can only select a sprite by one of three things:

  • Logical Position i.e. (0,0) {1,0}, (-5,-2) etc.
  • Sprite Id (you get this when you add a sprite)
  • Sprite Name (you can assign a name to a tile).
What you want is sprite "picking" and that is not currently implemented. It's extremely high on my list of things to get in. I'll try to get this done for ASAP!

Sorry for the delay.
#2
03/04/2013 (12:33 pm)
I've took the time this evening to add picking to CompositeSprite.

You can now perform the following operations:

  • .pickPoint()
  • .pickArea()
  • .pickRay()
As a basic example I updated the CompositeSpriteToy so that when you touch the CompositeSprite it deletes the sprite(s) where you touch. It does this using "pickPoint()".

I have pushed the work to the development branch.
#3
03/04/2013 (7:07 pm)
Thank you for your reply :), but i have a another question :(

isometric tile is a lozenge, they're in same layer, so i'll pick two tiles one-time if click tile's edge. like this:

f.hiphotos.baidu.com/album/s%3D369%3Bq%3D90/sign=238157880b7b020808c939e75be283ee/f11f3a292df5e0fed4a2f62c5d6034a85edf7260.jpg
•.pickPoint()
•.pickArea()
•.pickRay()

These methods can't seem to meet the demand. it maybe need a function like IsPtInLozenge(...) or IsPtInIrregularPolygon(...)