AndEngine 中的投影

发布于 2024-12-17 05:08:00 字数 137 浏览 2 评论 0原文

我想以抛射运动移动 AndEngine 中的 Sprite

任何人都可以用一段代码帮助我解决这个问题吗?不幸的是,我没有看到有关 AndEngine 中投影的示例。

I want to move my Sprite in AndEngine in a projectile motion.

Can any one help me in this matter with a piece of code? Unfortunately I didn't see an example about projections in AndEngine.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

圈圈圆圆圈圈 2024-12-24 05:08:00

我怀疑您正在寻找的是 UpdateModifier。

您希望您的精灵如何移动?您是否希望它找到到达目的地的路径,或者您只是想在屏幕上保留某些内容?您使用相机吗?所有这些都将决定您应该如何准确地让您的精灵移动。

这是有关 UpdateModifiers 的链接:

更新处理程序 - 使用他们的力量!

这是您正在寻找的吗?

What you're looking for is the UpdateModifier, I suspect.

How do you want your Sprite to move? Do you want it to find a path to the destination or are you just trying to keep something on the screen? Are you using a Camera? All of that will determine how exactly you should approach getting your Sprite to move.

This is a link for the tut about UpdateModifiers:

Update Handlers - Using their Power!

Is that what you were looking for?

情徒 2024-12-24 05:08:00

对于弹丸移动,您可以使用物理处理程序,然后您可以操纵加速度和速度,使其像弹丸一样移动......

projectile=new Sprite(X,Y, ProjectileTextureRegion);
physprojectile = new PhysicsHandler(projectile);
projectile.registerUpdateHandler(physprojectile);
physprojectile.setVelocityX(Xvelocity);
physprojectile.setVelocityY(Yvelocity);
pyhsprojectile.setAcceleration(Accelration)  //negative acceleration

for a projectile move , you can use the physicshandler and then you can manipulate the acceleration and velocity to make it move like projectile...

projectile=new Sprite(X,Y, ProjectileTextureRegion);
physprojectile = new PhysicsHandler(projectile);
projectile.registerUpdateHandler(physprojectile);
physprojectile.setVelocityX(Xvelocity);
physprojectile.setVelocityY(Yvelocity);
pyhsprojectile.setAcceleration(Accelration)  //negative acceleration
浅唱ヾ落雨殇 2024-12-24 05:08:00

基本上,您可以在精灵(或任何实体)上使用registerEntityMofidier: Andengine EntityModifierExample

示例:

sprite.registerEntityModifier(new MoveModifier(TIME_IN_SECOND, fromX, toX, fromY, toY));

Basically you can use registerEntityMofidier on a sprite (or on any Entity): Andengine EntityModifierExample

Example:

sprite.registerEntityModifier(new MoveModifier(TIME_IN_SECOND, fromX, toX, fromY, toY));
西瓜 2024-12-24 05:08:00
stakesprite.registerEntityModifier(new RotationModifier(0.1f, 0.0f,(float) ((360.0f/Math.PI)*Math.atan(velY/velX))));
            stake=PhysicsFactory.createCircleBody(this.mPhysicsWorld, stakesprite, BodyType.DynamicBody, FIXTURE_DEF);
            //stake = PhysicsFactory.createBoxBody(this.mPhysicsWorld, stakesprite, BodyType.DynamicBody, FIXTURE_DEF);
            stake.setBullet(true);
            stake.setLinearVelocity(new Vector2(velX, velY));
            stake.setSleepingAllowed(true);
            mScene.attachChild(stakesprite);
stakesprite.registerEntityModifier(new RotationModifier(0.1f, 0.0f,(float) ((360.0f/Math.PI)*Math.atan(velY/velX))));
            stake=PhysicsFactory.createCircleBody(this.mPhysicsWorld, stakesprite, BodyType.DynamicBody, FIXTURE_DEF);
            //stake = PhysicsFactory.createBoxBody(this.mPhysicsWorld, stakesprite, BodyType.DynamicBody, FIXTURE_DEF);
            stake.setBullet(true);
            stake.setLinearVelocity(new Vector2(velX, velY));
            stake.setSleepingAllowed(true);
            mScene.attachChild(stakesprite);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文