0

我是 cocos2D 的新程序员,我尝试做教程https://www.makegameswith.us/tutorials/getting-started-with-spritebuilder/creating-two-levels/ 但我的对象只是飞到地上然后不对……我不知道出了什么问题。这是我的代码:

- (void)launchFire {
    // loads the Penguin.ccb we have set up in Spritebuilder
    CCNode* fireBall = [CCBReader load:@"Fireball"];
    // position the penguin at the bowl of the catapult
    fireBall.position = ccpAdd(_block.position, ccp(18, 50));

    CCLOG(@"Block Position: \nX:%.2f\nY:%.2f",_block.position.x,_block.position.y);
    CCLOG(@"Fireball Position: \nX:%.2f\nY:%.2f",fireBall.position.x,fireBall.position.y);
    // add the penguin to the physicsNode of this scene (because it has physics enabled)
    [_physicsNode addChild:fireBall];

    // manually create & apply a force to launch the penguin
    CGPoint launchDirection = ccp(1, 0);
    CGPoint force = ccpMult(launchDirection, 8000);
    [fireBall.physicsBody applyForce:force];        
}

我使用了可变火球而不是 Pinguin ...... 火球物理配置

如果你能帮助我,非常感谢。

4

0 回答 0