I am developing a game in cocos2d-x for Android and I have run into a problem.
_hammer = CCSprite::createWithSpriteFrameName("Hammer.png");
_hammer->setPosition(ccp(_screenSize.width * 0.5f - 4*((_hammer->getContentSize().width) * 0.15f), _screenSize.height * 0.055f ));
_hammer->setVisible(true);
_hammer->setScale((_screenSize.width / _hammer->getContentSize().width) * 0.15f);
_hammer->setScale((_screenSize.height / _hammer->getContentSize().height) * 0.15f);
_hammerSelected = true;
{
CCTouch *touch = (CCTouch *) pTouches->anyObject();
CCPoint location = touch->locationInView();
location = CCDirector::sharedDirector()->convertToGL(location);
if ((CCRect::CCRectContainsPoint(_hammer->boundingBox(), location))) {
//do something
}
I turned on CC_SPRITE_DEBUG_DRAW and CC_SPRITEBATCHNODE_DEBUG_DRAW and the problems is that the boundingBox is bigger than it appears to be. When I click somewhere near the boundingBox it registers as if I actually clicked inside it.
Please can anyone help me out ? :)