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 68

<static> anchorPoint :me.Vector2d

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 109

<static> autoTransform :Boolean

[EXPERIMENTAL] when enabled, an object container will automatically apply any defined transformation before calling the child draw method.
Type:
  • Boolean
Default Value:
  • false
Source:
renderable.js, line 122
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> currentTransform :me.Matrix2d

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

<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 98

<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 46

<static> height :Number

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

<static, readonly> inViewport :Boolean

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

<static> isPersistent :Boolean

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

<static> pos :me.ObservableVector3d

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

<static> updateWhenPaused :Boolean

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

<static> width :Number

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

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 151
See:
  • me.Renderable#setOpacity
  • me.Renderable#getOpacity

ancestor :me.Container

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

Methods

<protected, static> draw(renderer)

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

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

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

<static> getOpacity() → {Number}

get the renderable alpha channel value
Source:
renderable.js, line 234
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 379

<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 279
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 299
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 245

<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 262
See:
  • me.Renderable#currentTransform
Returns:
Reference to this object for method chaining
Type
me.Renderable

<protected, static> update(dt)

update function called by the game manager on each game loop
Parameters:
Name Type Description
dt Number time since the last update in milliseconds.
Source:
renderable.js, line 312
Returns:
false
Copyright © 2011 - 2017, Olivier Biot, Jason Oster, Aaron McLeod
Documentation generated by JSDoc 3.4.0 on 2017-02-28T11:37:41+08:00 using the DocStrap template modified by codename-.