Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 265 | chris | 1 | package com.gebauz.Bauzoid.graphics.sprite; |
| 2 | |||
| 3 | import com.badlogic.gdx.graphics.Texture; |
||
| 4 | |||
| 5 | public class SpriteRegion |
||
| 6 | { |
||
| 7 | public float left; |
||
| 8 | public float top; |
||
| 9 | public float bottom; |
||
| 10 | public float right; |
||
| 11 | |||
| 12 | /** Constructor. */ |
||
| 13 | public SpriteRegion(Texture texture, float x, float y, float w, float h) |
||
| 14 | { |
||
| 15 | setAbsolute(texture, x, y, w, h); |
||
| 16 | } |
||
| 17 | |||
| 18 | /** Constructor - sets region by relative texture coordinates. */ |
||
| 19 | public SpriteRegion(float _top, float _left, float _right, float _bottom) |
||
| 20 | { |
||
| 21 | top = _top; |
||
| 22 | left = _left; |
||
| 23 | right = _right; |
||
| 24 | bottom = _bottom; |
||
| 25 | } |
||
| 26 | |||
| 27 | /** Set region by absolute pixel coordinates relative to the specified texture. |
||
| 28 | * Coordinates are in absolute texel space. |
||
| 29 | */ |
||
| 30 | public void setAbsolute(Texture texture, float x, float y, float w, float h) |
||
| 31 | { |
||
| 32 | left = x / texture.getWidth(); |
||
| 33 | top = y / texture.getHeight(); |
||
| 34 | right = left + (w / texture.getWidth()); |
||
| 35 | bottom = top + (h / texture.getHeight()); |
||
| 36 | } |
||
| 37 | } |