Search Results

Search found 3 results on 1 pages for 'diken'.

Page 1/1 | 1 

  • Sprite Body can not stop

    - by Diken
    Hey i have issue regarding jump sprite body. In my code i am using moveLeft and moveRight Button and when i am press moveRight Button using following code if (moveRight.active==YES) { b2Vec2 force=b2Vec2(4,0); ballBody->SetLinearVelocity(force); } Its move perfectly and When i release this Button than sprite body stop using following code else { b2Vec2 force=b2Vec2(0,0); ballBody->SetLinearVelocity(force); } But when i put this else part then jump can not done. My jump code is following if (jumpSprite.active==YES) { NSLog(@"Jump Sprite"); b2Vec2 locationWorld; locationWorld=b2Vec2(0.0f,4.0f); double force=ballBody->GetMass(); ballBody->ApplyLinearImpulse(force*locationWorld, ballBody->GetWorldCenter()); } If i remove else part then jump will perform complete but sprite body can not stop after release button. So what to do?? Thanks in advance

    Read the article

  • Confusing box2d forces

    - by Diken
    Hello Friends. This is my demo game screen-shoot. Here i am using three buttons. Right-bottom button is used for jump and left-bottom buttons used for move left and right. I have some questions 1) should i use linearImpuls for jump body?? 2) For move right and left which types of force i applied??? PLease tell me i am confusing to use linearImpuls, applyforce and linearVelocity. Thanks in advance

    Read the article

  • Can i add friction in air?

    - by Diken
    I have issue regarding speed in air. When i jump and move simultaneously that time speed of player increase.For jump i am using impuls and for movement i am using force.I want to slow speed when player is in air. Thanks in advance Following is my update method ih HUDLayer -(void)update:(ccTime)dt :(b2Body *)ballBody :(CCSprite *)player1 :(b2World *)world { if (moveRight.active==YES) { ballBody->SetActive(true); b2Vec2 locationworld=b2Vec2(maxSpeed,0); double mass=ballBody->GetMass(); ballBody->ApplyForce(mass*locationworld, ballBody->GetWorldCenter()); // ballBody->SetLinearDamping(1.2f); } else if(moveLeft.active==YES) { ballBody->SetActive(true); b2Vec2 locationworld=b2Vec2(-10,0); double mass=ballBody->GetMass(); ballBody->ApplyForce(mass*locationworld, ballBody->GetWorldCenter()); // ballBody->SetLinearDamping(1.2f); } } Following is jump -(void)jump:(b2Body*)ballBody:(ccTime)dt:(BOOL)touch { if (touch) { if (jumpSprte.active==YES) { ballBody->SetActive(true); b2Vec2 locationWorld; //locationWorld=b2Vec2(0.0f,98.0f); locationWorld=b2Vec2(0,32); // double mass=ballBody->GetMass(); ballBody->ApplyLinearImpulse(locationWorld, ballBody->GetWorldCenter()); // ballBody->ApplyForce(mass*locationWorld, ballBody->GetWorldCenter()); ballBody->SetLinearDamping(1.2f); } } } So where i apply logic??

    Read the article

1