Search code examples
cocos2d-iphonecocos2d-x

How to get the visible rect of the node in cocos2d or cocos2d-x?


How to get the visible rect of the node? Sometime i need to hide 50% of the sprite, if the touch point is in the hidden part, just return but not to active the callback function.


Solution

  • There is no default functions, maybe you need to create your own class to handle it.

    You can try to create a subclass of CCNode with a changeable CCRect as touchable area, or you can try to read the Image Raw data and detect if the touch position pixel is transparent or not.