Packagecom.pblabs.rendering2D
Classpublic class DisplayObjectRenderer
InheritanceDisplayObjectRenderer Inheritance AnimatedComponent Inheritance EntityComponent Inheritance Object
Subclasses BitmapRenderer, Box2DDebugComponent, MovieClipRenderer, SimpleShapeRenderer

Base renderer for Rendering2D. It wraps a DisplayObject, allows it to be controlled by PropertyReferences, and hooks it into a scene.

The various other renderers inherit from DisplayObjectRenderer, and rely on it for basic functionality.

Normally, the DisplayObjectRenderer tries to update itself every frame. However, you can suppress this by setting registerForUpdates to false, in which case you will have to call onFrame()/updateTransform() manually if you change something.

See also

BitmapRenderer
SpriteSheetRenderer
MovieClipRenderer


Public Properties
 PropertyDefined By
  alpha : Number
Transparency, 0 being completely transparent and 1 being opaque.
DisplayObjectRenderer
  alphaProperty : PropertyReference
If set, alpha is gotten from this property every frame.
DisplayObjectRenderer
  blendMode : String
Blend mode, using strings from flash.display.BlendMode
DisplayObjectRenderer
  blendModeProperty : PropertyReference
If set, blend mode is gotten from this property every frame.
DisplayObjectRenderer
  displayObject : DisplayObject
The displayObject which this DisplayObjectRenderer will draw.
DisplayObjectRenderer
 InheritedisRegistered : Boolean
[read-only] Whether or not the component is currently registered with an entity.
EntityComponent
  layerIndex : int
In what layer of the scene is this renderer drawn?
DisplayObjectRenderer
  layerIndexProperty : PropertyReference
If set, the layer index is gotten from this property every frame.
DisplayObjectRenderer
  localBounds : Rectangle
[read-only]
DisplayObjectRenderer
 Inheritedname : String
[read-only] The name given to the component when it is added to an entity.
EntityComponent
  objectMask : ObjectType
The types for this object; used for picking queries primarily.
DisplayObjectRenderer
 Inheritedowner : IEntity
A reference to the entity that this component currently belongs to.
EntityComponent
  position : Point
Position of the renderer in scene space.
DisplayObjectRenderer
  positionOffset : Point
Sets a position offset that will offset the sprite.
DisplayObjectRenderer
  positionProperty : PropertyReference
If set, position is gotten from this property every frame.
DisplayObjectRenderer
 InheritedregisterForUpdates : Boolean
Set to register/unregister for frame updates.
AnimatedComponent
  registrationPoint : Point
The registration point can be used to offset the sprite so that rotation and scaling work properly.
DisplayObjectRenderer
  registrationPointProperty : PropertyReference
If set, our registration point is gotten from this property every frame.
DisplayObjectRenderer
  renderKey : int = 0
Reference value used for sorting in some scenes.
DisplayObjectRenderer
  renderPosition : Point
[read-only] Where in the scene will this object be rendered?
DisplayObjectRenderer
  rotation : Number
Rotation in degrees, with 0 being Y+.
DisplayObjectRenderer
  rotationOffset : Number
Rotation offset applied to the child DisplayObject.
DisplayObjectRenderer
  rotationProperty : PropertyReference
If set, rotation is gotten from this property every frame.
DisplayObjectRenderer
  scale : Point
You can scale things on the X and Y axes.
DisplayObjectRenderer
  scaleProperty : PropertyReference
If set, scale is gotten from this property every frame.
DisplayObjectRenderer
  scene : IScene2D
The scene which is responsible for drawing this renderer.
DisplayObjectRenderer
  sceneBounds : Rectangle
[read-only] Our bounds in scene coordinates.
DisplayObjectRenderer
  size : Point
Explicitly set the size.
DisplayObjectRenderer
  sizeProperty : PropertyReference
If set, size is determined by this property every frame.
DisplayObjectRenderer
  snapToNearestPixels : Boolean = true
if set this to false, positions will be handeled with numbers insteed of integers makes slow movement smoother for example
DisplayObjectRenderer
 InheritedupdatePriority : Number = 0.0
The update priority for this component.
AnimatedComponent
  worldPosition : Point
Convenience method to allow placing the renderer in world coordinates.
DisplayObjectRenderer
  x : Number
The x value of our scene space position.
DisplayObjectRenderer
  y : Number
The y component of our scene space position.
DisplayObjectRenderer
  zIndex : int
By default, layers are sorted based on the z-index, from small to large.
DisplayObjectRenderer
  zIndexProperty : PropertyReference
If set, our z-index is gotten from this property every frame.
DisplayObjectRenderer
Protected Properties
 PropertyDefined By
  _alpha : Number = 1
DisplayObjectRenderer
  _blendMode : String = normal
DisplayObjectRenderer
  _displayObject : DisplayObject
DisplayObjectRenderer
  _hitTestDirty : Boolean = true
DisplayObjectRenderer
  _inScene : Boolean = false
