Class R.components.transform.Mover2D
Extends
R.components.Transform2D.
A mover component that adds simplified physical transformations to an object.
Properties include velocity, acceleration, mass, and gravity.
Defined in: mover2d.js.
Constructor Attributes | Constructor Name and Description |
---|---|
R.components.transform.Mover2D(name, priority)
Creates a 2d mover component
|
Field Attributes | Field Name and Description |
---|---|
The default adjustment made to calculations when a lag occurs between the last time
the component was updated and the current time.
|
|
The default velocity magnitude considered to be "at rest"
|
- Fields borrowed from class R.components.Base:
- TYPE_COLLIDER, TYPE_INPUT, TYPE_LOGIC, TYPE_RENDERING, TYPE_TRANSFORM
Method Attributes | Method Name and Description |
---|---|
destroy()
Destroys the component instance
|
|
execute(renderContext, time, dt)
Updates the transformation of the component, setting the
position and rotation based on the time that has elapsed since
the last update.
|
|
Get the acceleration vector.
|
|
Returns the angular velocity.
|
|
Determine if the component should check to see if the velocity has
dropped below a level which would indicate "at rest".
|
|
Get the class name of this object
|
|
Get the gravity vector
|
|
Get the value by which calculations are adjusted for time lag.
|
|
getMass()
Get the mass of the object.
|
|
Get the maximum velocity.
|
|
Get the magnitude at which velocity is determined to be close enough to
zero to be "at rest".
|
|
Returns the velocity vector of the component
|
|
Get the rate at which velocity will decay to zero.
|
|
Returns true if calculations should determine time lag and adjust.
|
|
Returns true if the component is in a resting state.
|
|
release()
Releases the component back into the object pool.
|
|
setAcceleration(vector, y)
Set the acceleration vector.
|
|
setAngularVelocity(angularVelocity)
Set the angular velocity.
|
|
setCheckLag(state)
Setting this to true will enable a check for time lag and adjust
calculations by a specified factor.
|
|
setCheckRestState(state)
If set to true, the component will check to see if the
velocity magnitude has dropped below a defined rate.
|
|
setGravity(vector, y)
Set the vector of gravity.
|
|
setLagAdjustment(lagAdj)
Sets the value by which calculations will be adjusted for time lag.
|
|
setMass(mass)
Set the mass of the object which can be subsequently used in
calculations like friction and energy transfer.
|
|
setMaxVelocity(maxVel)
Set the maximum velocity.
|
|
setResting(state)
Setting this to true will stop further movement calculations
from occuring.
|
|
setRestingVelocity(mag)
Set the magnitude of velocity which determines if the object is "at rest".
|
|
setVelocity(vector, y)
Set the velocity vector of the component.
|
|
setVelocityDecay(decay)
Set the decay rate at which the velocity will approach zero.
|
- Methods borrowed from class R.components.Transform2D:
- getLastPosition, getLastRenderPosition, getPosition, getRenderPosition, getRenderRotation, getRenderScale, getRenderScaleX, getRenderScaleY, getRotation, getScale, getScaleX, getScaleY, 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.Mover2D(name, priority)
Creates a 2d mover component
- Parameters:
- name
- {String} The name of the component
- priority
- {Number} The priority of this component between 0.0 and 1.0
Field Detail
DEFAULT_LAG_ADJUSTMENT
The default adjustment made to calculations when a lag occurs between the last time
the component was updated and the current time.
DEFAULT_RESTING_VELOCITY
The default velocity magnitude considered to be "at rest"
Method Detail
destroy()
Destroys the component instance
execute(renderContext, time, dt)
Updates the transformation of the component, setting the
position and rotation based on the time that has elapsed since
the last update. This component handles frame rate independent
updates so that lag between frames doesn't affect the relative
position or rotation.
- Parameters:
- renderContext
- {R.rendercontexts.AbstractRenderContext} The render context for the component
- time
- {Number} The engine time in milliseconds
- dt
- {Number} The delta between the world time and the last time the world was updated in milliseconds.
{R.math.Vector2D}
getAcceleration()
Get the acceleration vector.
- Returns:
- {R.math.Vector2D} The acceleration vector
{Number}
getAngularVelocity()
Returns the angular velocity.
- Returns:
- {Number}
{Boolean}
getCheckRestState()
Determine if the component should check to see if the velocity has
dropped below a level which would indicate "at rest".
- Returns:
- {Boolean} true if the component will check for the "resting state"
{String}
getClassName()
Get the class name of this object
- Returns:
- {String} "R.components.transform.Mover2D"
{R.math.Vector2D}
getGravity()
Get the gravity vector
- Returns:
- {R.math.Vector2D} The gravity vector
{Number}
getLagAdjustment()
Get the value by which calculations are adjusted for time lag.
- Returns:
- {Number} The adjustment value
{Number}
getMass()
Get the mass of the object.
- Returns:
- {Number} The mass of the object
{Number}
getMaxVelocity()
Get the maximum velocity.
- Returns:
- {Number} The maximum velocity
{Number}
getRestingVelocity()
Get the magnitude at which velocity is determined to be close enough to
zero to be "at rest".
- Returns:
- {Number} The resting velocity magnitude
{R.math.Vector2D}
getVelocity()
Returns the velocity vector of the component
- Returns:
- {R.math.Vector2D}
{Number}
getVelocityDecay()
Get the rate at which velocity will decay to zero.
- Returns:
- {Number} The velocity decay rate
{Boolean}
isCheckLag()
Returns true if calculations should determine time lag and adjust.
- Returns:
- {Boolean}
{Boolean}
isResting()
Returns true if the component is in a resting state.
- Returns:
- {Boolean}
release()
Releases the component back into the object pool. See R.engine.PooledObject#release
for more information.
setAcceleration(vector, y)
Set the acceleration vector. Acceleration will be constantly applied to
the last position.
- Parameters:
- vector
- {Number|R.math.Vector2D} The acceleration vector, or acceleration along X
- y Optional
- {Number} If vector is a number, the acceleration along Y
setAngularVelocity(angularVelocity)
Set the angular velocity.
- Parameters:
- angularVelocity
- {Number} The angle of change
setCheckLag(state)
Setting this to true will enable a check for time lag and adjust
calculations by a specified factor.
- Parameters:
- state
- {Boolean} true to check for lag
setCheckRestState(state)
If set to true, the component will check to see if the
velocity magnitude has dropped below a defined rate. When the
velocity magnitude drops below the set rate, the object will be
marked as "at rest" and no calculations will be made until the
object is set into motion again.
- Parameters:
- state
- {Boolean} true to check to see if the velocity has reached a "resting state".
setGravity(vector, y)
Set the vector of gravity.
- Parameters:
- vector
- {Number|R.math.Vector2D} The gravity vector, or gravity along X
- y Optional
- {Number} If vector is a number, the gravity along Y
setLagAdjustment(lagAdj)
Sets the value by which calculations will be adjusted for time lag.
- Parameters:
- lagAdj
- {Number} The adjustment value
setMass(mass)
Set the mass of the object which can be subsequently used in
calculations like friction and energy transfer.
- Parameters:
- mass
- {Number} The mass of the object
setMaxVelocity(maxVel)
Set the maximum velocity. Setting this value to zero indicates that
there is no maximum velocity.
- Parameters:
- maxVel
- {Number} The maximum velocity
setResting(state)
Setting this to true will stop further movement calculations
from occuring. Marks the object as being "at rest".
- Parameters:
- state
- {Boolean} true to stop movement
setRestingVelocity(mag)
Set the magnitude of velocity which determines if the object is "at rest".
- Parameters:
- mag
- {Number} The velocity magnitude which is "at rest"
setVelocity(vector, y)
Set the velocity vector of the component.
- Parameters:
- vector
- {Number|R.math.Vector2D} The velocity vector, or the X velocity
- y Optional
- {Number} If vector is a number, this is the Y velocity
setVelocityDecay(decay)
Set the decay rate at which the velocity will approach zero.
You can use this value to cause a moving object to eventually
stop moving. (e.g. friction)
- Parameters:
- decay
- {Number} The rate at which velocity decays