문제

I am new to cocos2d-x and i am developing a game using cocos2d-x in xcode. In my game I added player sprite and Obstacle sprite. Obstacle sprite is moving continuously from right to left. Now i am trying to add collision between the two sprites. So that I am using bounding box.Following is my code. but it is not working. this is first time that i am using bounding box.

if(obs1->boundingBox().intersectsRect(man->boundingBox()))
{
    obs1->stopAllActions();
}

I created both the sprite in init() function and declare the above code in init function. Please help me to solve this.

도움이 되었습니까?

해결책

you should be using if xxx->containsPoint()

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top