Skip to content
Snippets Groups Projects
Commit 99249ca0 authored by Matyáš Latner's avatar Matyáš Latner
Browse files

#7 In the Darkness game player animation use new TablexiaAtlasManager API

parent 2a013baa
No related branches found
No related tags found
No related merge requests found
......@@ -19,12 +19,9 @@
package cz.nic.tablexia.game.games.in_the_darkness.creature;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Interpolation;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.Array;
import cz.nic.tablexia.game.games.in_the_darkness.InTheDarknessGame;
import cz.nic.tablexia.game.games.in_the_darkness.assets.InTheDarknessAssets;
......@@ -292,12 +289,8 @@ public class Player extends Group {
return mapStartPositionY + ((InTheDarknessGame.MAP_Y_SIZE - tileMapPosition.getPositionY() - 1) * InTheDarknessGame.TILE_SIZE) + (InTheDarknessGame.TILE_SIZE / 2) - (actualPlayerAnimatedImage.getHeight() / 2);
}
private AnimatedImage createPlayerAnimatedImage(int width, int height, String spriteName, int framesCount, InTheDarknessGame inTheDarknessGame) {
Array<TextureRegion> frames = new Array<TextureRegion>();
for (int i = 0; i < framesCount; i++) {
frames.add(inTheDarknessGame.getScreenTextureRegion(spriteName, i));
}
AnimatedImage playerAnimatedImage = new AnimatedImage(new Animation(PLAYER_ANIMATION_FRAME_DURATION, frames), false);
private AnimatedImage createPlayerAnimatedImage(int width, int height, String animationName, int framesCount, InTheDarknessGame inTheDarknessGame) {
AnimatedImage playerAnimatedImage = new AnimatedImage(inTheDarknessGame.getScreenAnimation(animationName, framesCount, PLAYER_ANIMATION_FRAME_DURATION), false);
playerAnimatedImage.setSize(width, height);
playerAnimatedImage.setVisible(false);
playerAnimatedImage.setOrigin(Align.center);
......
......@@ -640,6 +640,14 @@ public abstract class AbstractTablexiaScreen<T> extends ScreenAdapter {
return preloaderAtlasManager.getAnimationFromAtlas(preparePreloaderAtlasPath(), regionName, framesCount, frameDuration, useBleedingFix);
}
public Animation getAnimationForAtlas(String atlasName, String regionName, int framesCount, float frameDuration) {
return atlasManager.getAnimationFromAtlas(atlasName, regionName, framesCount, frameDuration, false);
}
public Animation getScreenAnimation(String regionName, int framesCount, float frameDuration) {
return getAnimationForAtlas(screenAtlasPath, regionName, framesCount, frameDuration);
}
public TextureRegion getTextureRegionForAtlas(String atlasName, String regionName) {
return atlasManager.getTextureRegionFromAtlas(atlasName, regionName, null);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment