Subversion Repositories AndroidProjects

Rev

Blame | Last modification | View Log | RSS feed

package com.gebauz.Bauzoid.graphics.sprite;

import com.badlogic.gdx.graphics.Texture;

public class SpriteRegion
{
        public float left;
        public float top;
        public float bottom;
        public float right;
       
        /** Constructor. */
        public SpriteRegion(Texture texture, float x, float y, float w, float h)
        {
                setAbsolute(texture, x, y, w, h);
        }
       
        /** Constructor - sets region by relative texture coordinates. */
        public SpriteRegion(float _top, float _left, float _right, float _bottom)
        {
                top = _top;
                left = _left;
                right = _right;
                bottom = _bottom;
        }
       
        /** Set region by absolute pixel coordinates relative to the specified texture.
         * Coordinates are in absolute texel space.
         */

        public void setAbsolute(Texture texture, float x, float y, float w, float h)
        {
                left = x / texture.getWidth();
                top = y / texture.getHeight();
                right = left + (w / texture.getWidth());
                bottom = top + (h / texture.getHeight());
        }
}