Cocos2dx中的body节点

时间:2013-09-03 11:10:43

标签: cocos2d-iphone cocos2d-x

您能否将此cocos2d代码转换为cocos2dx?

shiprightnode = [[Shipright alloc] initWithBody:shipright game:game_];
[game_ addBodyNode:shiprightnode z:1];
[shiprightnode release];

2 个答案:

答案 0 :(得分:1)

shiprightnode = new Shipright();
shiprightnode->init(p_game_);
game_->addBodyNode(shiprightnode);
shiprightnode->release();

答案 1 :(得分:0)

auto shiprightnode = Shipright :: createWithGame(game _);

游戏_-> addBodyNode(shiprightnode,1);

//无需释放shiprightnode,因为它会创建自动释放对象。