大家好,我是 COCOS2DX 框架的新手,正在尝试开发破砖游戏。我正在关注这个演示Brick breker 游戏本教程在 cocos2d (iPhone) 中。我在 cocos2dx 中编码并正常工作。但是当我正在实施ccTouchesMoved
方法时。我的代码可以正确编译和运行,但是当我触摸(单击)屏幕时,它会崩溃并出现错误违规行为。我的代码是
void HelloWorld::ccTouchesMoved(CCSet* touches, CCEvent* event)
{
if (_mouseJoint == NULL) return;
CCTouch *myTouch = (CCTouch*)touches->anyObject();
CCPoint location = myTouch->locationInView();
location = CCDirector::sharedDirector()->convertToGL(location);
b2Vec2 locationWorld = b2Vec2(location.x/PTM_RATIO, location.y/PTM_RATIO);
_mouseJoint->SetTarget(locationWorld);
}
我该如何解决这个问题。请指导我。