Class R.components.transform.BehaviorMover2D
Extends
R.components.Transform2D.
A 2d transform component driven by different behaviors. Behaviors are located in the
R.components.logic
package.
Defined in: behaviormover2d.js.
Constructor Attributes | Constructor Name and Description |
---|---|
R.components.transform.BehaviorMover2D(name, maxForce, maxSpeed)
|
- Fields borrowed from class R.components.Base:
- TYPE_COLLIDER, TYPE_INPUT, TYPE_LOGIC, TYPE_RENDERING, TYPE_TRANSFORM
Method Attributes | Method Name and Description |
---|---|
addBehavior(name, behavior, weight)
Add a behavior to this component.
|
|
execute(renderContext, time, dt)
Execute this component, calculating motion based on the behaviors.
|
|
getBehavior(name)
Get the behavior component, by name.
|
|
Get the maximum force that can be applied to this mover component.
|
|
Get the maximum speed of this mover component.
|
|
Get the current velocity of the mover component.
|
|
removeBehavior(name)
Remove a behavior, by name.
|
|
setMaxSpeed(speed)
Set the maximum speed which can be applied to this mover component.
|
|
setStopped(state)
Stop or start behavior processing.
|
|
setVelocity(vel, y)
Set the velocity, directly.
|
- Methods borrowed from class R.components.Transform2D:
- destroy, getClassName, getLastPosition, getLastRenderPosition, getPosition, getRenderPosition, getRenderRotation, getRenderScale, getRenderScaleX, getRenderScaleY, getRotation, getScale, getScaleX, getScaleY, release, setLastPosition, setPosition, setRotation, setScale
- Methods borrowed from class R.components.Base:
- getGameObject, getHostObject, getPriority, getType, getTypeString, setGameObject, setHostObject, setPriority
- Methods borrowed from class R.engine.BaseObject:
- addEvent, addEvents, getElement, jQ, removeEvent, setElement, triggerEvent, update
- Methods borrowed from class R.engine.PooledObject:
- clearObjectDataModel, getId, getName, getObjectDataModel, getProperties, isDestroyed, setName, setObjectDataModel, toString, toXML
Class Detail
R.components.transform.BehaviorMover2D(name, maxForce, maxSpeed)
- Parameters:
- name
- The name of the component
- maxForce
- The maximum force that can be applied to the vehicle
- maxSpeed
- The top speed of the vehicle
Method Detail
addBehavior(name, behavior, weight)
Add a behavior to this component.
- Parameters:
- name
- {String} The name of the behavior
- behavior
- {R.components.Logic} A behavior component to add
- weight
- {Number} The blending weight of the component amongst all other components
execute(renderContext, time, dt)
Execute this component, calculating motion based on the behaviors.
- Parameters:
- renderContext
- {R.rendercontexts.AbstractRenderContext} The rendering context
- time
- {Number} The world time
- dt
- {Number} The time since the last frame was generated
{R.components.Logic}
getBehavior(name)
Get the behavior component, by name.
- Parameters:
- name
- {String}
- Returns:
- {R.components.Logic} The behavior component
{Number}
getMaxForce()
Get the maximum force that can be applied to this mover component.
- Returns:
- {Number}
{Number}
getMaxSpeed()
Get the maximum speed of this mover component.
- Returns:
- {Number}
{R.math.Vector2D}
getVelocity()
Get the current velocity of the mover component.
- Returns:
- {R.math.Vector2D}
{R.components.Logic}
removeBehavior(name)
Remove a behavior, by name.
- Parameters:
- name
- {String} The behavior component to remove
- Returns:
- {R.components.Logic} The component which was removed
setMaxSpeed(speed)
Set the maximum speed which can be applied to this mover component.
- Parameters:
- speed
- {Number} The maximum speed
setStopped(state)
Stop or start behavior processing.
- Parameters:
- state
- {Boolean} Set to
true
to stop behaviors from executing
setVelocity(vel, y)
Set the velocity, directly.
- Parameters:
- vel
- {R.math.Vector2D|Number} The velocity vector, or X component
- y
- {Number} The Y component, if vel is the X component