Class Index | File Index

Classes


Class twodee.SceneNode


Extends .
A scene node. Can be used directly to create invisible group nodes or can be extended to implement other node types.
Defined in: SceneNode.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Constructs a new scene node.
Field Summary
Field Attributes Field Name and Description
<static>  
twodee.SceneNode.counter
Instance counter.
Method Summary
Method Attributes Method Name and Description
 
Appends the specified node as a child node to this node.
 
collide(other)
Informs the node that it has collided with the specified node.
 
collidesWith(other)
Checks if this node collides with the specified node.
 
Disables the node.
 
Enables the node.
 
Returns the bounds of this node.
 
Returns the collisiton bit mask of the node.
 
Returns the collisiton type of the node.
 
Returns the first child node of this node.
 
Returns the node id.
 
Returns the last child node of this node.
 
Returns the next sibling of this node.
 
Returns the current opacity of the node.
 
Returns the parent node.
 
Returns the physics model.
 
Returns the previous sibling of this node.
 
Returns the current transformation matrix.
 
Checks if this node has child nodes.
 
insertBefore(insertNode, referenceNode)
Inserts a new child node before the specified reference node.
 
Checks if the node is collidable.
 
Checks if node is enabled or not.
 
Finishes the collision detection.
 
Removes this node from its parent.
 
Removes the specified child node from this node.
 
Removes all child nodes.
 
render(g, transform)
Renders the node.
 
replaceChild(oldNode, newNode)
Replaces the specified old node with the specified new node.
 
setBounds(bounds)
Sets the bounds of this node.
 
setCollisionMask(collisionMask)
Sets the collision bit mask of the node.
 
setCollisionType(collisionType)
Sets the collision type of the node.
 
setEnabled(enabled)
Enables or disables the node.
 
setOpacity(opacity)
Sets the opacity of the node.
 
setPhysics(physics)
Sets the physics model.
 
update(delta)
Updates the node with the specified time delta.
 
updateTransformation(baseTransform)
Transforms the node according to its effective transformation (Calculated from its local transformation and the effective transformation of its parent).
Class Detail
twodee.SceneNode()
Constructs a new scene node.
Field Detail
<static> twodee.SceneNode.counter
Instance counter.
Method Detail
appendChild(node)
Appends the specified node as a child node to this node. If the node was previously connected to a different parent node then it is first disconnected from this parent.
Parameters:
{twodee.SceneNode} node
The node to append to this node

collide(other)
Informs the node that it has collided with the specified node. Do not call this method yourself, it is called by the scene.
Parameters:
{twodee.SceneNode} other
The node this one has collided with

{boolean} collidesWith(other)
Checks if this node collides with the specified node. Do not call this method yourself, it's called by the scene.
Parameters:
{twodee.SceneNode} other
The other scene node
Returns:
{boolean} True if nodes collide, false if not

disable()
Disables the node.

enable()
Enables the node.

{twodee.Polygon} getBounds()
Returns the bounds of this node.
Returns:
{twodee.Polygon} The node bounds

{number} getCollisionMask()
Returns the collisiton bit mask of the node.
Returns:
{number} The collision bit mask

{number} getCollisionType()
Returns the collisiton type of the node. May return 0 of node is not collidable.
Returns:
{number} The collision type of the node

{twodee.SceneNode} getFirstChild()
Returns the first child node of this node. If the node has no child nodes then null is returned.
Returns:
{twodee.SceneNode} The first child node or null if there are no child nodes

{number} getId()
Returns the node id.
Returns:
{number} The node id

{twodee.SceneNode} getLastChild()
Returns the last child node of this node. If the node has no child nodes then null is returned.
Returns:
{twodee.SceneNode} The last child node or null if there are no child nodes

{twodee.SceneNode} getNextSibling()
Returns the next sibling of this node. If the node is the last child node of its parent then null is returned because there can't be a next sibling.
Returns:
{twodee.SceneNode} The next sibling of this node or null if there is no next sibling

