Java Code Examples for com.badlogic.gdx.graphics.g2d.Animation#setPlayMode()

The following examples show how to use com.badlogic.gdx.graphics.g2d.Animation#setPlayMode() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnimationDrawable.java    From TerraLegion with MIT License 6 votes vote down vote up
public AnimationDrawable(SpriteSheet sheet) {
    final int startX = 0;
    final int startY = 0;
    final int frames = 3;

    Array<TextureRegion> tempSpritesUp = AnimationDrawable.grabSprites(sheet, startX, startY, frames);
    Array<TextureRegion> tempSpritesDown = AnimationDrawable.grabSprites(sheet, startX, startY + 2, frames);
    Array<TextureRegion> tempSpritesLeft = AnimationDrawable.grabSprites(sheet, startX, startY + 1, frames, true);
    Array<TextureRegion> tempSpritesRight = AnimationDrawable.grabSprites(sheet, startX, startY + 1, frames);

    AnimationDrawable.addMiddleReversed(tempSpritesUp, false);
    AnimationDrawable.addMiddleReversed(tempSpritesDown, false);
    AnimationDrawable.addMiddleReversed(tempSpritesLeft, false);
    AnimationDrawable.addMiddleReversed(tempSpritesRight, false);

    animations.put(Type.WALK_DOWN, new Animation(1f / (frames * 1.5f), tempSpritesDown));
    animations.put(Type.WALK_UP, new Animation(1f / (frames * 1.5f), tempSpritesUp));
    animations.put(Type.WALK_LEFT, new Animation(1f / (frames * 1.5f), tempSpritesLeft));
    animations.put(Type.WALK_RIGHT, new Animation(1f / (frames * 1.5f), tempSpritesRight));

    for(Animation animation : animations.values()) {
        animation.setPlayMode(Animation.PlayMode.LOOP);
    }

    setAnimationByType(Type.WALK_DOWN); // default animation
}
 
Example 2
Source File: ClientFrog.java    From killingspree with MIT License 5 votes vote down vote up
public ClientFrog(short id, float x, float y, WorldRenderer renderer) {
    super(id, x, y, renderer);
    markForDispose = false;
    Texture texture = AssetLoader.instance.getTexture("sprites/frog.png");
    sprite = new Sprite(texture);
    walk = new Animation(0.25f, TextureRegion.split(texture,
            texture.getWidth()/2, texture.getHeight())[0]);
    walk.setPlayMode(Animation.PlayMode.LOOP);
    sprite.setSize(ServerFrog.WIDTH + 5f, ServerFrog.HEIGHT + 5f);
}
 
Example 3
Source File: ClientPlayer.java    From killingspree with MIT License 5 votes vote down vote up
public ClientPlayer(short id, float x, float y, WorldRenderer renderer) {
    super(id, x, y, renderer);
    markForDispose = false;
    Texture texture = AssetLoader.instance.getTexture("sprites/player.png");
    sprite = new Sprite(texture);
    gunSprite = new Sprite(AssetLoader.instance.getTexture("sprites/arrow.png"));
    gunSprite.setOrigin(gunSprite.getWidth()/2, gunSprite.getHeight()/2);
    walk = new Animation(0.05f, TextureRegion.split(texture,
            texture.getWidth()/10, texture.getHeight())[0]);
    walk.setPlayMode(Animation.PlayMode.LOOP);
    walkDuration = 0;
    gunSprite.setSize(40, 6);
    gunSprite.setOrigin(gunSprite.getWidth()/2, gunSprite.getHeight()/2);
    gunSprite.setAlpha(0.7f);
}
 
Example 4
Source File: ClientTestPlayer.java    From killingspree with MIT License 5 votes vote down vote up
public ClientTestPlayer(short id, float x, float y, WorldRenderer renderer) {
    super(id, x, y, renderer);
    markForDispose = false;
    Texture texture = AssetLoader.instance.getTexture("sprites/explosion.png");
    sprite = new Sprite(texture);
    
    walk = new Animation(0.05f, TextureRegion.split(texture,
            texture.getWidth()/7, texture.getHeight())[0]);
    walk.setPlayMode(Animation.PlayMode.LOOP);
    
    walkDuration = 0;
}
 
Example 5
Source File: ClientBlob.java    From killingspree with MIT License 5 votes vote down vote up
public ClientBlob(short id, float x, float y, WorldRenderer renderer) {
    super(id, x, y, renderer);
    markForDispose = false;
    Texture texture = AssetLoader.instance.getTexture("sprites/blob.png");
    sprite = new Sprite(texture);
    walk = new Animation(0.25f, TextureRegion.split(texture,
            texture.getWidth()/2, texture.getHeight())[0]);
    walk.setPlayMode(Animation.PlayMode.LOOP);
    sprite.setSize(ServerBlob.WIDTH + 5f, ServerBlob.HEIGHT);
    deadTimer = 2f;
}
 
Example 6
Source File: ClientFly.java    From killingspree with MIT License 5 votes vote down vote up
public ClientFly(short id, float x, float y, WorldRenderer renderer) {
    super(id, x, y, renderer);
    markForDispose = false;
    Texture texture = AssetLoader.instance.getTexture("sprites/fly.png");
    sprite = new Sprite(texture);
    walk = new Animation(0.25f, TextureRegion.split(texture,
            texture.getWidth()/2, texture.getHeight())[0]);
    walk.setPlayMode(Animation.PlayMode.LOOP);
    sprite.setSize(ServerBlob.WIDTH + 5f, ServerFly.HEIGHT);
}
 
Example 7
Source File: Assets.java    From ashley-superjumper with Apache License 2.0 4 votes vote down vote up
public static void load () {
	background = loadTexture("data/background.png");
	backgroundRegion = new TextureRegion(background, 0, 0, 320, 480);

	items = loadTexture("data/items.png");
	mainMenu = new TextureRegion(items, 0, 224, 300, 110);
	pauseMenu = new TextureRegion(items, 224, 128, 192, 96);
	ready = new TextureRegion(items, 320, 224, 192, 32);
	gameOver = new TextureRegion(items, 352, 256, 160, 96);
	highScoresRegion = new TextureRegion(Assets.items, 0, 257, 300, 110 / 3);
	logo = new TextureRegion(items, 0, 352, 274, 142);
	soundOff = new TextureRegion(items, 0, 0, 64, 64);
	soundOn = new TextureRegion(items, 64, 0, 64, 64);
	arrow = new TextureRegion(items, 0, 64, 64, 64);
	pause = new TextureRegion(items, 64, 64, 64, 64);

	spring = new TextureRegion(items, 128, 0, 32, 32);
	castle = new TextureRegion(items, 128, 64, 64, 64);
	coinAnim = new Animation(0.2f, new TextureRegion(items, 128, 32, 32, 32), new TextureRegion(items, 160, 32, 32, 32),
		new TextureRegion(items, 192, 32, 32, 32), new TextureRegion(items, 160, 32, 32, 32));
	bobJump = new Animation(0.2f, new TextureRegion(items, 0, 128, 32, 32), new TextureRegion(items, 32, 128, 32, 32));
	bobFall = new Animation(0.2f, new TextureRegion(items, 64, 128, 32, 32), new TextureRegion(items, 96, 128, 32, 32));
	bobHit = new Animation(0.2f, new TextureRegion(items, 128, 128, 32, 32));
	squirrelFly = new Animation(0.2f, new TextureRegion(items, 0, 160, 32, 32), new TextureRegion(items, 32, 160, 32, 32));
	platform = new Animation(0.2f, new TextureRegion(items, 64, 160, 64, 16));
	breakingPlatform = new Animation(0.2f, new TextureRegion(items, 64, 160, 64, 16), new TextureRegion(items, 64, 176, 64, 16),
		new TextureRegion(items, 64, 192, 64, 16), new TextureRegion(items, 64, 208, 64, 16));

	font = new BitmapFont(Gdx.files.internal("data/font.fnt"), Gdx.files.internal("data/font.png"), false);

	music = Gdx.audio.newMusic(Gdx.files.internal("data/music.mp3"));
	music.setLooping(true);
	music.setVolume(0.5f);
	if (Settings.soundEnabled) music.play();
	jumpSound = Gdx.audio.newSound(Gdx.files.internal("data/jump.wav"));
	highJumpSound = Gdx.audio.newSound(Gdx.files.internal("data/highjump.wav"));
	hitSound = Gdx.audio.newSound(Gdx.files.internal("data/hit.wav"));
	coinSound = Gdx.audio.newSound(Gdx.files.internal("data/coin.wav"));
	clickSound = Gdx.audio.newSound(Gdx.files.internal("data/click.wav"));
	
	coinAnim.setPlayMode(PlayMode.LOOP);
	bobJump.setPlayMode(PlayMode.LOOP);
	bobFall.setPlayMode(PlayMode.LOOP);
	bobHit.setPlayMode(PlayMode.LOOP);
	squirrelFly.setPlayMode(PlayMode.LOOP);
	platform.setPlayMode(PlayMode.LOOP);
}