Packagesandy.core.scenegraph
Classpublic class Sprite2D
InheritanceSprite2D Inheritance ATransformable Inheritance Node
ImplementsIDisplayable

The Sprite2D class is use to create a 2D sprite.

A Sprite2D object is used to display a static or dynamic texture in the Sandy world.
The sprite always shows the same side to the camera. This is useful when you want to show more or less complex images, without heavy calculations of perspective distortion.

The Sprite2D has a fixed bounding sphere radius, set by default to 30.
In case your sprite is bigger, you can adjust it to avoid any frustum culling issue



Public Properties
 PropertyDefined by
  autoCenter : Boolean = true
When enabled, the sprite will be displayed at its graphical center.
Sprite2D
 InheritedboundingBox : BBox
The bounding box of this node IMPORTANT: Do not modify it unless you perfectly know what you are doing
Node
 InheritedboundingSphere : BSphere
The bounding sphere of this node IMPORTANT: Do not modify it unless you perfectly know what you are doing
Node
 Inheritedbroadcaster : BubbleEventBroadcaster
The broadcaster

The broadcaster is used to send events to listeners.
This property is a BubbleEventBroadcaster.

Node
 Inheritedchanged : Boolean = false
This property set the cache status of the current node.
Node
 Inheritedchildren : Array
The children of this node are stored inside this array.
Node
  container : Sprite
[read-only] The container of this sprite ( canvas )
Sprite2D
  content : DisplayObject
Get the content DisplayObject reference
Sprite2D
 Inheritedculled : CullingState
This property represent the culling state of the current node.
Node
  depth : Number
[read-only] The depth to draw this sprite at.
Sprite2D
 Inheriteddisable : Boolean = false
Disable the local transformations applied to this Node if set to false.
ATransformable
 Inheritedmatrix : Matrix4
ATransformable
 InheritedmodelMatrix : Matrix4
Cached matrix corresponding to the transformation to the 0,0,0 frame system
Node
 Inheritedname : String
Name of this node.
Node
 Inheritedout : Vector
Forward direction ( local z ) in parent coordinates.
ATransformable
 Inheritedpan : Number
Pans this object around the local y axis.
ATransformable
 Inheritedparent : Node
The parent node of this node.
Node
 Inheritedroll : Number
Rolls this object around the local z axis.
ATransformable
 InheritedrotateX : Number
Rotates this object around an axis parallel to the parents x axis.
ATransformable
 InheritedrotateY : Number
Rotates this object around an axis parallel to the parents y axis.
ATransformable
 InheritedrotateZ : Number
Rotates this object around an axis paralell to the parents z axis.
ATransformable
  scale : Number
The scale of this sprite.
Sprite2D
 InheritedscaleX : Number
x scale of this object.
ATransformable
 InheritedscaleY : Number
y scale of this object.
ATransformable
 InheritedscaleZ : Number
z scale of this object.
ATransformable
 Inheritedscene : Scene3D = null
Reference to the scene is it linked to.
Node
 Inheritedside : Vector
Side direction ( local x ) in parent coordinates.
ATransformable
 Inheritedtarget : Vector
The position in the parent frame this object should "look at".
ATransformable
 Inheritedtilt : Number
Getter for the tilt value
ATransformable
 Inheritedup : Vector
Up direction ( local y ) in parent coordinates.
ATransformable
 InheritedviewMatrix : Matrix4
Cached matrix corresponding to the transformation to the camera frame system
Node
 Inheritedvisible : Boolean = true
Specify the visibility of this node.
Node
 Inheritedx : Number
x position of this object in its parent frame.
ATransformable
 Inheritedy : Number
y position of this object in its parent frame.
ATransformable
 Inheritedz : Number
z position of the node in its parent frame.
ATransformable
Protected Properties
 PropertyDefined by
 Inheritedm_oEB : BubbleEventBroadcaster
Node
 Inheritedm_oPreviousOffsetRotation : Vector
