I have a scene with some sprite on it (added), the gamer has to select one of them and take the next action.
What is the simplest way to select one of the sprites accurately?
I am looking for a method that recieves a click coordinate and returns one of the sprites on the scene.
Since the sprites cant be well fitted in a bounding box I dont like to use a minimum bounding box approximation.
I was thinking of loading the sprites into a matrix and creating a scene matrix that each member belongs to a specified sprite, but it costs a lot( each pixel must be transformed using an affine transformation and it must be recalculated each time one of the sprites move)
Can someone show me a better way with a lower cost?
P.S I am using Swift and Apple's SpriteKit There is a code for minimum bounding box but I am looking for an accurate method.
Inaccurate method if some interested is something like this :
for touch in touches
{
var location : CGPoint = (touch as! UITouch).locationInNode(self)
for asprite in self.viewIso.children
{
if (asprite.containsPoint(location))
{
println("Selected : \(asprite.name as String)")
return
}
}
}
Thanks Iman