How would one detect a touch on a rotated CCSprite?
I am familiar with the general technique of using ccTouchesBegan and contentSize, anchorPoint etc. to have a sprite detect if a touch was within its bounds … but I am not sure how to proceed once the sprite has been rotated by some angle.
I want the sprite itself to detect the touch (encapsulation) and report the event via a delegate to another object.
If anyone has some code to share … would be great.
Try using the CCNode convertTouchToNodeSpaceAR: method to convert the point to the rotated coordinates and then you can do the compare of the sprite bounds.
I made this a category on CCNode so it’s available to any CCNode or subclass.
and the implementation: