Skip to main content

If you wish to detect if a ccpoint in inside a sprite rectangle in Cocos2D-HTML5, checkout this quick snippet:

onTouchesEnded:function (touches, event) { for( n=0; n < touches.length; n++) { var touch = touches[n]; if (cc.rectContainsPoint(this.yoursprite.getBoundingBox(), touch.getLocation()) == true) { // Sprite has been touched } } } 

Source: http://gamedevuniversity.com/cocos2d-html5-detect-if-sprite-has-been-touched/

If you wish to detect if a ccpoint in inside a sprite rectangle in Cocos2D-HTML5, checkout this quick snippet:

http://gamedevuniversity.com/cocos2d-html5-detect-if-sprite-has-been-touched/

If you wish to detect if a ccpoint in inside a sprite rectangle in Cocos2D-HTML5, checkout this quick snippet:

onTouchesEnded:function (touches, event) { for( n=0; n < touches.length; n++) { var touch = touches[n]; if (cc.rectContainsPoint(this.yoursprite.getBoundingBox(), touch.getLocation()) == true) { // Sprite has been touched } } } 

Source: http://gamedevuniversity.com/cocos2d-html5-detect-if-sprite-has-been-touched/

Source Link

If you wish to detect if a ccpoint in inside a sprite rectangle in Cocos2D-HTML5, checkout this quick snippet:

http://gamedevuniversity.com/cocos2d-html5-detect-if-sprite-has-been-touched/