moved sprites into single spritesheet + agdtexdef
Before Width: | Height: | Size: 67 KiB |
Before Width: | Height: | Size: 45 KiB |
Before Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 218 B |
15
android/assets/spritesheet.agdtexdef
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<texturedefinitions>
|
||||
|
||||
<texture identifier="cannon_body" coordinates=" 0,2304 256,256" />
|
||||
<texture identifier="cannon_bullet" coordinates=" 256,2304 48, 48" />
|
||||
<texture identifier="level_background" coordinates=" 512,2304 64, 64" />
|
||||
|
||||
<flatten_array identifier="cannon_hearth" >
|
||||
<array_2d coordinates_offset="0,0" identifier="tex_chess_figures" width="256" height="256" size_x="8" size_y="8" />
|
||||
</flatten_array>
|
||||
|
||||
<flatten_array identifier="cannon_barrel" >
|
||||
<array_2d coordinates_offset="2048,0" identifier="tex_chess_figures" width="512" height="256" size_x="4" size_y="8" />
|
||||
</flatten_array>
|
||||
</texturedefinitions>
|
BIN
android/assets/spritesheet.png
Normal file
After Width: | Height: | Size: 170 KiB |
@ -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() {
|
||||
try {
|
||||
Textures.init();
|
||||
} catch (AgdxTexDefException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
setLayer(new StandardLevel(this));
|
||||
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
|