0

I am a new programmer in cocos2D and I tried to do the tutorial https://www.makegameswith.us/tutorials/getting-started-with-spritebuilder/creating-two-levels/ but my Object just fly down on the ground and not right... I don't know what wrong is. here is my Code:

- (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];        
}

I used the Variable Fireball and not Pinguin... Fireball Physics config

If you can help me, many many Thanks.

Cœur
  • 37,241
  • 25
  • 195
  • 267
J0k3R
  • 303
  • 1
  • 14
  • CGPoint launchDirection = ccp(1, 0); <-- this creates a force on the X axis only, try ccp(1, 1) for a 45° angle trajectory. – CodeSmile Sep 03 '14 at 10:52
  • nothing change still fly down ... I tried some other physics body functions but nothing happen... – J0k3R Sep 03 '14 at 11:02
  • Try applyImpulse or a greater force than 8000. Check that gravity isn't set too high (0, -10 should suffice for gravity). – CodeSmile Sep 03 '14 at 11:14
  • just vertical down... Its awful, ... no impulse help, nothing,... I think the Physik body doenst work... – J0k3R Sep 03 '14 at 11:21

0 Answers0