Hi,
I'm using TargetedTouchDelegate in some TextureNode and work ok, but how I can know wich object was touched from his parent?
Thanks,
Juan Pablo
A fast, easy to use, free, and community supported 2D game engine
Hi,
I'm using TargetedTouchDelegate in some TextureNode and work ok, but how I can know wich object was touched from his parent?
Thanks,
Juan Pablo
You either need to implement the touch delegate on EACH object so each custom object returns touch responses, or compare touches on your layer/node with the position on objects on your layer. You could use CGRectContainsPoint() for this.
Thanks, but not is clear for me.
If I use CGRectContainsPoint don't use TargetedTouchDelegate right?
And how I can implement the touch delegate?
I might not be understanding your question, but why not just have each object call a method of the parent object when they are touched?
I think TouchDispatcher need a method to return the current touched object, somshing like [TouchDispatcher sharedDispatcher] currentTargetedDelegate.
This is possible?
What are you implementing the TouchDispatcher on? A Layer, Sprite, etc?
If you implement it on a layer, its going to dispatch touches ANYWHERE on that layer and you will and you will probably want to detect touches on children in the layer. This will require you to compare child positions with touch points.
If you implement it on each object (like a sprite) it will only dispatch touches on that object. (this sounds like what you are trying to do).
Yes, that is. I detect touchs in a TextureNode, and the parent layer need know wich child was touched.
You must log in to post.