DisplayObjectRenderer
  _lastLayerIndex : int = -1
DisplayObjectRenderer
  _layerIndex : int = 0
DisplayObjectRenderer
  _layerIndexDirty : Boolean = true
DisplayObjectRenderer
  _position : Point
DisplayObjectRenderer
  _positionOffset : Point
DisplayObjectRenderer
  _registrationPoint : Point
DisplayObjectRenderer
  _rotation : Number = 0
DisplayObjectRenderer
  _rotationOffset : Number = 0
DisplayObjectRenderer
  _scale : Point
DisplayObjectRenderer
  _scene : IScene2D
DisplayObjectRenderer
  _size : Point
DisplayObjectRenderer
  _transformDirty : Boolean = true
DisplayObjectRenderer
  _transformMatrix : Matrix
DisplayObjectRenderer
  _zIndex : int = 0
DisplayObjectRenderer
  _zIndexDirty : Boolean = true
DisplayObjectRenderer
Public Methods
 MethodDefined By
  
DisplayObjectRenderer
  
onFrame(elapsed:Number):void
[override]
DisplayObjectRenderer
  
pointOccupied(worldPosition:Point, mask:ObjectType):Boolean
Is the rendered object opaque at the request position in screen space?
DisplayObjectRenderer
 Inherited
register(owner:IEntity, name:String):void
Registers the component with an entity.
EntityComponent
 Inherited
reset():void
This is called by an entity on all of its components any time a component is added or removed.
EntityComponent
  
transformObjectToWorld(p:Point):Point
Transform a point from object space to world space.
DisplayObjectRenderer
  
transformWorldToObject(p:Point):Point
Transform a point from world space to object space.
DisplayObjectRenderer
 Inherited
unregister():void
Unregisters the component from an entity.
EntityComponent
  
updateTransform(updateProps:Boolean = false):void
Update the object's transform based on its current state.
DisplayObjectRenderer
Protected Methods
 MethodDefined By
  
addToScene():void
DisplayObjectRenderer
  
onAdd():void
[override]
DisplayObjectRenderer
  
onRemove():void
[override]
DisplayObjectRenderer
 Inherited
onReset():void
This is called anytime a component is added or removed from the owner entity.
EntityComponent
  
DisplayObjectRenderer
  
DisplayObjectRenderer
Property Detail
_alphaproperty
protected var _alpha:Number = 1

_blendModeproperty 
protected var _blendMode:String = normal

_displayObjectproperty 
protected var _displayObject:DisplayObject

_hitTestDirtyproperty 
protected var _hitTestDirty:Boolean = true

_inSceneproperty 
protected var _inScene:Boolean = false

_lastLayerIndexproperty 
protected var _lastLayerIndex:int = -1

_layerIndexproperty 
protected var _layerIndex:int = 0

_layerIndexDirtyproperty 
protected var _layerIndexDirty:Boolean = true

_positionproperty 
protected var _position:Point

_positionOffsetproperty 
protected var _positionOffset:Point

_registrationPointproperty 
protected var _registrationPoint:Point

_rotationproperty 
protected var _rotation:Number = 0

_rotationOffsetproperty 
protected var _rotationOffset:Number = 0

_scaleproperty 
protected var _scale:Point

_sceneproperty 
protected var _scene:IScene2D

_sizeproperty 
protected var _size:Point

_transformDirtyproperty 
protected var _transformDirty:Boolean = true

_transformMatrixproperty 
protected var _transformMatrix:Matrix

_zIndexproperty 
protected var _zIndex:int = 0

_zIndexDirtyproperty 
protected var _zIndexDirty:Boolean = true

alphaproperty 
alpha:Number

Transparency, 0 being completely transparent and 1 being opaque.


Implementation
    public function get alpha():Number
    public function set alpha(value:Number):void
alphaPropertyproperty 
public var alphaProperty:PropertyReference

If set, alpha is gotten from this property every frame.

blendModeproperty 
blendMode:String

Blend mode, using strings from flash.display.BlendMode


Implementation
    public function get blendMode():String
    public function set blendMode(value:String):void

See also

flash.display.BlendMode
blendModePropertyproperty 
public var blendModeProperty:PropertyReference

If set, blend mode is gotten from this property every frame.

displayObjectproperty 
displayObject:DisplayObject

The displayObject which this DisplayObjectRenderer will draw.


Implementation
    public function get displayObject():DisplayObject
    public function set displayObject(value:DisplayObject):void
layerIndexproperty 
layerIndex:int

In what layer of the scene is this renderer drawn?


Implementation
    public function get layerIndex():int
    public function set layerIndex(value:int):void
layerIndexPropertyproperty 
public var layerIndexProperty:PropertyReference

If set, the layer index is gotten from this property every frame.

localBoundsproperty 
localBounds:Rectangle  [read-only]


Implementation
    public function get localBounds():Rectangle
objectMaskproperty 
public var objectMask:ObjectType

The types for this object; used for picking queries primarily.