ATransformable
 Inheritedm_tmpMt : Matrix4
ATransformable
 Inherited_oScale : Vector
ATransformable
 Inherited_p : Vector
ATransformable
  _v : Vertex
Sprite2D
 Inherited_vOut : Vector
ATransformable
 Inherited_vSide : Vector
ATransformable
 Inherited_vUp : Vector
ATransformable
Public Methods
 MethodDefined by
  
Sprite2D(p_sName:String = "", p_oContent:DisplayObject = null, p_nScale:Number = 1)
Creates a Sprite2D.
Sprite2D
 Inherited
addChild(p_oChild:Node):void
Adds a new child to this node.
Node
 Inherited
addEventListener(p_sEvt:String, p_oL:*):void
Adds a listener for the specified event.
Node
  
clear():void
Clears the graphics object of this object's container.
Sprite2D
  
cull(p_oScene:Scene3D, p_oFrustum:Frustum, p_oViewMatrix:Matrix4, p_bChanged:Boolean):void
Tests this node against the camera frustum to get its visibility.
Sprite2D
 Inherited
destroy():void
Delete this node and all its child nodes.
Node
  
display(p_oScene:Scene3D, p_oContainer:Sprite = null):void
Displays this sprite.
Sprite2D
 Inherited
getChildByName(p_sName:String, p_bRecurs:Boolean = false):Node
Returns the child node with the specified name.
Node
 Inherited
getChildFromId(p_nId:uint, p_bRecurs:Boolean = false):Node
Returns the child node with the specified id.
Node
 Inherited
getChildList():Array
Returns an array with all child nodes of this node.
Node
 Inherited
getPosition(p_sMode:String = "local"):Vector
Returns the position of this group or object.
ATransformable
 Inherited
hasParent():Boolean
Tests if this node has a parent.
Node
 Inherited
initFrame():void
Initiates the local coordinate system for this object.
ATransformable
 Inherited
isParent(p_oNode:Node):Boolean
Tests if the node passed in the argument is parent of this node.
Node
 Inherited
lookAt(p_nX:Number, p_nY:Number, p_nZ:Number):void
Makes this object "look at" the specified position in the parent frame.
ATransformable
 Inherited
moveForward(p_nD:Number):void
Translates this object along its forward vector ( local z ) in the parent frame.
ATransformable
 Inherited
moveHorizontally(p_nD:Number):void
Translates this object parallel to its parent zx plane and in its forward direction.
ATransformable
 Inherited
moveLateraly(p_nD:Number):void
Translates this object laterally in its parent frame.
ATransformable
 Inherited
moveSideways(p_nD:Number):void
Translates this object along its side vector ( local x ) in the parent frame.
ATransformable
 Inherited
moveUpwards(p_nD:Number):void
Translates this object along its up vector ( local y ) in the parent frame.
ATransformable
 Inherited
moveVertically(p_nD:Number):void
Translates this object vertically in ots parent frame.
ATransformable
  
remove():void
Provide the classical remove behaviour, plus remove the container to the display list.
Sprite2D
 Inherited
removeChildById(p_nId:Number):Boolean
Removes the child node with the specified id.
Node
 Inherited
removeChildByName(p_sName:String):Boolean
Removes the child node with the specified name.
Node
 Inherited
removeEventListener(p_sEvt:String, p_oL:*):void
Removes a listener for the specified event.
Node
  
render(p_oScene:Scene3D, p_oCamera:Camera3D):void
Renders this 2D sprite
Sprite2D
 Inherited
rotateAxis(p_nX:Number, p_nY:Number, p_nZ:Number, p_nAngle:Number):void
Rotate this object around the specified axis in the parent frame by the specified angle.
ATransformable
  
setBoundingSphereRadius(p_nRadius:Number):void
Sets the radius of bounding sphere for this sprite.
Sprite2D
 Inherited
setPosition(p_nX:Number, p_nY:Number, p_nZ:Number):void
Sets the position of this object in coordinates of its parent frame.
ATransformable
 Inherited
