您好,我需要拍摄我的雪碧图..我使用以下代码
-(void)shooter
{
LHSprite* laserSprite = [lh newPhysicalSpriteWithUniqueName:@"ball_1" ];
b2Body* laserBody = [laserSprite body];
[self addChild:laserSprite z:10];
NSAssert(laserSprite!=nil, @"Couldn't find devil1");
[laserSprite transformPosition:_hero.position];
b2Vec2 ballvel = laserBody->GetLinearVelocity();
ballvel.x = 16;
laserBody->SetLinearVelocity(ballvel);
}
上面的代码拍摄了右侧的sprite,
但如果我更改了side..even,我需要向左射击。x= 16;改为balvel.x= -16;它仍然朝右射击。side..please帮助
我是新来box2d的,所以请温文点:)
发布于 2012-07-12 22:41:07
语法如下:
//1.首先计算移动角度。//2.计算命中功率(强度)
b2Vec2 force;
force.x = cos(angle * M_PI / 180) * power;
force.y = sin(angle * M_PI / 180) * power;
laserBody->ApplyLinearImpulse(force, laserBody->GetPosition()); //or SetLinearVelocity
发布于 2012-07-17 13:02:21
实际上,我的子弹头雪碧图不是issensor...so,它击中了英雄雪碧图,然后又回到了正确的side..my bad ..embarassing :D
https://stackoverflow.com/questions/11453872
复制相似问题