Class: Renderable

me. Renderable

new Renderable(x, y, width, height)

A base class for renderable objects.
Parameters:
Name Type Description
x Number position of the renderable object
y Number position of the renderable object
width Number object width
height Number object height
Source:
renderable.js, line 20

Extends

Classes

Error

Members

<static> alwaysUpdate :Boolean

Whether the renderable object will always update, even when outside of the viewport
Type:
  • Boolean
Default Value:
  • false
Source:
renderable.js, line 93

<static> anchorPoint :me.ObservableVector2d

The anchor point is used for attachment behavior, and/or when applying transformations.
The coordinate system places the origin at the top left corner of the frame (0, 0) and (1, 1) means the bottom-right corner
:
a Renderable's anchor point defaults to (0.5,0.5), which corresponds to the center position.
Type:
Default Value:
  • <0.5,0.5>
Source:
renderable.js, line 134

<static> autoTransform :Boolean

When enabled, an object container will automatically apply any defined transformation before calling the child draw method.
Type:
  • Boolean
Default Value:
  • true
Source:
renderable.js, line 151
Example
// enable "automatic" transformation when the object is activated
onActivateEvent: function () {
    // reset the transformation matrix
    this.renderable.currentTransform.identity();
    // ensure the anchor point is the renderable center
    this.renderable.anchorPoint.set(0.5, 0.5);
    // enable auto transform
    this.renderable.autoTransform = true;
    ....
},
// add a rotation effect when updating the entity
update : function (dt) {
    ....
    this.renderable.currentTransform.rotate(0.025);
    ....
    return this._super(me.Entity, 'update', [dt]);
},

<static> body :me.Body

the renderable physic body
Type:
Source:
renderable.js, line 43
Example
// add a physic body on this renderable
myRenderable.body = new me.Body(this);
myRenderable.body.setShape(new me.Rect(0, 0, width, height));
// enable physic collision (off by default for basic me.Renderable)
myRenderable.isKinematic = false;

<static> currentTransform :me.Matrix2d

the renderable default transformation matrix
Type:
Source:
renderable.js, line 58

<static> floating :Boolean

Define if a renderable follows screen coordinates (floating)
or the world coordinates (not floating)
Type:
  • Boolean
Default Value:
  • false
Source:
renderable.js, line 123

<static> GUID :String

(G)ame (U)nique (Id)entifier"
a GUID will be allocated for any renderable object added
to an object container (including the `me.game.world` container)
Type:
  • String
Source:
renderable.js, line 71

<static> height :Number

height of the Renderable bounding box
Type:
  • Number
Source:
renderable.js, line 546

<static, readonly> inViewport :Boolean

Whether the renderable object is visible and within the viewport
Type:
  • Boolean
Default Value:
  • false
Source:
renderable.js, line 82

<static> isKinematic :Boolean

If true then physic collision and input events will not impact this renderable
Type:
  • Boolean
Default Value:
  • true
Source:
renderable.js, line 33

<static> isPersistent :Boolean

make the renderable object persistent over level changes
Type:
  • Boolean
Default Value:
  • false
Source:
renderable.js, line 113

<static> pos :me.ObservableVector3d

Position of the Renderable relative to its parent container
Type:
Source:
renderable.js, line 230

<static> updateWhenPaused :Boolean

Whether to update this object when the game is paused.
Type:
  • Boolean
Default Value:
  • false
Source:
renderable.js, line 103

<static> width :Number

width of the Renderable bounding box
Type:
  • Number
Source:
renderable.js, line 522

alpha :Number

Define the renderable opacity
Set to zero if you do not wish an object to be drawn
Type:
  • Number
Default Value:
  • 1.0
Source:
renderable.js, line 180
See:
  • me.Renderable#setOpacity
  • me.Renderable#getOpacity

ancestor :me.Container|me.Entity

a reference to the parent object that contains this renderable, or undefined if it has not been added to one.
Type:
Default Value:
  • undefined
Source:
renderable.js, line 192

Methods

<protected, static> draw(renderer)

object draw.
automatically called by the game manager me.game
Parameters:
Name Type Description
renderer me.CanvasRenderer | me.WebGLRenderer a renderer object
Source:
renderable.js, line 466

<static> flipX(flip)

flip the renderable on the horizontal axis, using negative transform scale
Parameters:
Name Type Description
flip Boolean enable/disable flip
Source:
renderable.js, line 297
See:

<static> flipY(flip)

flip the renderable on the vertical axis, using negative transform scale
Parameters:
Name Type Description
flip Boolean enable/disable flip
Source:
renderable.js, line 313
See:

<static> getBounds() → {me.Rect}

returns the bounding box for this renderable
Source:
renderable.js, line 258
Returns:
bounding box Rectangle object
Type
me.Rect

<static> getOpacity() → {Number}

get the renderable alpha channel value
Source:
renderable.js, line 269
Returns:
current opacity value between 0 and 1
Type
Number

<static> onDestroyEvent()

OnDestroy Notification function
Called by engine before deleting the object
Source:
renderable.js, line 510

<protected, static> postDraw(renderer)

restore the rendering context after drawing.
automatically called by the game manager me.game
Parameters:
Name Type Description
renderer me.CanvasRenderer | me.WebGLRenderer a renderer object
Source:
renderable.js, line 479

<protected, static> preDraw(renderer)

prepare the rendering context before drawing (apply defined transforms, anchor point).
automatically called by the game manager me.game
Parameters:
Name Type Description
renderer me.CanvasRenderer | me.WebGLRenderer a renderer object
Source:
renderable.js, line 434

<static> scale(x, y) → {me.Renderable}

scale the renderable around his anchor point
Parameters:
Name Type Argument Default Description
x Number a number representing the abscissa of the scaling vector.
y Number <optional>
x a number representing the ordinate of the scaling vector.
Source:
renderable.js, line 346
Returns:
Reference to this object for method chaining
Type
me.Renderable

<static> scaleV(vector) → {me.Renderable}

scale the renderable around his anchor point
Parameters:
Name Type Description
vector me.Vector2d scaling vector
Source:
renderable.js, line 366
Returns:
Reference to this object for method chaining
Type
me.Renderable

<static> setOpacity(alpha)

set the renderable alpha channel value
Parameters:
Name Type Description
alpha Number opacity value between 0.0 and 1.0
Source:
renderable.js, line 280

<static> transform(matrix) → {me.Renderable}

multiply the renderable currentTransform with the given matrix
Parameters:
Name Type Description
matrix me.Matrix2d the transformation matrix
Source:
renderable.js, line 329
See:
  • me.Renderable#currentTransform
Returns:
Reference to this object for method chaining
Type
me.Renderable

<protected, static> update(dt)

update function.
automatically called by the game manager me.game
Parameters:
Name Type Description
dt Number time since the last update in milliseconds.
Source:
renderable.js, line 379
Returns:
false