public TextureFilm( TextureFilm atlas, Object key, int width, int height ) { texture = atlas.texture; texWidth = atlas.texWidth; texHeight = atlas.texHeight; RectF patch = atlas.get( key ); float uw = (float)width / texWidth; float vh = (float)height / texHeight; int cols = (int)(width( patch ) / width); int rows = (int)(height( patch ) / 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 ); rect.shift( patch.left, patch.top ); add( i * cols + j, rect ); } } }
public static Image image( int index ) { Image image = new Image( Assets.BADGES ); if (atlas == null) { atlas = new TextureFilm( image.texture, 16, 16 ); } image.frame( atlas.get( index ) ); return image; } }
public Animation frames( TextureFilm film, Object... frames ) { this.frames = new RectF[frames.length]; for (int i=0; i < frames.length; i++) { this.frames[i] = film.get( frames[i] ); } return this; }
public SpellSprite() { super( Assets.SPELL_ICONS ); if (film == null) { film = new TextureFilm( texture, SIZE ); } }
@Override public Emitter emitter() { if (seal == null) return super.emitter(); Emitter emitter = new Emitter(); emitter.pos(ItemSpriteSheet.film.width(image)/2f + 2f, ItemSpriteSheet.film.height(image)/3f); emitter.fillTarget = false; emitter.pour(Speck.factory( Speck.RED_LIGHT ), 0.6f); return emitter; }
private static void assignItemRect( int item, int width, int height){ int x = (item % WIDTH) * WIDTH; int y = (item / WIDTH) * WIDTH; film.add( item, x, y, x+width, y+height); }
public Animation frames( TextureFilm film, Object... frames ) { this.frames = new RectF[frames.length]; for (int i=0; i < frames.length; i++) { this.frames[i] = film.get( frames[i] ); } return this; }
public SpellSprite() { super( Assets.SPELL_ICONS ); if (film == null) { film = new TextureFilm( texture, SIZE ); } }
@Override public Emitter emitter() { if (seal == null) return super.emitter(); Emitter emitter = new Emitter(); emitter.pos(ItemSpriteSheet.film.width(image)/2f + 2f, ItemSpriteSheet.film.height(image)/3f); emitter.fillTarget = false; emitter.pour(Speck.factory( Speck.RED_LIGHT ), 0.6f); return emitter; }
private static void assignItemRect( int item, int width, int height){ int x = (item % WIDTH) * WIDTH; int y = (item / WIDTH) * WIDTH; film.add( item, x, y, x+width, y+height); }
public TextureFilm( TextureFilm atlas, Object key, int width, int height ) { texWidth = atlas.texWidth; texHeight = atlas.texHeight; RectF patch = atlas.get( key ); float uw = (float)width / texWidth; float vh = (float)height / texHeight; float pwidth = Math.round(width( patch )); float pheight = Math.round(height( patch )); int cols = (int)(pwidth / width); int rows = (int)(pheight / 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 ); rect.offset( patch.left, patch.top ); add( i * cols + j, rect ); } } }
public Animation frames( TextureFilm film, Object... frames ) { this.frames = new RectF[frames.length]; for (int i=0; i < frames.length; i++) { this.frames[i] = film.get( frames[i] ); } return this; }
public Avatar( HeroClass cl ) { super( Assets.AVATARS ); frame( new TextureFilm( texture, WIDTH, HEIGHT ).get( cl.ordinal() ) ); } }