class spinehx.atlas.TextureRegion
Available on all platforms
Sub classes | ||||
![]() | AtlasRegion |
|
Class Fields
static function copy(region:TextureRegion):TextureRegion
Constructs a region with the same texture and coordinates of the specified region.
static function createRelXYWH(region:TextureRegion, x:Int, y:Int, width:Int, height:Int):TextureRegion
Constructs a region with the same texture as the specified region and sets the coordinates relative to the specified region. *
width | The width of the texture region. May be negative to flip the sprite when drawn. * |
height | The height of the texture region. May be negative to flip the sprite when drawn. |
static function fromTexture(texture:Texture):TextureRegion
Constructs a region the size of the specified texture.
static function fromTextureUVUV(texture:Texture, u:Float, v:Float, u2:Float, v2:Float):TextureRegion
static function fromTextureWH(texture:Texture, width:Int, height:Int):TextureRegion
width | The width of the texture region. May be negative to flip the sprite when drawn. * |
height | The height of the texture region. May be negative to flip the sprite when drawn. |
static function fromTextureXYWH(texture:Texture, x:Int, y:Int, width:Int, height:Int):TextureRegion
width | The width of the texture region. May be negative to flip the sprite when drawn. * |
height | The height of the texture region. May be negative to flip the sprite when drawn. |
static function splitTex(texture:Texture, tileWidth:Int, tileHeight:Int):Array<Array<TextureRegion>>
Helper function to create tiles out of the given {@link Texture} starting from the top left corner going to the left and * ending at the bottom right corner. Only complete tiles will be returned so if the texture's width or height are not a * multiple of the tile width and height not all of the texture will be used. * *
texture | the Texture * |
tileWidth | a tile's width in pixels * |
tileHeight | a tile's height in pixels * |
returns | a 2D array of TextureRegions indexed by [row][column]. |
Instance Fields
function scroll(xAmount:Float, yAmount:Float):Void
Offsets the region relative to the current region. Generally the region's size should be the entire size of the texture in * the direction(s) it is scrolled. *
xAmount | The percentage to offset horizontally. * |
yAmount | The percentage to offset vertically. This is done in texture space, so up is negative. |
function setRegionCopy(region:TextureRegion):Void
Sets the texture and coordinates to the specified region.
function setRegionRelXYWH(region:TextureRegion, x:Int, y:Int, width:Int, height:Int):Void
Sets the texture to that of the specified region and sets the coordinates relative to the specified region.
function setRegionTex(texture:Texture):Void
Sets the texture and sets the coordinates to the size of the specified texture.
function setRegionXYWH(x:Int, y:Int, width:Int, height:Int):Void
width | The width of the texture region. May be negative to flip the sprite when drawn. * |
height | The height of the texture region. May be negative to flip the sprite when drawn. |
function split(tileWidth:Int, tileHeight:Int):Array<Array<TextureRegion>>
Helper function to create tiles out of this TextureRegion starting from the top left corner going to the left and ending at * the bottom right corner. Only complete tiles will be returned so if the region's width or height are not a multiple of the * tile width and height not all of the region will be used. * *
tileWidth | a tile's width in pixels * |
tileHeight | a tile's height in pixels * |
returns | a 2D array of TextureRegions indexed by [row][column]. |