moved sprites into single spritesheet + agdtexdef

This commit is contained in:
2015-09-25 14:59:20 +02:00
parent 6bea6a5491
commit bf46dfd1b6
15 changed files with 44 additions and 13 deletions

View File

@@ -5,13 +5,18 @@ import com.badlogic.gdx.Input.Keys;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import de.samdev.absgdx.framework.AgdxGame;
import de.samdev.absgdx.framework.util.exceptions.AgdxTexDefException;
import de.samdev.cannonshooter.level.StandardLevel;
public class CannonGame extends AgdxGame {
@Override
public void onCreate() {
Textures.init();
try {
Textures.init();
} catch (AgdxTexDefException e) {
throw new RuntimeException(e);
}
setLayer(new StandardLevel(this));

View File

@@ -1,24 +1,35 @@
package de.samdev.cannonshooter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import de.samdev.absgdx.framework.util.TextureHelper;
import de.samdev.absgdx.framework.menu.texdef.AgdxTextureDefinitionLoader;
import de.samdev.absgdx.framework.util.exceptions.AgdtexdefLoadException;
import de.samdev.absgdx.framework.util.exceptions.AgdtexdefParsingException;
public final class Textures {
public static Texture texbackground;
public static Texture cannon_body;
public static AgdxTextureDefinitionLoader spritesheet;
//#########################################################################
public static TextureRegion level_background;
public static TextureRegion cannon_body;
public static TextureRegion[] cannon_barrel;
public static TextureRegion[] cannon_hearth;
public static Texture cannon_bullet;
public static TextureRegion cannon_bullet;
public static void init() {
texbackground = new Texture("level_background.png");
public static void init() throws AgdtexdefParsingException, AgdtexdefLoadException {
spritesheet = new AgdxTextureDefinitionLoader(Gdx.files.internal("spritesheet.agdtexdef"), new Texture("spritesheet.png"));
spritesheet.parse();
cannon_body = new Texture("cannon_body.png");
cannon_barrel = TextureHelper.load1DArray("cannon_barrel.png", 512, 256, 32);
cannon_hearth = TextureHelper.load1DArray("cannon_hearth.png", 256, 256, 64);
cannon_bullet = new Texture("cannon_bullet.png");
level_background = spritesheet.getSingleTexture("level_background");
cannon_body = spritesheet.getSingleTexture("cannon_body");
cannon_barrel = spritesheet.getTextureArray("cannon_barrel");
cannon_hearth = spritesheet.getTextureArray("cannon_hearth");
cannon_bullet = spritesheet.getSingleTexture("cannon_bullet");
}
}

View File

@@ -32,11 +32,11 @@ public class StandardLevel extends GameLayer {
initMap();
setTimeMultiplier(3);
//setTimeMultiplier(3);
}
private void initMap() {
addBackground(new RepeatingBackground(Textures.texbackground, 1/32f));
addBackground(new RepeatingBackground(Textures.level_background, 1/32f));
setMapScaleResolver(new ShowCompleteMapScaleResolver());
addEntity(new Cannon(6, 25, team_player));