Beispiel #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();
   }
 }
Beispiel #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);
 }
Beispiel #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());
 }
Beispiel #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;
 }
Beispiel #5
0
 public void setImage(LTexture image) {
   this.image = image;
   this.width = (int) image.width();
   this.height = (int) image.height();
 }
Beispiel #6
0
 public void setImage(String fileName) {
   this.image = LTextures.loadTexture(fileName);
   this.width = (int) image.width();
   this.height = (int) image.height();
 }
Beispiel #7
0
 public void setRegion(LTexture texture) {
   this.texture = texture;
   setRegion(0, 0, texture.width(), texture.height());
 }
Beispiel #8
0
 public int getRegionHeight() {
   float result = texture.height() * heightRatio - texture.height() * yOff;
   return (int) (result > 0 ? result : -result);
 }
Beispiel #9
0
 public int getRegionY() {
   return (int) (yOff * texture.height());
 }