Cocos2d iphone 我的精灵身体如何能在box2d中跳跃并回到原来的位置
我的精灵怎么能跳回来呢?? 我正在iphone应用程序中使用box2d物理引擎。 我在使用冲动,但不能正常工作 有谁知道逻辑或代码比告诉我Cocos2d iphone 我的精灵身体如何能在box2d中跳跃并回到原来的位置,cocos2d-iphone,box2d-iphone,Cocos2d Iphone,Box2d Iphone,我的精灵怎么能跳回来呢?? 我正在iphone应用程序中使用box2d物理引擎。 我在使用冲动,但不能正常工作 有谁知道逻辑或代码比告诉我 -(void)jump { b2Vec2 pos=ballbody->GetPosition(); // float vel=ballbody->GetAngularVelocity(); double radian=atan2(pos.x+10, pos.y+10); float angle=CC_RADIANS_
-(void)jump
{
b2Vec2 pos=ballbody->GetPosition();
// float vel=ballbody->GetAngularVelocity();
double radian=atan2(pos.x+10, pos.y+10);
float angle=CC_RADIANS_TO_DEGREES(radian);
NSLog(@"Angle: %f",angle);
float impulseFactor = 1.0;
float force=ballbody->GetMass()*10;
//force/=6.0;
//b2Vec2 force=b2Vec2(0,50.0f);
// float apply=force*JUMP_IMPULSE*impulseFactor;
ballbody->ApplyLinearImpulse(b2Vec2(angle,force), ballbody->GetWorldCenter());
// [self applyLinearImpulse:b2Vec2(0,[self mass]*JUMP_IMPULSE*impulseFactor) point:[self worldCenter]];
}
谢谢
让我们看看你已经有了什么。。当我施力但无法到达跳跃位置时,返回到原始位置的精灵身体跳跃到底有什么“不起作用”。你的意思是它没有返回下来?HelloWorldLayer中使用的勾选/更新方法的可能重复最初会使精灵向下移动。你查过那个了吗?