{number} getOpacity()
Returns the current opacity of the node.
Returns:
{number} The node opacity. 1.0 = Fully solid, 0.0 = fully transparent

{twodee.SceneNode} getParentNode()
Returns the parent node. If the node has no root node yet then null is returned.
Returns:
{twodee.SceneNode} The parent node or null if there is none

{twodee.Physics} getPhysics()
Returns the physics model. May return null if node has no physics model.
Returns:
{twodee.Physics} The physics model or null if not present

{twodee.SceneNode} getPreviousSibling()
Returns the previous sibling of this node. If the node is the first child node of its parent then null is returned because there can't be a previous sibling.
Returns:
{twodee.SceneNode} The previous sibling of this node or null if there is no previous sibling

{twodee.Matrix} getTransform()
Returns the current transformation matrix.
Returns:
{twodee.Matrix} The current transformation matrix

{boolean} hasChildNodes()
Checks if this node has child nodes.
Returns:
{boolean} True if this node has child nodes, false if not

insertBefore(insertNode, referenceNode)
Inserts a new child node before the specified reference node. If the new node was already connected to a parent then it is disconnected from this parent first.
Parameters:
{twodee.SceneNode} insertNode
The new node to insert
{twodee.SceneNode} referenceNode
The reference node

{boolean} isCollidable()
Checks if the node is collidable. It is only collidable when it has a collision type and bounds set.
Returns:
{boolean} True if node is collidable, false if not

{boolean} isEnabled()
Checks if node is enabled or not.
Returns:
{boolean} True if node is enabled, false if not

processCollisions()
Finishes the collision detection. This must be called after rendering of the scene is complete. It checks which collisions are new or obsolete and sends the required signals. Don't call this method yourself, it is done by the Scene.

remove()
Removes this node from its parent.

removeChild(node)
Removes the specified child node from this node.
Parameters:
{twodee.SceneNode} node
The node to remove

removeChildren()
Removes all child nodes.

render(g, transform)
Renders the node. Default implementation does nothing.
Parameters:
{CanvasRenderingContext2D} g
The graphics context
{twodee.Matrix} transform
The effective transformation. This is already applied to the node bounds.

replaceChild(oldNode, newNode)
Replaces the specified old node with the specified new node. If the new node was already connected to a parent then it is disconnected from this parent first.
Parameters:
{twodee.SceneNode} oldNode
The old node to be replaced by the new one
{twodee.SceneNode} newNode
The new node to replace the old one

setBounds(bounds)
Sets the bounds of this node. Specify null to use no bounds.
Parameters:
{twodee.Polygon} bounds
The node bounds to set

setCollisionMask(collisionMask)
Sets the collision bit mask of the node.
Parameters:
{number} collisionMask
The collision bit mask to set.

setCollisionType(collisionType)
Sets the collision type of the node.
Parameters:
{number} collisionType
The collision type to set. 0 means that the node is not collidable at all.

setEnabled(enabled)
Enables or disables the node.
Parameters:
{boolean} enabled
True to enable the node, false to disable it

setOpacity(opacity)
Sets the opacity of the node.
Parameters:
{number} opacity
The opacity to set. 1.0 = Fully solid, 0.0 = fully transparent

setPhysics(physics)
Sets the physics model. Specify null to remove the existing physics model.
Parameters:
{twodee.Physics} physics
The physics model to set

update(delta)
Updates the node with the specified time delta. Default implementation is processing the physics model if present.
Parameters:
{number} delta
The time elapsed since the last scene update (in milliseconds)

{twodee.Matrix} updateTransformation(baseTransform)
Transforms the node according to its effective transformation (Calculated from its local transformation and the effective transformation of its parent). Do not call this method yourself. It is triggered by the scene.
Parameters:
{twodee.Matrix} baseTransform
The base transformation to apply to nodes without a parent.
Returns:
{twodee.Matrix} The calculated effetive transformation of this node

Documentation generated by JsDoc Toolkit 2.4.0 on Thu Dec 29 2011 20:19:03 GMT+0100 (CET)