class spinehx.atlas.TextureRegion

Available on all platforms

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

var u:Float

var u2:Float

var v:Float

var v2:Float

function new():Void

Constructs a region with no texture and no coordinates defined.

function flip(x:Bool, y:Bool):Void

function getRegionHeight():Int

Returns the region's height.

function getRegionWidth():Int

Returns the region's width.

function getRegionX():Int

function getRegionY():Int

function getTexture():Texture

function getU():Float

function getU2():Float

function getV():Float

function getV2():Float

function isFlipX():Bool

function isFlipY():Bool

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 setRegionHeight(height:Int):Void

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 setRegionUV(u:Float, v:Float, u2:Float, v2:Float):Void

function setRegionWidth(width:Int):Void

function setRegionX(x:Int):Void

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 setRegionY(y:Int):Void

function setTexture(texture:Texture):Void

function setU(u:Float):Void

function setU2(u2:Float):Void

function setV(v:Float):Void

function setV2(v2:Float):Void

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].