List of usage examples for com.badlogic.gdx.graphics.g2d Animation Animation
public Animation(float frameDuration, Array<? extends TextureRegion> keyFrames, PlayMode playMode)
From source file:ca.hiphiparray.amazingmaze.Assets.java
License:Open Source License
/** Helper method to setup the mouse animation. */ private void setupMouseAnimation() { TextureAtlas atlas = manager.get(Assets.GAME_ATLAS_LOCATION, TextureAtlas.class); // Reference used for readability. mouseUp = new Animation<TextureRegion>(MOUSE_FRAME_DURATION, atlas.findRegions(Assets.MOUSE + Assets.UP_MODIFIER), PlayMode.LOOP_PINGPONG); mouseDown = new Animation<TextureRegion>(MOUSE_FRAME_DURATION, atlas.findRegions(Assets.MOUSE + Assets.DOWN_MODIFIER), PlayMode.LOOP_PINGPONG); mouseLeft = new Animation<TextureRegion>(MOUSE_FRAME_DURATION, atlas.findRegions(Assets.MOUSE + Assets.LEFT_MODIFIER), PlayMode.LOOP_PINGPONG); mouseRight = new Animation<TextureRegion>(MOUSE_FRAME_DURATION, atlas.findRegions(Assets.MOUSE + Assets.RIGHT_MODIFIER), PlayMode.LOOP_PINGPONG); assert mouseUp .getKeyFrames().length == MOUSE_FRAME_COUNT : "mouseUp frame count does not match MOUSE_FRAME_COUNT."; assert mouseDown .getKeyFrames().length == MOUSE_FRAME_COUNT : "mouseDown frame count does not match MOUSE_FRAME_COUNT."; assert mouseLeft .getKeyFrames().length == MOUSE_FRAME_COUNT : "mouseLeft frame count does not match MOUSE_FRAME_COUNT."; assert mouseRight .getKeyFrames().length == MOUSE_FRAME_COUNT : "mouseRight frame count does not match MOUSE_FRAME_COUNT."; }
From source file:com.badlydrawngames.veryangryrobots.Assets.java
License:Apache License
private static void createAnimations() { playerWalkingRightAnimation = new Animation(PLAYER_FRAME_DURATION, Assets.playerWalkingRight1, Assets.playerWalkingRight2); playerWalkingLeftAnimation = new Animation(PLAYER_FRAME_DURATION, Assets.playerWalkingLeft1, Assets.playerWalkingLeft2);/* w w w. java2 s . c o m*/ robotWalkingLeftAnimation = new Animation(ROBOT_FRAME_DURATION, robotLeft1, robotLeft2, robotLeft3, robotLeft4, robotLeft3, robotLeft2); robotWalkingRightAnimation = new Animation(ROBOT_FRAME_DURATION, robotRight1, robotRight2, robotRight3, robotRight4, robotRight3, robotRight2); robotScanningAnimation = new Animation(ROBOT_FRAME_DURATION, robotScan1, robotScan2, robotScan3, robotScan4, robotScan3, robotScan2); nemesisAnimation = new Animation(CAPTAIN_FRAME_DURATION, nemesis1, nemesis2); }
From source file:com.cyphercove.dayinspace.gameplayscene.rendering.Border.java
License:Apache License
public Border(Assets assets) { this.assets = assets; left = assets.mainAtlas.findRegion("borderLeft"); right = assets.mainAtlas.findRegion("borderRight"); top = assets.mainAtlas.findRegion("borderTop"); bottom = assets.mainAtlas.findRegion("borderBottom"); entryDoor = assets.mainAtlas.findRegion("entryDoor"); exitDoorBehindTile = assets.mainAtlas.findRegion("doorBehindTile"); exitDoor = new Animation(0.05f, assets.mainAtlas.findRegions("exitDoor"), Animation.PlayMode.NORMAL); white = assets.white;//from w w w. j a v a 2s.c o m beams = new Array<>(10); for (int i = 0; i < 5; i++) { for (int j = 0; j < 2; j++) { GlowSpot glowSpot = new GlowSpot(); glowSpot.x = 33 + 44 * i; glowSpot.y = -4.5f + 141 * j; glowSpot.spotlight = true; glowSpot.width = 60; glowSpot.height = 100; glowSpot.angle = 90 + 180 * j; glowSpot.glowColor = BEAM_GLOW; glowSpot.lightColor = BEAM_LIGHT; glowSpot.glowSizeFraction = 0.5f; beams.add(glowSpot); } } exitDoorGlow = new GlowSpot(); exitDoorGlow.x = 15; exitDoorGlow.y = 20; exitDoorGlow.width = 70; exitDoorGlow.height = 70; exitDoorGlow.glowSizeFraction = 0.2f; entryDoorGlow = new GlowSpot(); entryDoorGlow.x = 7; entryDoorGlow.y = 20; entryDoorGlow.width = 70; entryDoorGlow.height = 70; entryDoorGlow.glowSizeFraction = 0.2f; entryDoorGlow.lightColor = DOOR_LIGHT_ENTRY; entryDoorGlow.glowColor = DOOR_GLOW_ENTRY; }
From source file:com.maplescot.loggerbill.ui.SplashScreen.java
License:Creative Commons License
@Override public void show() { Gdx.app.debug(TAG, "STARTING"); camera = new OrthographicCamera(); camera.position.set(0, 0, 0);/*from ww w .j av a 2s. c o m*/ camera.setToOrtho(true, VIEWPORT_GUI_WIDTH / 2, getViewportHeight() / 2); camera.update(); batch = new SpriteBatch(); batch.enableBlending(); atlas = new TextureAtlas(Constants.TEXTURE_ATLAS_SPLASH); Array<TextureAtlas.AtlasRegion> morphRegions = atlas.findRegions("morph"); for (TextureRegion r : morphRegions) r.flip(false, true); morphAnimation = new Animation(10.0f / 60.0f, morphRegions, Animation.PlayMode.NORMAL); nameRegion = atlas.findRegion("name2"); nameRegion.flip(false, true); Gdx.app.debug(TAG, "Queuing Asset Load"); Assets.getInstance().load(); // Start loading... Gdx.app.debug(TAG, "Asset Load queued"); }
From source file:com.mekomidev.gdxengine.utils.loaders.GifDecoder.java
License:Open Source License
public Animation<TextureRegion> getAnimation(PlayMode playType) { int nrFrames = getFrameCount(); // if(nrFrames > 100) // {/*from w w w .j ava 2 s . co m*/ // nrFrames=100; // } advance(); Pixmap frame = getNextFrame(); int width = frame.getWidth(); int height = frame.getHeight(); int vzones = (int) Math.sqrt((double) nrFrames); int hzones = vzones; while (vzones * hzones < nrFrames) vzones++; int v, h; Pixmap target = new Pixmap(width * hzones, height * vzones, Pixmap.Format.RGBA8888); int frameCountCurrent = 0; for (h = 0; h < hzones; h++) { for (v = 0; v < vzones; v++) { if (frameCountCurrent < nrFrames) { frameCountCurrent++; advance(); frame = getNextFrame(); target.drawPixmap(frame, h * width, v * height); int pixelSize = (int) (frame.getWidth() * 0.025f); target.setColor(Color.BLACK); int xPos, yPos; xPos = h * width; yPos = v * height; // target.fillRectangle(xPos, yPos, frame.getWidth(), pixelSize); // target.fillRectangle(xPos + frame.getWidth()-pixelSize, yPos, pixelSize, frame.getHeight()); // target.fillRectangle(xPos, yPos + frame.getHeight()-pixelSize, frame.getWidth(), pixelSize); // target.fillRectangle(xPos, yPos,pixelSize, frame.getHeight()); } } } Texture texture = new Texture(target); //target.dispose(); target = null; Array<TextureRegion> texReg = new Array<TextureRegion>(); TextureRegion tr = new TextureRegion(texture); for (h = 0; h < hzones; h++) { for (v = 0; v < vzones; v++) { int frameID = v + h * vzones; if (frameID < nrFrames) { tr = new TextureRegion(texture, h * width, v * height, width, height); texReg.add(tr); } } } float frameDuration = (float) getDelay(0); frameDuration /= 500; // convert milliseconds into seconds Animation<TextureRegion> result = new Animation<>(frameDuration, texReg, playType); texReg.clear(); frames.clear(); prefix = null; suffix = null; pixelStack = null; mainPixels = null; mainScratch = null; copyScratch = null; return result; //return animation object }
From source file:com.mygdx.game.GameUtils.java
public static Animation parseSpriteSheet(String fileName, int frameCols, int frameRows, float frameDuration, PlayMode mode) {/*from ww w . j a v a 2 s . c o m*/ Texture t = new Texture(Gdx.files.internal(fileName), true); t.setFilter(TextureFilter.Linear, TextureFilter.Linear); int frameWidth = t.getWidth() / frameCols; int frameHeight = t.getHeight() / frameRows; TextureRegion[][] temp = TextureRegion.split(t, frameWidth, frameHeight); TextureRegion[] frames = new TextureRegion[frameCols * frameRows]; int index = 0; for (int i = 0; i < frameRows; i++) { for (int j = 0; j < frameCols; j++) { frames[index] = temp[i][j]; index++; } } Array<TextureRegion> framesArray = new Array<TextureRegion>(frames); return new Animation(frameDuration, framesArray, mode); }
From source file:com.mygdx.game.GameUtils.java
public static Animation parseImageFiles(String fileNamePrefix, String fileNameSuffix, int frameCount, float frameDuration, PlayMode mode) { TextureRegion[] frames = new TextureRegion[frameCount]; for (int n = 0; n < frameCount; n++) { String fileName = fileNamePrefix + n + fileNameSuffix; Texture tex = new Texture(Gdx.files.internal(fileName)); tex.setFilter(TextureFilter.Linear, TextureFilter.Linear); frames[n] = new TextureRegion(tex); }//w ww. j av a 2s . c o m Array<TextureRegion> framesArray = new Array<TextureRegion>(frames); return new Animation(frameDuration, framesArray, mode); }
From source file:com.mygdx.game.Sprites.Enemies.AirEnemy.AirEnemy.java
public AirEnemy(PlayScreen screen, float x, float y) { super(screen, x, y); frames = new Array<TextureRegion>(); for (int i = 0; i <= 2; i++) { frame = new TextureRegion(screen.getAtlas().findRegion("AirEnemy"), 55 * i, 0, 55, 69); frames.add(frame);/* w w w . j ava 2 s. c o m*/ } moveBall = new Animation(0.2f, frames, PlayMode.LOOP_PINGPONG); for (int i = 3; i <= 6; i++) { frame = new TextureRegion(screen.getAtlas().findRegion("AirEnemy"), 55 * i, 0, 55, 69); frames.add(frame); } dropBall = new Animation(0.1f, frames); frames.clear(); for (int i = 7; i <= 11; i++) { frame = new TextureRegion(screen.getAtlas().findRegion("AirEnemy"), 55 * i, 0, 55, 69); frames.add(frame); } moveAlone = new Animation(0.1f, frames, PlayMode.LOOP); frames.clear(); TimeState = 0; lives = 2; drop = false; this.setBounds(x, y, 27 / AdventureGame.PPM, 34 / AdventureGame.PPM); }
From source file:com.mygdx.game.Sprites.Enemies.AirEnemy.AirEnemyBall.java
public AirEnemyBall(PlayScreen screen, float x, float y) { super(screen, x, y); frames = new Array<TextureRegion>(); for (int i = 0; i <= 3; i++) { frame = new TextureRegion(screen.getAtlas().findRegion("BallAirEnemy"), (i * 40), 0, 40, 41); frames.add(frame);/*ww w .j a v a2 s.co m*/ } animation = new Animation(0.1f, frames, PlayMode.LOOP); setBounds(x, y, 20 / AdventureGame.PPM, 20 / AdventureGame.PPM); b2body.setActive(true); TimeState = 0; }
From source file:com.mygdx.game.Sprites.Enemies.Cannon.BulletCannon.java
public BulletCannon(PlayScreen screen, float x, float y, boolean fireLeft) { super(screen, x, y); frames = new Array<TextureRegion>(); for (int i = 0; i <= 3; i++) { frame = new TextureRegion(screen.getAtlas().findRegion("CannonBullet"), (i * 15), 0, 15, 9); frames.add(frame);// www . ja va 2 s . c o m } animation = new Animation(0.1f, frames, PlayMode.LOOP); frames.clear(); setBounds(x, y, 15 / AdventureGame.PPM, 9 / AdventureGame.PPM); this.fireLeft = fireLeft; if (fireLeft) { b2body.setLinearVelocity(new Vector2(-2, 0)); } else { b2body.setLinearVelocity(new Vector2(2, 0)); } StateTimer = 0; }