Ejemplo n.º 1
0
 public void scroll(float xAmount, float yAmount) {
   if (xAmount != 0) {
     float width = (widthRatio - xOff) * texture.width();
     xOff = (xOff + xAmount) % 1;
     widthRatio = xOff + width / texture.width();
   }
   if (yAmount != 0) {
     float height = (heightRatio - yOff) * texture.height();
     yOff = (yOff + yAmount) % 1;
     heightRatio = yOff + height / texture.height();
   }
 }
Ejemplo n.º 2
0
 public void setRegion(int x, int y, int width, int height) {
   float invTexWidth = 1f;
   float invTexHeight = 1f;
   if (texture.isScale()) {
     invTexWidth = (1f / texture.width());
     invTexHeight = (1f / texture.height());
   } else {
     invTexWidth = (1f / texture.width()) * texture.widthRatio;
     invTexHeight = (1f / texture.height()) * texture.heightRatio;
   }
   setRegion(
       x * invTexWidth + texture.xOff,
       y * invTexHeight + texture.yOff,
       (x + width) * invTexWidth,
       (y + height) * invTexHeight);
 }
Ejemplo n.º 3
0
 public LTextureRegion(LTexture texture) {
   if (texture == null) {
     throw new IllegalArgumentException("texture cannot be null.");
   }
   this.texture = texture;
   setRegion(0, 0, texture.width(), texture.height());
 }
Ejemplo n.º 4
0
 public Picture(LTexture image, int x, int y) {
   if (image != null) {
     this.setImage(image);
     this.width = (int) image.width();
     this.height = (int) image.height();
   }
   this.setLocation(x, y);
   this.visible = true;
 }
Ejemplo n.º 5
0
 public void setImage(LTexture image) {
   this.image = image;
   this.width = (int) image.width();
   this.height = (int) image.height();
 }
Ejemplo n.º 6
0
 public void setImage(String fileName) {
   this.image = LTextures.loadTexture(fileName);
   this.width = (int) image.width();
   this.height = (int) image.height();
 }
Ejemplo n.º 7
0
 public void setRegion(LTexture texture) {
   this.texture = texture;
   setRegion(0, 0, texture.width(), texture.height());
 }
Ejemplo n.º 8
0
 public int getRegionWidth() {
   float result = texture.width() * widthRatio - texture.width() * xOff;
   return (int) (result > 0 ? result : -result);
 }
Ejemplo n.º 9
0
 public int getRegionX() {
   return (int) (xOff * texture.width());
 }