我有一个问题,玩家释放一个强力攻击,这个强力攻击必须移动到某个位置然后分离,我怎么能做到这一点?我尝试使用 setvelocity 但效果不佳...请帮助!
好的,这是我按下按钮时调用的攻击方法:
公共无效powerattack(){
float startBulletX = player.getX() + 30; //Get X position of character body
float startBulletY = player.getY(); //Get Y position of character body
final Sprite bullet = new Sprite(startBulletX, startBulletY,
resourcesManager.special_attack, vbom); //The special attack sprite
final FixtureDef bulletFixtureDef1 = PhysicsFactory.createFixtureDef(0,
0, 0, false, CATEGORYBIT_KNIFE, MASKBIT_KNIFE, (short) 0);
this.mBulletBody = PhysicsFactory.createBoxBody(physicsWorld, bullet,
BodyType.DynamicBody, bulletFixtureDef1);
mBulletBody.setLinearVelocity(20f,0);
this.physicsWorld.registerPhysicsConnector(new PhysicsConnector(bullet,
this.mBulletBody, true, false));
this.attachChild(bullet);
}
当我运行此代码时,特殊攻击体移出屏幕......我想将强力攻击限制在某个位置,即距离角色几远。