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(); } }
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); }
public LTextureRegion(LTexture texture) { if (texture == null) { throw new IllegalArgumentException("texture cannot be null."); } this.texture = texture; setRegion(0, 0, texture.width(), texture.height()); }
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; }
public void setImage(LTexture image) { this.image = image; this.width = (int) image.width(); this.height = (int) image.height(); }
public void setImage(String fileName) { this.image = LTextures.loadTexture(fileName); this.width = (int) image.width(); this.height = (int) image.height(); }
public void setRegion(LTexture texture) { this.texture = texture; setRegion(0, 0, texture.width(), texture.height()); }
public int getRegionHeight() { float result = texture.height() * heightRatio - texture.height() * yOff; return (int) (result > 0 ? result : -result); }
public int getRegionY() { return (int) (yOff * texture.height()); }