ImageLayer

class ImageLayer extends Sprite

a generic Image Layer Object

Constructor


new ImageLayer(x: number, y: number, settings: object) → {}
// create a repetitive background pattern on the X axis using the citycloud image asset
me.game.world.addChild(new me.ImageLayer(0, 0, {
    image:"citycloud",
    repeat :"repeat-x"
}), 1);
Parameters:
Name Type Attributes Default Description
x number

x coordinate

y number

y coordinate

settings object

ImageLayer properties

settings.image HTMLImageElement | HTMLCanvasElement | string

Image reference. See loader.getImage

settings.name string

<optional>

"me.ImageLayer"

layer name

settings.z number

<optional>

0

z-index position

settings.ratio number | Vector2d

<optional>

1.0

Scrolling ratio to be applied. See ImageLayer#ratio

settings.repeat "repeat" | "repeat-x" | "repeat-y" | "no-repeat"

<optional>

"repeat"

define if and how an Image Layer should be repeated. See ImageLayer#repeat

settings.anchorPoint number | Vector2d

<optional>

<0.0,0.0>

Define how the image is anchored to the viewport bound. By default, its upper-left corner is anchored to the viewport bounds upper left corner.

Summary


Properties from ImageLayer

Properties inherited from Rect

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

Properties inherited from Polygon

Array<Vector2d>
points

Public Properties


ratio imagelayer.js:42
ratio: Vector2d = <1.0,1.0>

Vector2d

Define the image scrolling ratio
Scrolling speed is defined by multiplying the viewport delta position by the specified ratio. Setting this vector to <0.0,0.0> will disable automatic scrolling.
To specify a value through Tiled, use one of the following format :

  • a number, to change the value for both axis
  • a json expression like json:{"x":0.5,"y":0.5} if you wish to specify a different value for both x and y
repeat imagelayer.js:81
repeat: string = 'repeat'

string

Define if and how an Image Layer should be repeated.
By default, an Image Layer is repeated both vertically and horizontally.
Acceptable values :

  • 'repeat' - The background image will be repeated both vertically and horizontally
  • 'repeat-x' - The background image will be repeated only horizontally.
  • 'repeat-y' - The background image will be repeated only vertically.
  • 'no-repeat' - The background-image will not be repeated.

Public Methods


resize imagelayer.js:136
resize(w: number, h: number) → {}

resize the Image Layer to match the given size

Parameters:
Name Type Description
w number

new width

h number

new height

Protected Methods


draw imagelayer.js:228
protected draw(renderer: CanvasRenderer | WebGLRenderer, viewport: Camera2d) → {}

draw this ImageLayer (automatically called by melonJS)

Parameters:
Name Type Attributes Description
renderer CanvasRenderer | WebGLRenderer

a renderer instance

viewport Camera2d

<optional>

the viewport to (re)draw


Powered by webdoc!