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