如何将动画应用到 box2d 主体?
我知道如何使用TextureRegions 创建动画并应用于非box2d 游戏中的对象。
但在 libgdx 的 box2d 中,我不知道该怎么做。在CocosD2中,Sprite对象中有runaction方法。但libgdx中没有。我将不胜感激任何提示或线索。
I know how I can create animation with TextureRegions and apply to an object in non-box2d game.
But in box2d of libgdx, I am not sure how to. In CocosD2, there is runaction method in Sprite object. But there isn't in libgdx. I would appreciate any hint or clue.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
别把事情搞混了。 Box2D是一个物理引擎,而你谈论的是与物理完全无关的动画。
Cocos2D 和 libgdx 都使用 Box2D 来管理物理,但它们管理动画的方式与之无关。
我对Cocos2D很实用,但从未使用过libgdx,根据Javadoc(找到这里)你有一个类
Actor
被描述为我想这就是您正在寻找的。它将从纹理图集中绘制自身,您将能够动态修改其属性(检查包 com.badlogic.gdx.scenes.scene2d.actions )。如果你搜索的话,并不难找到。
Don't mix up things. Box2D is a physics engine while you are talking about animations which are absolutely unrelated to physics.
Both Cocos2D and libgdx use Box2D to manage physics but the way they manage animations is independent from that.
I'm practical of Cocos2D but never used libgdx, according to Javadoc (found here) you have a class
Actor
that is described asI guess this is what you are looking for. It will draw itself from a texture atlas and you will be able to dinamically modify its attributes (check package
com.badlogic.gdx.scenes.scene2d.actions
). Not that hard to find if you search for it.