我正在为 Android 开发 cocos2d-x 游戏,但遇到了问题。
_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
}
我打开了 CC_SPRITE_DEBUG_DRAW 和 CC_SPRITEBATCHNODE_DEBUG_DRAW,问题是 boundingBox 比看起来要大。当我单击边界框附近的某个位置时,它会注册,就好像我实际上在其中单击一样。
请问谁能帮帮我?:)