- public class MyActor extends Actor{
- private Texture texture;
- private TextureRegion[] animationFrames;
- private AnimatedSprite animatedSprite;
- public AnimatedBox2DSprite animatedBox2DSprite;
- private Animation animation;
- private float stateTime = 0f;
- TextureRegion currentFrame;
- public MyActor(){
- texture = Assets.manager.get(Assets.gulubi, Texture.class);
- splitAnimation();
- animation = new Animation(1f/35f, animationFrames);
- setPosition(getX(),getY());
- setSize(getWidth(), getHeight());
- }
- public void splitAnimation(){
- TextureRegion[][] tmpFrames = TextureRegion.split(texture, 240, 314);
- animationFrames = new TextureRegion[4 * 5];
- int index = 0;
- for (int i = 0; i < 4; ++i){
- for (int j = 0; j < 5; ++j){
- animationFrames[index++] = tmpFrames[i][j];
- }
- }
- }
- @Override
- public void act(float delta) {
- stateTime += delta; // #15
- currentFrame = animation.getKeyFrame(stateTime, true); // #16
- }
- @Override
- public void draw(Batch batch, float parentAlpha) {
- // TODO Auto-generated method stub // #14
- batch.draw(currentFrame,getX(),getY());
- }
- }
- MoveToAction moveAction = new MoveToAction();
- moveAction.setPosition(300f, 0f);
- moveAction.setDuration(10f);
- MyActor ac = new MyActor();
- ac.addAction(moveAction);
- stage.addActor(ac);
SHARE
TWEET
Untitled
a guest
Oct 21st, 2015
99
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