swapParent(p_oNewParent:Node):void
Moves this node to another parent node.
Node
 Inherited
toString():String
Returns a string representation of this object
ATransformable
 Inherited
translate(p_nX:Number, p_nY:Number, p_nZ:Number):void
Translate this object from it's current position with the specified offsets.
ATransformable
 Inherited
update(p_oScene:Scene3D, p_oModelMatrix:Matrix4, p_bChanged:Boolean):void
Updates this node or object.
ATransformable
 Inherited
Updates the transform matrix of the current object/node before it is rendered.
ATransformable
Public Constants
 ConstantDefined by
 Inheritedid : uint
The unique id of this node in the node graph.
Node
Property detail
autoCenterproperty
public var autoCenter:Boolean = true

When enabled, the sprite will be displayed at its graphical center. Otherwise its top left corner will be set at the computed screen position

containerproperty 
container:Sprite  [read-only]

The container of this sprite ( canvas )

Implementation
    public function get container():Sprite
contentproperty 
content:DisplayObject  [read-write]

Get the content DisplayObject reference

Implementation
    public function get content():DisplayObject
    public function set content(value:DisplayObject):void
depthproperty 
depth:Number  [read-only]

The depth to draw this sprite at.

[ToDo: Explain ]

Implementation
    public function get depth():Number
scaleproperty 
scale:Number  [read-write]

The scale of this sprite.

Using scale, you can change the dimension of the sprite rapidly.

Implementation
    public function get scale():Number
    public function set scale(value:Number):void
_vproperty 
protected var _v:Vertex
Constructor detail
Sprite2D()constructor
public function Sprite2D(p_sName:String = "", p_oContent:DisplayObject = null, p_nScale:Number = 1)

Creates a Sprite2D.

Parameters
p_sName:String (default = "") — A string identifier for this object
 
p_oContent:DisplayObject (default = null) — The container containing all the pre-rendered picture
 
p_nScale:Number (default = 1) — A number used to change the scale of the displayed object. In case that the object projected dimension isn't adapted to your needs. Default value is 1.0 which means unchanged. A value of 2.0 will make the object will double the size
Method detail
clear()method
public function clear():void

Clears the graphics object of this object's container.

The the graphics that were drawn on the Graphics object is erased, and the fill and line style settings are reset.

cull()method 
public override function cull(p_oScene:Scene3D, p_oFrustum:Frustum, p_oViewMatrix:Matrix4, p_bChanged:Boolean):void

Tests this node against the camera frustum to get its visibility.

If this node and its children are not within the frustum, the node is set to cull and it would not be displayed.

The method also updates the bounding volumes to make the more accurate culling system possible.
First the bounding sphere is updated, and if intersecting, the bounding box is updated to perform the more precise culling.

[MANDATORY] The update method must be called first!

Parameters
p_oScene:Scene3D — The current scene
 
p_oFrustum:Frustum — The frustum of the current camera
 
p_oViewMatrix:Matrix4 — The view martix of the curren camera
 
p_bChanged:Boolean
display()method 
public function display(p_oScene:Scene3D, p_oContainer:Sprite = null):void

Displays this sprite.

display the object onto the scene. If the object has autocenter enabled, sprite center is set at screen position. Otherwise the sprite top left corner will be at that position.

Parameters
p_oScene:Scene3D — The current scene
 
p_oContainer:Sprite (default = null) — The container to draw on
remove()method 
public override function remove():void

Provide the classical remove behaviour, plus remove the container to the display list.

render()method 
public override function render(p_oScene:Scene3D, p_oCamera:Camera3D):void

Renders this 2D sprite

Parameters
p_oScene:Scene3D — The current scene
 
p_oCamera:Camera3D — The current camera
setBoundingSphereRadius()method 
public function setBoundingSphereRadius(p_nRadius:Number):void

Sets the radius of bounding sphere for this sprite.

Parameters
p_nRadius:Number — The radius