List of usage examples for com.badlogic.gdx.graphics.g2d Animation getKeyFrame
public TextureRegion getKeyFrame(float stateTime)
From source file:com.codamasters.LNHelpers.AnimatedSprite.java
License:Apache License
/** creates a new {@link AnimatedSprite} with the given {@link Animation} * @param animation the {@link #animation} to use * @param keepSize the {@link #keepSize} to use */ public AnimatedSprite(Animation animation, boolean keepSize) { super(animation.getKeyFrame(0)); this.animation = animation; this.keepSize = keepSize; }
From source file:com.dagondev.drop.MainMenuScreen.java
License:Apache License
/** * handles rendering of main screen text and gifs, shoudn`t be called with {@link #drawCredits()} at same time *//*w w w. j a va2s.c o m*/ private void drawMainScreen() { int y = LINE_HEIGHT; int x = LINE_WIDTH_START; game.batch.begin(); for (String text : baseTextArray) { game.font.draw(game.batch, text, x, baseHeight - y); y += LINE_HEIGHT; } y += LINE_HEIGHT; int i = 0; int oldX = x; for (String rule : rulesTextArray) { if (animations.size() <= i) { game.batch.end(); return; } Animation animation = animations.get(i); game.font.draw(game.batch, rule, x, baseHeight - y); game.batch.draw(animation.getKeyFrame(stateTime), x, baseHeight - (y + LINE_HEIGHT + animation.getKeyFrame(0).getRegionHeight())); x += baseWidth / 3; i++; } //draw last animation with text x = oldX; Animation lastAnimation = animations.get(animations.size() - 1); y += LINE_HEIGHT; y += animations.get(0).getKeyFrame(0).getRegionHeight() * 1.5; game.font.draw(game.batch, "Use slopes to get in the air or on the higher ledges.", x, baseHeight - y); y += LINE_HEIGHT * 2; game.font.draw(game.batch, "Watch out for other obstacles, they can stomp on you as well as you on them!", x, baseHeight - y); y -= LINE_HEIGHT * 2; y -= animations.get(0).getKeyFrame(0).getRegionHeight() * 0.5; x = LINE_WIDTH_START + baseWidth - baseWidth / 3; game.batch.draw(lastAnimation.getKeyFrame(stateTime), x, baseHeight - (y + LINE_HEIGHT + lastAnimation.getKeyFrame(0).getRegionHeight())); game.batch.end(); }
From source file:com.github.fauu.helix.graphics.AnimatedDecal.java
License:Apache License
/** @see Decal#newDecal(TextureRegion) */ public static AnimatedDecal newAnimatedDecal(Animation animation) { return newAnimatedDecal(animation.getKeyFrame(0).getRegionWidth(), animation.getKeyFrame(0).getRegionHeight(), animation, DecalMaterial.NO_BLEND, DecalMaterial.NO_BLEND);/*from ww w. j a v a 2s . c o m*/ }
From source file:com.github.fauu.helix.graphics.AnimatedDecal.java
License:Apache License
/** @see Decal#newDecal(TextureRegion, boolean) */ public static AnimatedDecal newDecal(Animation animation, boolean hasTransparency) { return newAnimatedDecal(animation.getKeyFrame(0).getRegionWidth(), animation.getKeyFrame(0).getRegionHeight(), animation, hasTransparency ? GL20.GL_SRC_ALPHA : DecalMaterial.NO_BLEND, hasTransparency ? GL20.GL_ONE_MINUS_SRC_ALPHA : DecalMaterial.NO_BLEND); }
From source file:com.github.fauu.helix.graphics.AnimatedDecal.java
License:Apache License
/** @see Decal#newDecal(float, float, TextureRegion, int, int) */ public static AnimatedDecal newAnimatedDecal(float width, float height, Animation animation, int srcBlendFactor, int dstBlendFactor) { AnimatedDecal decal = new AnimatedDecal(); decal.setTextureRegion(animation.getKeyFrame(0)); decal.setBlending(srcBlendFactor, dstBlendFactor); decal.dimensions.x = width;//from w w w. j a va 2 s . c o m decal.dimensions.y = height; decal.setColor(1, 1, 1, 1); return decal; }
From source file:com.github.fauu.helix.graphics.AnimatedDecal.java
License:Apache License
@Override public void flipFrames(float startTime, float endTime, boolean flipX, boolean flipY, boolean set) { Animation animation = getAnimated(); for (float t = startTime; t < endTime; t += animation.getFrameDuration()) { TextureRegion frame = animation.getKeyFrame(t); frame.flip(flipX && (!set || !frame.isFlipX()), flipY && (!set || !frame.isFlipY())); }//from w w w.j ava 2 s . c o m }
From source file:com.github.skittishSloth.openSkies.battles.ships.PlayerShip.java
public TextureRegion getCurrentFrame(final float deltaTime) { final Animation curAnim; switch (bankState) { case NONE:// w ww. ja v a2 s .co m curAnim = baseAnimation; break; case LEFT: curAnim = bankLeft; break; case RIGHT: curAnim = bankRight; break; default: throw new UnsupportedOperationException("Unknown state: " + bankState); } if (movementTime > curAnim.getAnimationDuration()) { movementTime = curAnim.getAnimationDuration(); } return curAnim.getKeyFrame(movementTime); }
From source file:com.siondream.superjumper.systems.AnimationSystem.java
License:Apache License
@Override public void processEntity(Entity entity, float deltaTime) { long id = entity.getId(); TextureComponent tex = tm.get(entity); AnimationComponent anim = am.get(entity); StateComponent state = sm.get(entity); Animation animation = anim.animations.get(state.get()); if (animation != null) { tex.region = animation.getKeyFrame(state.time); }/*from w w w . j a va 2s . c om*/ state.time += deltaTime; }
From source file:com.sturdyhelmetgames.roomforchange.entity.Player.java
License:Apache License
@Override public void render(float delta, SpriteBatch batch) { super.render(delta, batch); Animation animation = null; if (blinkTick < BLINK_TICK_MAX) { if (isFalling()) { animation = Assets.playerFalling; batch.draw(animation.getKeyFrame(dyingAnimState), bounds.x - 0.1f, bounds.y, width, height + 0.4f); } else if (isDying() || isDead()) { animation = Assets.playerDying; batch.draw(animation.getKeyFrame(dyingAnimState), bounds.x - 0.1f, bounds.y, width, height + 0.4f); } else {/*from w ww. j av a2 s . c om*/ if (direction == Direction.UP) { animation = Assets.playerWalkBack; } else if (direction == Direction.DOWN) { animation = Assets.playerWalkFront; } else if (direction == Direction.RIGHT) { animation = Assets.playerWalkRight; } else if (direction == Direction.LEFT) { animation = Assets.playerWalkLeft; } if (isNotWalking()) { batch.draw(animation.getKeyFrame(0.25f), bounds.x - 0.1f, bounds.y, width, height + 0.4f); } else { batch.draw(animation.getKeyFrame(stateTime, true), bounds.x - 0.1f, bounds.y, width, height + 0.4f); } } } if (tryHitTime < 0.3) { float rotation = 0f; float x = this.bounds.x; float y = this.bounds.y; if (direction == Direction.UP) { rotation = 270f; y += .8f; } else if (direction == Direction.DOWN) { rotation = 90f; y -= .8f; } else if (direction == Direction.RIGHT) { rotation = 180f; x += .8f; } else if (direction == Direction.LEFT) { x -= .8f; } batch.draw(Assets.hitTarget.getKeyFrame(tryHitTime, true), x, y, 1f / 2, 1f / 2, 1f, 1f, 1f, 1f, rotation); } }
From source file:com.trgk.touchwave.utils.AnimatedImage.java
License:Open Source License
public AnimatedImage(Animation animation) { super(animation.getKeyFrame(0)); this.animation = animation; }