سؤال

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.

هل كانت مفيدة؟

المحلول

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 as

An Actor is part of a Stage or a Group within a Stage. It has a position, a rectangular size given as width and height, a rotation angle, a scale in x and y and an origin relative to the position which is used for rotation and scaling.

I 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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top