我正在開發一款適用於Android的cocos2d-x遊戲,並遇到問題。Cocos2d-x boundingBox問題
_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的是大於它似乎是。當我點擊邊界框附近的某處時,它會註冊,就好像我真的在裏面點擊了一樣。
請任何人都可以幫我嗎? :)