….Code Examples of com.badlogic.gdx.graphics.g2d.An Animation stores a list of {@link TextureRegion}s representing an animated sequence, e.g. for running or jumping. Each region of an Animation is called a key frame, multiple key frames make up the animation. @author mzechner
TextureRegion[] split = new TextureRegion(bobTexture).split(20, 20)[0];
TextureRegion[] mirror = new TextureRegion(bobTexture).split(20, 20)[0];
for (TextureRegion region : mirror)
region.flip(true, false);
spikes = split[5];
bobRight = new Animation(0.1f, split[0], split[1]);
bobLeft = new Animation(0.1f, mirror[0], mirror[1]);
bobJumpRight = new Animation(0.1f, split[2], split[3]);
bobJumpLeft = new Animation(0.1f, mirror[2], mirror[3]);
bobIdleRight = new Animation(0.5f, split[0], split[4]);
bobIdleLeft = new Animation(0.5f, mirror[0], mirror[4]);
bobDead = new Animation(0.2f, split[0]);
split = new TextureRegion(bobTexture).split(20, 20)[1];
cube = split[0];
cubeFixed = new Animation(1, split[1], split[2], split[3], split[4], split[5]);
split = new TextureRegion(bobTexture).split(20, 20)[2];
cubeControlled = split[0];
spawn = new Animation(0.1f, split[4], split[3], split[2], split[1]);
dying = new Animation(0.1f, split[1], split[2], split[3], split[4]);
dispenser = split[5];
split = new TextureRegion(bobTexture).split(20, 20)[3];
rocket = new Animation(0.1f, split[0], split[1], split[2], split[3]);
rocketPad = split[4];
split = new TextureRegion(bobTexture).split(20, 20)[4];
rocketExplosion = new Animation(0.1f, split[0], split[1], split[2], split[3], split[4], split[4]);
split = new TextureRegion(bobTexture).split(20, 20)[5];
endDoor = split[2];
movingSpikes = split[0];
laser = split[1];
}
TextureRegion[][] regions = TextureRegion.split(tex, 32, 48);
TextureRegion[] downWalkReg = regions[0];
TextureRegion[] leftWalkReg = regions[1];
TextureRegion[] rightWalkReg = regions[2];
TextureRegion[] upWalkReg = regions[3];
downWalk = new Animation(ANIMATION_SPEED, downWalkReg);
leftWalk = new Animation(ANIMATION_SPEED, leftWalkReg);
rightWalk = new Animation(ANIMATION_SPEED, rightWalkReg);
upWalk = new Animation(ANIMATION_SPEED, upWalkReg);
currentWalk = leftWalk;
currentFrameTime = 0.0f;
spriteBatch = new SpriteBatch();
for (int i = 0; i < rightWalkFrames.length; i++) {
TextureRegion frame = new TextureRegion(leftWalkFrames[i]);
frame.flip(true, false);
rightWalkFrames[i] = frame;
}
leftWalk = new Animation(0.25f, leftWalkFrames);
rightWalk = new Animation(0.25f, rightWalkFrames);
cavemen = new Caveman[100];
for (int i = 0; i < 100; i++) { cavemen[i] = new Caveman((float)Math.random() * Gdx.graphics.getWidth(), (float)Math.random() * Gdx.graphics.getHeight(), Math.random() > 0.5 ? true : false);
public void create () {
batch = new SpriteBatch();
atlas = new TextureAtlas(Gdx.files.internal(“data/pack”));
jumpAtlas = new TextureAtlas(Gdx.files.internal(“data/jump.txt”));
jumpAnimation = new Animation(0.25f, jumpAtlas.findRegions(“ALIEN_JUMP_”));
badlogic = atlas.createSprite(“badlogicslice”);
badlogic.setPosition(50, 50);
badlogicSmall = atlas.createSprite(“badlogicsmall”);
Related Class of com.badlogic.gdx.graphics.g2d.Animation
Copyright © 2011 www.androidadb.com. All rights reserved. All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc. Contact . See also:
|
|
|