Esempio n. 1
0
 public SpriteSheet(LTexture img, int tw, int th, int s, int m) {
   this.width = img.getWidth();
   this.height = img.getHeight();
   this.target = img;
   this.tw = tw;
   this.th = th;
   this.margin = m;
   this.spacing = s;
 }
Esempio n. 2
0
 public void setImage(LTexture image) {
   if (image != null || this.image != null) {
     boolean sizeChanged = true;
     if (image != null
         && this.image != null
         && image.getWidth() == this.image.getWidth()
         && image.getHeight() == this.image.getHeight()) {
       sizeChanged = false;
     }
     this.image = image;
     if (sizeChanged) {
       this.boundingRect = null;
       this.sizeChanged();
     }
   }
 }
Esempio n. 3
0
 public void dispose() {
   this.isClose = true;
   if (texture != null) {
     texture.destroy();
     texture = null;
   }
 }
Esempio n. 4
0
 public void dispose() {
   if (image != null) {
     image.dispose();
     image = null;
   }
   if (animation != null) {
     animation.dispose();
     animation = null;
   }
 }
Esempio n. 5
0
 public LTexture getImage(int x, int y) {
   checkImage(x, y);
   if ((x < 0) || (x >= subImages.length)) {
     throw new RuntimeException("SubTexture2D out of sheet bounds: " + x + "," + y);
   }
   if ((y < 0) || (y >= subImages[0].length)) {
     throw new RuntimeException("SubTexture2D out of sheet bounds: " + x + "," + y);
   }
   return target.getSubTexture(x * (tw + spacing) + margin, y * (th + spacing) + margin, tw, th);
 }
Esempio n. 6
0
 public synchronized void update() {
   if (isClose) {
     return;
   }
   if (texture == null) {
     texture = new LTexture(width, height, hasAlpha);
   }
   if (!texture.isLoaded()) {
     texture.loadTexture();
     GLEx.gl10.glBindTexture(GL.GL_TEXTURE_2D, texture.getTextureID());
     GLEx.gl10.glTexSubImage2D(
         GL.GL_TEXTURE_2D, 0, 0, 0, width, height, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, buffer);
     GLEx.gl10.glBindTexture(GL.GL_TEXTURE_2D, 0);
   } else {
     if (isUpdate) {
       GLEx.gl10.glBindTexture(GL.GL_TEXTURE_2D, texture.getTextureID());
       GLEx.gl10.glTexSubImage2D(
           GL.GL_TEXTURE_2D, 0, 0, 0, width, height, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, buffer);
       GLEx.gl10.glBindTexture(GL.GL_TEXTURE_2D, 0);
       isUpdate = false;
     }
   }
 }
Esempio n. 7
0
 public void dispose() {
   if (target != null) {
     target.dispose();
     target = null;
   }
   if (subImages != null) {
     synchronized (subImages) {
       for (int i = 0; i < subImages.length; i++) {
         for (int j = 0; j < subImages[i].length; j++) {
           subImages[i][j].dispose();
         }
       }
       this.subImages = null;
     }
   }
 }
Esempio n. 8
0
 private void update() {
   if (subImages != null) {
     return;
   }
   target.loadTexture();
   int tilesAcross = ((width - (margin * 2) - tw) / (tw + spacing)) + 1;
   int tilesDown = ((height - (margin * 2) - th) / (th + spacing)) + 1;
   if ((height - th) % (th + spacing) != 0) {
     tilesDown++;
   }
   subImages = new LTexture[tilesAcross][tilesDown];
   for (int x = 0; x < tilesAcross; x++) {
     for (int y = 0; y < tilesDown; y++) {
       subImages[x][y] = getImage(x, y);
     }
   }
 }
Esempio n. 9
0
 public int getHeight() {
   if (image != null) {
     return image.getHeight();
   }
   return getRectBox().height;
 }
Esempio n. 10
0
 public int getWidth() {
   if (image != null) {
     return image.getWidth();
   }
   return getRectBox().width;
 }
Esempio n. 11
0
 public PhysicsPolygon(LTexture img) {
   this((Polygon) img.getShape());
 }