| Package | sandy.core.scenegraph |
| Class | public class Sprite2D |
| Inheritance | Sprite2D ATransformable Node |
| Implements | IDisplayable |
| Subclasses | Sprite3D |
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
| Property | Defined by | ||
|---|---|---|---|
![]() | appearance : Appearance
Set that appearance to all the children of that node
| Node | |
| autoCenter : Boolean = true
When enabled, the sprite will be displayed at its graphical center.
| Sprite2D | ||
![]() | boundingBox : BBox
The bounding box of this node
IMPORTANT: Do not modify it unless you perfectly know what you are doing
| Node | |
![]() | boundingSphere : BSphere
The bounding sphere of this node
IMPORTANT: Do not modify it unless you perfectly know what you are doing
| Node | |
![]() | broadcaster : BubbleEventBroadcaster
The broadcaster
The broadcaster is used to send events to listeners. | Node | |
![]() | changed : Boolean = false
This property set the cache status of the current node.
| Node | |
| container : Sprite [read-only]
The container of this sprite ( canvas )
| Sprite2D | ||
| content : DisplayObject
The DisplayObject that will used as content of this Sprite2D.
| Sprite2D | ||
![]() | culled : CullingState
This property represent the culling state of the current node.
| Node | |
| depth : Number [read-only]
The depth to draw this sprite at.
| Sprite2D | ||
![]() | disable : Boolean = false
Disable the local transformations applied to this Node if set to false.
| ATransformable | |
![]() | enableBackFaceCulling : Boolean
Change the backface culling state to all the shapes objects in the children list
| Node | |
| enableEvents : Boolean | Sprite2D | ||
| enableForcedDepth : Boolean = false
Should forced depth be enable for this object?.
| Sprite2D | ||
![]() | enableInteractivity : Boolean
Change the interactivity of all the children
| Node | |
| fixedAngle : Boolean = false
Set this to true if you want this sprite to rotate with camera.
| Sprite2D | ||
| floorCenter : Boolean = false
When enabled, the sprite will be displayed at its bottom line.
| Sprite2D | ||
| forcedDepth : Number = 0
The forced depth for this object.
| Sprite2D | ||
| material : Material
Material that the sprite will be dressed in.
| Sprite2D | ||
![]() | matrix : Matrix4 | ATransformable | |
![]() | name : String
Name of this node.
| Node | |
![]() | out : Vector
Forward direction ( local z ) in parent coordinates.
| ATransformable | |
![]() | pan : Number
Pans this object around the local y axis.
| ATransformable | |
![]() | parent : Node
The parent node of this node.
| Node | |
![]() | roll : Number
Rolls this object around the local z axis.
| ATransformable | |
![]() | rotateX : Number
Rotates this object around an axis parallel to the parents x axis.
| ATransformable | |
![]() | rotateY : Number
Rotates this object around an axis parallel to the parents y axis.
| ATransformable | |
![]() | rotateZ : Number
Rotates this object around an axis paralell to the parents z axis.
| ATransformable | |
| scale : Number
The scale of this sprite.
| Sprite2D | ||
![]() | scaleX : Number
x scale of this object.
| ATransformable | |
![]() | scaleY : Number
y scale of this object.
| ATransformable | |
![]() | scaleZ : Number
z scale of this object.
| ATransformable | |
![]() | scene : Scene3D = null
Reference to the scene is it linked to.
| Node | |
![]() | side : Vector
Side direction ( local x ) in parent coordinates.
| ATransformable | |
![]() | target : Vector
The position in the parent frame this object should "look at".
| ATransformable | |
![]() | tilt : Number
Tilts this object around the local x axis.
| ATransformable | |
![]() | up : Vector
Up direction ( local y ) in parent coordinates.
| ATransformable | |
![]() | useSingleContainer : Boolean
Make all the Shape3D and descendants children react to this value.
| Node | |
![]() | visible : Boolean = true
Specify the visibility of this node.
| Node | |
![]() | x : Number
x position of this object in its parent frame.
| ATransformable | |
![]() | y : Number
y position of this object in its parent frame.
| ATransformable | |
![]() | z : Number
z position of the node in its parent frame.
| ATransformable | |
| Property | Defined by | ||
|---|---|---|---|
| m_nDepth : Number | Sprite2D | ||
| m_nPerspScaleX : Number = 0 | Sprite2D | ||
| m_nRotation : Number = 0 | Sprite2D | ||
| m_oContent : DisplayObject | Sprite2D | ||
![]() | m_oEB : BubbleEventBroadcaster | Node | |
| m_oMaterial : Material | Sprite2D | ||
![]() | m_oPreviousOffsetRotation : Vector | ATransformable | |
![]() | m_tmpMt : Matrix4 | ATransformable | |
| _nScale : Number | Sprite2D | ||
![]() | _oScale : Vector | ATransformable | |
![]() | _p : Vector | ATransformable | |
| _v : Vertex | Sprite2D | ||
![]() | _vOut : Vector | ATransformable | |
![]() | _vSide : Vector | ATransformable | |
![]() | _vUp : Vector | ATransformable | |
| Method | Defined by | ||
|---|---|---|---|
|
Sprite2D(p_sName:String = "", p_oContent:DisplayObject = null, p_nScale:Number = 1)
Creates a Sprite2D.
| Sprite2D | ||
![]() |
Adds a new child to this node.
| Node | |
![]() |
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 | ||
|
Tests this node against the camera frustum to get its visibility.
| Sprite2D | ||
![]() |
destroy():void
Delete this node and all its child nodes.
| Node | |
|
Displays this sprite.
| Sprite2D | ||
![]() |
getChildByName(p_sName:String, p_bRecurs:Boolean = false):Node
Returns the child node with the specified name.
| Node | |
![]() |
getPosition(p_sMode:String = "local"):Vector
Returns the position of this group or object.
| ATransformable | |
![]() |
hasParent():Boolean
Tests if this node has a parent.
| Node | |
![]() |
initFrame():void
Initiates the local coordinate system for this object.
| ATransformable | |
![]() |
Tests if the node passed in the argument is parent of this node.
| Node | |
![]() |
lookAt(p_nX:Number, p_nY:Number, p_nZ:Number):void
Makes this object "look at" the specified position in the parent frame.
| ATransformable | |
![]() |
moveForward(p_nD:Number):void
Translates this object along its forward vector ( local z ) in the parent frame.
| ATransformable | |
![]() |
moveHorizontally(p_nD:Number):void
Translates this object parallel to its parent zx plane and in its forward direction.
| ATransformable | |
![]() |
moveLateraly(p_nD:Number):void
Translates this object laterally in its parent frame.
| ATransformable | |
![]() |
moveSideways(p_nD:Number):void
Translates this object along its side vector ( local x ) in the parent frame.
| ATransformable | |
![]() |
moveUpwards(p_nD:Number):void
Translates this object along its up vector ( local y ) in the parent frame.
| ATransformable | |
![]() |
moveVertically(p_nD:Number):void
Translates this object vertically in ots parent frame.
| ATransformable | |
![]() |
perform(p_iOperation:INodeOperation):void
Performs an operation on this node and all of its children.
| Node | |
|
remove():void
Provide the classical remove behaviour, plus remove the container to the display list.
| Sprite2D | ||
![]() |
removeChildByName(p_sName:String):Boolean
Removes the child node with the specified name.
| Node | |
![]() |
removeEventListener(p_sEvt:String, p_oL:*):void
Removes a listener for the specified event.
| Node | |
|
Renders this 2D sprite
| Sprite2D | ||
![]() |
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 | ||
![]() |
setPosition(p_nX:Number, p_nY:Number, p_nZ:Number):void
Sets the position of this object in coordinates of its parent frame.
| ATransformable | |
![]() |
swapParent(p_oNewParent:Node):void
Moves this node to another parent node.
| Node | |
|
toString():String
| Sprite2D | ||
![]() |
translate(p_nX:Number, p_nY:Number, p_nZ:Number):void
Translate this object from it's current position with the specified offsets.
| ATransformable | |
![]() |
Updates this node or object.
| ATransformable | |
![]() |
updateTransform():void
Updates the transform matrix of the current object/node before it is rendered.
| ATransformable | |
| Method | Defined by | ||
|---|---|---|---|
|
_onInteraction(p_oEvt:Event):void
| Sprite2D | ||
| autoCenter | property |
public var autoCenter:Boolean = trueWhen enabled, the sprite will be displayed at its graphical center. Otherwise the sprite positioning is controlled by floorCenter property.
| container | property |
container:Sprite [read-only]The container of this sprite ( canvas )
Implementation public function get container():Sprite
| content | property |
content:DisplayObject [read-write]The DisplayObject that will used as content of this Sprite2D. If this DisplayObject has already a screen position, it will be reseted to 0,0. If the DisplayObject has allready a parent, it will be unrelated from it automatically. (its transform matrix property is resetted to identity too).
Implementation public function get content():DisplayObject
public function set content(value:DisplayObject):void
| depth | property |
depth:Number [read-only]The depth to draw this sprite at.
[ToDo: Explain ]
Implementation public function get depth():Number
| enableEvents | property |
enableEvents:Boolean [read-write]Implementation
public function get enableEvents():Boolean
public function set enableEvents(value:Boolean):void
| enableForcedDepth | property |
public var enableForcedDepth:Boolean = falseShould forced depth be enable for this object?.
If true it is possible to force this object to be drawn at a specific depth,
if false the normal Z-sorting algorithm is applied.
When correctly used, this feature allows you to avoid some Z-sorting problems.
| fixedAngle | property |
public var fixedAngle:Boolean = falseSet this to true if you want this sprite to rotate with camera.
| floorCenter | property |
public var floorCenter:Boolean = falseWhen enabled, the sprite will be displayed at its bottom line. Otherwise it is positioned at its registration point (usually top left corner). This property has no effect when autoCenter is enabled.
| forcedDepth | property |
public var forcedDepth:Number = 0The forced depth for this object.
To make this feature work, you must enable the ForcedDepth system too.
The higher the depth is, the sooner the more far the object will be represented.
| material | property |
material:Material [read-write]Material that the sprite will be dressed in. Use it to apply some attributes to sprite, such as light attributes.
Implementation public function get material():Material
public function set material(value:Material):void
| m_nDepth | property |
protected var m_nDepth:Number
| m_nPerspScaleX | property |
protected var m_nPerspScaleX:Number = 0
| m_nRotation | property |
protected var m_nRotation:Number = 0
| m_oContent | property |
protected var m_oContent:DisplayObject
| m_oMaterial | property |
protected var m_oMaterial:Material
| _nScale | property |
protected var _nScale:Number
| scale | property |
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
| _v | property |
protected var _v:Vertex
| Sprite2D | () | constructor |
public function Sprite2D(p_sName:String = "", p_oContent:DisplayObject = null, p_nScale:Number = 1)Creates a Sprite2D.
Parametersp_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 double object size.
A value of 0 will force original graphics size independent of distance.
|
| _onInteraction | () | method |
protected function _onInteraction(p_oEvt:Event):voidParameters
p_oEvt:Event |
| clear | () | method |
public function clear():voidClears 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):voidTests 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!
Parametersp_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):voidDisplays 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.
Parametersp_oScene:Scene3D — The current scene
|
|
p_oContainer:Sprite (default = null) — The container to draw on
|
| remove | () | method |
public override function remove():voidProvide the classical remove behaviour, plus remove the container to the display list.
| render | () | method |
public override function render(p_oScene:Scene3D, p_oCamera:Camera3D):voidRenders this 2D sprite
Parametersp_oScene:Scene3D — The current scene
|
|
p_oCamera:Camera3D — The current camera
|
| setBoundingSphereRadius | () | method |
public function setBoundingSphereRadius(p_nRadius:Number):voidSets the radius of bounding sphere for this sprite.
Parametersp_nRadius:Number — The radius
|
| toString | () | method |
public override function toString():String
Returns
String |