v3.2.2: adjusted itemspritesheet to not longer init with texture ref
This commit is contained in:
@@ -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 );
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user