diff --git a/SPD-classes/src/main/java/com/watabou/noosa/TextureFilm.java b/SPD-classes/src/main/java/com/watabou/noosa/TextureFilm.java index 53ed9ca5c..b3d4b591c 100644 --- a/SPD-classes/src/main/java/com/watabou/noosa/TextureFilm.java +++ b/SPD-classes/src/main/java/com/watabou/noosa/TextureFilm.java @@ -90,6 +90,26 @@ public class TextureFilm { } } } + + //creates a film for a texture with known size without needing to reference it + public TextureFilm( int txWidth, int txHeight, int width, int height){ + + texWidth = txWidth; + texHeight = txHeight; + + float uw = (float)width / texWidth; + float vh = (float)height / texHeight; + int cols = texWidth / width; + int rows = texHeight / height; + + for (int i=0; i < rows; i++) { + for (int j=0; j < cols; j++) { + RectF rect = new RectF( j * uw, i * vh, (j+1) * uw, (i+1) * vh ); + add( i * cols + j, rect ); + } + } + + } public void add( Object id, RectF rect ) { frames.put( id, rect ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/ItemSpriteSheet.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/ItemSpriteSheet.java index c7405044e..349fc94a9 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/ItemSpriteSheet.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/ItemSpriteSheet.java @@ -26,10 +26,14 @@ import com.watabou.noosa.TextureFilm; public class ItemSpriteSheet { - private static final int WIDTH = 16; public static final int SIZE = 16; - public static TextureFilm film = new TextureFilm( Assets.Sprites.ITEMS, SIZE, SIZE ); + private static final int TX_WIDTH = 256; + private static final int TX_HEIGHT = 512; + + private static final int WIDTH = TX_WIDTH / SIZE; + + public static TextureFilm film = new TextureFilm( TX_WIDTH, TX_HEIGHT, SIZE, SIZE ); private static int xy(int x, int y){ x -= 1; y -= 1;