positionproperty 
position:Point

Position of the renderer in scene space.


Implementation
    public function get position():Point
    public function set position(value:Point):void

See also

worldPosition
positionOffsetproperty 
positionOffset:Point

Sets a position offset that will offset the sprite. Please note: This is unaffected by rotation.


Implementation
    public function get positionOffset():Point
    public function set positionOffset(value:Point):void
positionPropertyproperty 
public var positionProperty:PropertyReference

If set, position is gotten from this property every frame.

registrationPointproperty 
registrationPoint:Point

The registration point can be used to offset the sprite so that rotation and scaling work properly.


Implementation
    public function get registrationPoint():Point
    public function set registrationPoint(value:Point):void
registrationPointPropertyproperty 
public var registrationPointProperty:PropertyReference

If set, our registration point is gotten from this property every frame.

Note that some subclasses override this; for instance, the SpriteSheetRenderer always uses the registrationPoint from the sprite sheet it is rendering.

renderKeyproperty 
public var renderKey:int = 0

Reference value used for sorting in some scenes.

renderPositionproperty 
renderPosition:Point  [read-only]

Where in the scene will this object be rendered?


Implementation
    public function get renderPosition():Point
rotationproperty 
rotation:Number

Rotation in degrees, with 0 being Y+.


Implementation
    public function get rotation():Number
    public function set rotation(value:Number):void
rotationOffsetproperty 
rotationOffset:Number

Rotation offset applied to the child DisplayObject. Used if, for instance, your art is rotated 90deg off from where you want it.


Implementation
    public function get rotationOffset():Number
    public function set rotationOffset(value:Number):void
rotationPropertyproperty 
public var rotationProperty:PropertyReference

If set, rotation is gotten from this property every frame.

scaleproperty 
scale:Point

You can scale things on the X and Y axes.


Implementation
    public function get scale():Point
    public function set scale(value:Point):void
scalePropertyproperty 
public var scaleProperty:PropertyReference

If set, scale is gotten from this property every frame.

sceneproperty 
scene:IScene2D

The scene which is responsible for drawing this renderer. Note that you can use the renderer outside of a scene, to control some DisplayObject, by setting displayObject to point to what you want to control, and setting scene to null.


Implementation
    public function get scene():IScene2D
    public function set scene(value:IScene2D):void
sceneBoundsproperty 
sceneBounds:Rectangle  [read-only]

Our bounds in scene coordinates.


Implementation
    public function get sceneBounds():Rectangle
sizeproperty 
size:Point

Explicitly set the size. This overrides scale if it is set.


Implementation
    public function get size():Point
    public function set size(value:Point):void
sizePropertyproperty 
public var sizeProperty:PropertyReference

If set, size is determined by this property every frame.

snapToNearestPixelsproperty 
public var snapToNearestPixels:Boolean = true

if set this to false, positions will be handeled with numbers insteed of integers makes slow movement smoother for example

worldPositionproperty 
worldPosition:Point

Convenience method to allow placing the renderer in world coordinates.


Implementation
    public function get worldPosition():Point
    public function set worldPosition(value:Point):void
xproperty 
x:Number

The x value of our scene space position.


Implementation
    public function get x():Number
    public function set x(value:Number):void
yproperty 
y:Number

The y component of our scene space position. Used for sorting.


Implementation
    public function get y():Number
    public function set y(value:Number):void
zIndexproperty 
zIndex:int

By default, layers are sorted based on the z-index, from small to large.


Implementation
    public function get zIndex():int
    public function set zIndex(value:int):void
zIndexPropertyproperty 
public var zIndexProperty:PropertyReference

If set, our z-index is gotten from this property every frame.

Constructor Detail
DisplayObjectRenderer()Constructor
public function DisplayObjectRenderer()



Method Detail
addToScene()method
protected function addToScene():void

onAdd()method 
override protected function onAdd():void

onFrame()method 
override public function onFrame(elapsed:Number):void

Parameters

elapsed:Number

onRemove()method 
override protected function onRemove():void

pointOccupied()method 
public function pointOccupied(worldPosition:Point, mask:ObjectType):Boolean

Is the rendered object opaque at the request position in screen space?

Parameters

worldPosition:Point — Location in world space we are curious about.
 
mask:ObjectType

Returns
Boolean — True if object is opaque there.
removeFromScene()method 
protected function removeFromScene():void

transformObjectToWorld()method 
public function transformObjectToWorld(p:Point):Point

Transform a point from object space to world space.

Parameters

p:Point

Returns
Point
transformWorldToObject()method 
public function transformWorldToObject(p:Point):Point

Transform a point from world space to object space.

Parameters

p:Point

Returns
Point
updateProperties()method 
protected function updateProperties():void

updateTransform()method 
public function updateTransform(updateProps:Boolean = false):void

Update the object's transform based on its current state. Normally called automatically, but in some cases you might have to force it to update immediately.

Parameters

updateProps:Boolean (default = false) — Read fresh values from any mapped properties.