NineSliceSprite

class NineSliceSprite extends Sprite

A NineSliceSprite is similar to a Sprite, but it uses 9-slice scaling to strech its inner area to fit the size of the Renderable, by proportionally scaling a sprite by splitting it in a grid of nine parts (with only parts 1, 3, 7, 9 not being scaled).

See: https://en.wikipedia.org/wiki/9-slice_scaling

Constructor


new NineSliceSprite(x: number, y: number, settings: object) → {}
this.panelSprite = new me.NineSliceSprite(0, 0, {
    image : game.texture,
    region : "grey_panel",
    width : this.width,
    height : this.height
});
Parameters:
Name Type Attributes Default Description
x number

the x coordinates of the sprite object

y number

the y coordinates of the sprite object

settings object

Configuration parameters for the Sprite object

settings.width number

the width of the Renderable over which the sprite needs to be stretched

settings.height number

the height of the Renderable over which the sprite needs to be stretched

settings.insetx number

<optional>

the width of a corner over which the sprite is unscaled (default is a quarter of the sprite width)

settings.insety number

<optional>

the height of a corner over which the sprite is unscaled (default is a quarter of the sprite height)

settings.image HTMLImageElement | HTMLCanvasElement | TextureAtlas | string

reference to spritesheet image, a texture atlas or to a texture atlas

settings.name string

<optional>

""

name of this object

settings.region string

<optional>

region name of a specific region to use when using a texture atlas, see TextureAtlas

settings.framewidth number

<optional>

Width of a single frame within the spritesheet

settings.frameheight number

<optional>

Height of a single frame within the spritesheet

settings.tint string | Color

<optional>

a tint to be applied to this sprite

settings.flipX number

<optional>

flip the sprite on the horizontal axis

settings.flipY number

<optional>

flip the sprite on the vertical axis

settings.anchorPoint Vector2d

<optional>

{x:0.5, y:0.5}

Anchor point to draw the frame at (defaults to the center of the frame).

Summary


Properties from NineSliceSprite

number
height
number
width

Properties inherited from Rect

number
bottom
number
centerX
number
centerY
number
left
number
right
number
top
string
type = "Rectangle"

Properties inherited from Polygon

Array<Vector2d>
points

Public Properties


height nineslicesprite.js:69
height: number

number

height of the NineSliceSprite

width nineslicesprite.js:58
width: number

number

width of the NineSliceSprite


Powered by webdoc!