Class R.objects.Object2D
Extends
R.engine.GameObject.
An object for use in a 2d game environment. If no transformComponent is provided,
the object will be assigned a {@link R.components.Transform2D Transform2D} component. This class is the recommended
base class for objects used within a 2d game environment, instead of deriving from the base
R.engine.GameObject class.
Defined in: object2d.js.
Constructor Attributes | Constructor Name and Description |
---|---|
R.objects.Object2D(name, transformComponent)
Create a game object with methods for operating in a 2D context.
|
- Fields borrowed from class R.struct.Container:
- EMPTY
Method Attributes | Method Name and Description |
---|---|
deserialize(obj, clazz)
Deserialize the object back into a 2d object.
|
|
destroy()
Destroy the object.
|
|
getAABB()
Get an axis aligned world bounding box for the object.
|
|
Get the object's local bounding box.
|
|
[ABSTRACT] Get the object's local bounding circle.
|
|
Get the class name of this object
|
|
Get the convex hull used for collision testing with a {@link R.components.ConvexCollider ConvexCollider}
component.
|
|
Get the default transform component.
|
|
Get the last position the object was rendered at.
|
|
Get the render origin of the object.
|
|
Get the position of the object, at its origin.
|
|
Get the position of the object.
|
|
Returns a bean which represents the read or read/write properties
of the object.
|
|
Get the render position of the object.
|
|
Get the world adjusted rotation of the object
|
|
Get the rotation of the object
|
|
getScale()
Get the scale of the object along both the X and Y axis.
|
|
Get the scale of the object along the X axis
|
|
Get the scale of the object along the Y axis.
|
|
Get the transformation matrix for this object
|
|
Get the object's bounding box in world coordinates.
|
|
Get the object's bounding circle in world coordinates.
|
|
Get the depth at which this object will render to
the context.
|
|
release()
Release the object back into the pool.
|
|
serialize(obj, defaults)
Get a properties object with values for the given object.
|
|
setBoundingBox(width, height)
Set the bounding box of this object
|
|
setCollisionHull(convexHull)
Set the convex hull used for collision.
|
|
setDefaultTransformComponent(transformComponent)
Set, or override, the default transformation component.
|
|
setOrigin(x, y)
Set the render origin of the object.
|
|
setPosition(point, y)
Set the position of the object
|
|
setRotation(angle)
Set the rotation of the object
|
|
setScale(scaleX, scaleY)
Set the scale of the object along the X and Y axis in the scaling matrix
|
|
setZIndex(zIndex)
Set the depth at which this object will render to
the context.
|
- Methods borrowed from class R.engine.GameObject:
- add, componentSort, getComponent, getComponentByClass, getRenderContext, isDirty, isKeepAlive, markDirty, remove, setKeepAlive, setRenderContext, update, wasDirty
- Methods borrowed from class R.struct.HashContainer:
- cleanUp, clear, get, isInHash, removeAtIndex, removeHash
- Methods borrowed from class R.struct.Container:
- addAll, append, clone, concat, contains, filter, forEach, fromArray, getAll, getObjects, insert, iterator, reduce, replace, replaceAt, size, sort, subset, toXML
- Methods borrowed from class R.engine.BaseObject:
- addEvent, addEvents, getElement, jQ, removeEvent, setElement, triggerEvent
- Methods borrowed from class R.engine.PooledObject:
- clearObjectDataModel, getId, getName, getObjectDataModel, isDestroyed, setName, setObjectDataModel, toString
Class Detail
R.objects.Object2D(name, transformComponent)
Create a game object with methods for operating in a 2D context.
- Parameters:
- name
- {String} The name of the object
- transformComponent Optional
- {R.components.Transform2D} The transform component to use, or
null
. If the value isnull
, the object will be assigned a default {@link R.components.Transform2D Transform2D} component.
Method Detail
{R.objects.Object2D}
deserialize(obj, clazz)
Deserialize the object back into a 2d object.
- Parameters:
- obj
- {Object} The object to deserialize
- clazz Optional
- {Class} The object class to populate
- Returns:
- {R.objects.Object2D} The object which was deserialized
destroy()
Destroy the object.
{R.math.Rectangle2D}
getAABB()
Get an axis aligned world bounding box for the object. This bounding box
is ensured to encompass the entire object.
- Returns:
- {R.math.Rectangle2D}
{R.math.Rectangle2D}
getBoundingBox()
Get the object's local bounding box.
- Returns:
- {R.math.Rectangle2D} The object bounding rectangle
{R.math.Circle2D}
getBoundingCircle()
[ABSTRACT] Get the object's local bounding circle.
- Returns:
- {R.math.Circle2D} The object bounding circle
{String}
getClassName()
Get the class name of this object
- Returns:
- {String} "R.objects.Object2D"
{R.collision.ConvexHull}
getCollisionHull()
Get the convex hull used for collision testing with a {@link R.components.ConvexCollider ConvexCollider}
component. If no collision hull has been assigned, a {@link R.collision.OBBHull OBBHull} will
be created and returned.
- Returns:
- {R.collision.ConvexHull}
{R.components.Transform2D}
getDefaultTransformComponent()
Get the default transform component.
- Returns:
- {R.components.Transform2D}
{R.math.Point2D}
getLastPosition()
Get the last position the object was rendered at.
- Returns:
- {R.math.Point2D}
{R.math.Point2D}
getOrigin()
Get the render origin of the object.
- Returns:
- {R.math.Point2D}
{R.math.Point2D}
getOriginPosition()
Get the position of the object, at its origin.
- Returns:
- {R.math.Point2D} The position
{R.math.Point2D}
getPosition()
Get the position of the object.
- Returns:
- {R.math.Point2D} The position
{Object}
getProperties()
Returns a bean which represents the read or read/write properties
of the object.
- Returns:
- {Object} The properties object
{R.math.Point2D}
getRenderPosition()
Get the render position of the object.
- Returns:
- {R.math.Point2D}
{Number}
getRenderRotation()
Get the world adjusted rotation of the object
- Returns:
- {Number} Angle in degrees
{Number}
getRotation()
Get the rotation of the object
- Returns:
- {Number} Angle in degrees
{R.math.Vector2D}
getScale()
Get the scale of the object along both the X and Y axis.
- Returns:
- {R.math.Vector2D}
{Number}
getScaleX()
Get the scale of the object along the X axis
- Returns:
- {Number}
{Number}
getScaleY()
Get the scale of the object along the Y axis.
- Returns:
- {Number}
{Matrix}
getTransformationMatrix()
Get the transformation matrix for this object
- Returns:
- {Matrix}
{R.math.Rectangle2D}
getWorldBox()
Get the object's bounding box in world coordinates.
- Returns:
- {R.math.Rectangle2D} The world bounding rectangle
{R.math.Circle2D}
getWorldCircle()
Get the object's bounding circle in world coordinates. If #getBoundingCircle returns
null, the bounding circle will be approximated using #getBoundingBox.
- Returns:
- {R.math.Circle2D} The world bounding circle
{Number}
getZIndex()
Get the depth at which this object will render to
the context.
- Returns:
- {Number}
release()
Release the object back into the pool.
{Object}
serialize(obj, defaults)
Get a properties object with values for the given object.
- Parameters:
- obj
- {R.objects.Object2D} The object to query
- defaults Optional
- {Object} Default values that don't need to be serialized unless they are different.
- Returns:
- {Object}
setBoundingBox(width, height)
Set the bounding box of this object
- Parameters:
- width
- {Number|R.math.Rectangle2D} The width, or the rectangle that completely encompasses this object.
- height
- {Number} If width is a number, this is the height
setCollisionHull(convexHull)
Set the convex hull used for collision. The {@link R.components.ConvexCollider ConvexCollider} component
uses the collision hull to perform the collision testing.
- Parameters:
- convexHull
- {R.collision.ConvexHull} The convex hull object
setDefaultTransformComponent(transformComponent)
Set, or override, the default transformation component.
- Parameters:
- transformComponent
- {R.components.Transform2D}
setOrigin(x, y)
Set the render origin of the object. The render origin is where the object will be
centered around when drawing position and rotation.
- Parameters:
- x
- {Number|R.math.Point2D} The X coordinate or the render origin (default: 0,0 - top left corner)
- y
- {Number} The Y coordinate or
null
if X is aPoint2D
setPosition(point, y)
Set the position of the object
- Parameters:
- point
- {R.math.Point2D|Number} The position of the object, or a simple X coordinate
- y Optional
- {Number} A Y coordinate if point is a number
setRotation(angle)
Set the rotation of the object
- Parameters:
- angle
- {Number} The rotation angle
setScale(scaleX, scaleY)
Set the scale of the object along the X and Y axis in the scaling matrix
- Parameters:
- scaleX
- {Number} The scale along the X axis
- scaleY Optional
- {Number} Optional scale along the Y axis. If no value is provided scaleX will be used to perform a uniform scale.
setZIndex(zIndex)
Set the depth at which this object will render to
the context. The lower the z-index, the further
away from the front the object will draw.
- Parameters:
- zIndex
- {Number} The z-index of this object