Packageverlocity.ents
Classpublic class DynamicEntity
InheritanceDynamicEntity Inheritance Entity Inheritance Object
Subclasses DisplayEntity

All moving entities rely on this dynamic entity base for its position. It handles collision, physics, boudaries, and sound.



Public Properties
 PropertyDefined By
  absX : Number
[read-only] Returns the absolute X position.
DynamicEntity
  absY : Number
[read-only] Returns the absolute Y position.
DynamicEntity
  baseClass : Object
[override] [read-only] Returns the entity base class.
DynamicEntity
  collisionRect : CRectangle
[read-only] Returns the collision rect
DynamicEntity
 InheriteddefaultHealth : int
[read-only] A getter that returns the default health the entity has.
Entity
 Inherited_display : Boolean
[read-only] Returns if this entity base contains display functionality (will not Init until spawned).
Entity
  _dynamic : Boolean
[override] [read-only] Returns if the entity is dynamic.
DynamicEntity
 Inheritedhealth : int
[read-only] A getter that returns the current health value of the entity.
Entity
 Inherited_id : int
Returns the registration ID of the entity.
Entity
  initX : Number
[read-only] A getter that returns the initial X position.
DynamicEntity
  initY : Number
[read-only] A getter that returns the initial Y position.
DynamicEntity
 InheritedmaxHealth : int
A getter that returns the maximum health this entity can have.
Entity
  phys : PhysObject
[read-only] Returns the physics object (short-hand).
DynamicEntity
  x : Number
Returns the current calculated x position of this entity
DynamicEntity
  y : Number
Returns the current calculated y position of this entity
DynamicEntity
Protected Properties
 PropertyDefined By
  bCollisionEnabled : Boolean
DynamicEntity
  iBoundPadding : int = 100
DynamicEntity
  iCollisionFlags : int
DynamicEntity
  iRemoveOffScreenPadding : int = 100
DynamicEntity
  nInitialX : Number
DynamicEntity
  nInitialY : Number
DynamicEntity
  nPosX : Number
DynamicEntity
  nPosY : Number
DynamicEntity
  rectBounds : Rectangle
DynamicEntity
  rectCollision : CRectangle
DynamicEntity
Public Methods
 MethodDefined By
  
_Dispose():void
[override] Cleans the entity's data.
DynamicEntity
  
_Update():void
[override] Called each engine tick, do not override this.
DynamicEntity
  
Clears the boundaries of the entity.
DynamicEntity
 Inherited
Construct():void
Called before the entity is spawned to setup the constants of the entity.
Entity
 Inherited
DeInit():void
Called when the entity is deleted.
Entity
  
EmitSound(sSound:*, nStartVolume:Number = 1, bLoops:Boolean = false, bParent:Boolean = false, bFadeIn:Boolean = false):void
Plays a sound at the location of the entity.
DynamicEntity
  
EnableCollision(bEnable:Boolean = true):void
Enables/disables calculations for collision.
DynamicEntity
  
EnablePhysics(bEnable:Boolean = true, bRemovePhysicsObj:Boolean = true):void
Enables/disables calculations for physics.
DynamicEntity
 Inherited
EnableUpdate(bUpdate:Boolean = true):void
Sets if the entity will update each engine tick.
Entity
 Inherited
GetClass():Object
Returns the class of the entity.
Entity
  
Returns the rotation (0-360) from the relation of the mouse and the entity.
DynamicEntity
 Inherited
GetOwner():Object
Returns the current owner of the entity.
Entity
  
Returns the physics object
DynamicEntity
  
GetPos():Point
Returns the current position as a point
DynamicEntity
 Inherited
GetType():String
Returns the current string type of the entity.
Entity
  
HasMoved():Boolean
Returns if the entity has moved (determined by its previous position set) This is used to optimize collision and physics calculations
DynamicEntity
 Inherited
Init():void
Called when the entity is first registered/spawned.
Entity
 Inherited
Is(cClass:Class):Boolean
Returns if the entity matches a class.
Entity
  
Returns the method of basic collision between other types
DynamicEntity
  
Returns if collision is enabled
DynamicEntity
  
IsCollisionFlagOn(iCollisionFlag:int):Boolean
Returns if a collision flag is enabled or not.
DynamicEntity
 Inherited
IsDead():Boolean
Returns if the entity is dead.
Entity
 Inherited
IsHealthZero():Boolean
Returns if the health is zero.
Entity
  
DynamicEntity
  
IsOnBoundary():Boolean
DynamicEntity
  
DynamicEntity
  
DynamicEntity
  
IsOnScreen():Boolean
Returns if the entity is within the boundaries of the screen.
DynamicEntity
  
IsOnTopBoundary():Boolean
DynamicEntity
  
IsOnXBoundary():Boolean
DynamicEntity
  
IsOnYBoundary():Boolean
DynamicEntity
  
Returns if physics is enabled
DynamicEntity
 Inherited
IsProtected():Boolean
Returns if the entity is protected.
Entity
 Inherited
IsT(sCheckType:String):Boolean
Returns if the entity is matches a type (lowercase only).
Entity
 Inherited
IsUpdating():Boolean
Returns if the entity is updating.
Entity
  
OnCollide(ent:*):void
Called when a rectangle collision occured
DynamicEntity
 Inherited
Remove():void
Marks the entity for removal.
Entity
 Inherited
Removes all health of the entity.
Entity
  
RemoveOffScreen(bShouldRemove:Boolean = true, iPadding:int = 100):void
Tells the entity to remove itself when its off screen.
DynamicEntity
  
Reset():void
[override] Resets the entity to its original values.
DynamicEntity
 Inherited
Resets the entity's health to the default health.
Entity
  
ResetPos():void
Resets the entity to its initial position.
DynamicEntity
  
SetBounds(rectSetBounds:Rectangle, iInnerPadding:int = 0):void
Sets the screen boundaries of the entity.
DynamicEntity
  
SetCollisionFlags(iFlags:int):void
Set collision flags.
DynamicEntity
  
SetCollisionRect(rect:Rectangle, nOffsetX:Number = 0, nOffsetY:Number = 0):void
Sets the collision rect (required for collision)
DynamicEntity
 Inherited
SetDefaultHealth(setHealth:int = 100):void
Sets the default health of this entity.
Entity
 Inherited
SetHealth(newHealth:int):void
Sets the health value of this entity.
Entity
 Inherited
SetOwner(newOwner:Object):void
Sets the owner of the entity.
Entity
  
SetPhysicsProperties(nMass:Number, pVelocityDirection:Point, nVelocityMagnitude:Number):void
Sets the physicial properies of this entity
DynamicEntity
  
SetPos(nSetPosX:Number, nSetPosY:Number):void
Sets the X and Y position of the entity
DynamicEntity
 Inherited
SetProtected(bProtected:Boolean = true):void
Protects an entity from being removed by clean up calls, such as CleanSlate.
Entity
 Inherited
SetType(sSetType:String):void
Sets the string type of the entity.
Entity
  
Stops all sounds that are emitting from this entity.
DynamicEntity
 Inherited
TakeDamage(iDamageAmount:int):void
Subtracts the current health.
Entity
 Inherited
Update():void
Called each engine tick.
Entity
Protected Methods
 MethodDefined By
  
CalcXBoundaries(nSetPosX:Number):void
Calculates if a position is beyond the Y boundaries
DynamicEntity
  
CalcYBoundaries(nSetPosY:Number):void
Calculates if a position is beyond the Y boundaries
DynamicEntity
  
DynamicEntity
 Inherited
OnDeath():void
Called when the entity's health is now 0.
Entity
 Inherited
Called when the entity's health has been changed.
Entity
 Inherited
Called when the entity took damage via TakeDamage function.
Entity
  
UpdateCollisionRect(nSetPosX:Number, nSetPosY:Number, nSetScaleX:Number, nSetScaleY:Number, nSetWidth:Number, nSetHeight:Number, nSetOffsetX:Number, nSetOffsetY:Number):void
Update the position/scale of the collision rect
DynamicEntity
Property Detail
_dynamicproperty
_dynamic:Boolean  [read-only] [override]

Returns if the entity is dynamic.


Implementation
    public function get _dynamic():Boolean
absXproperty 
absX:Number  [read-only]

Returns the absolute X position.


Implementation
    public function get absX():Number
absYproperty 
absY:Number  [read-only]

Returns the absolute Y position.


Implementation
    public function get absY():Number
baseClassproperty 
baseClass:Object  [read-only] [override]

Returns the entity base class.


Implementation
    public function get baseClass():Object
bCollisionEnabledproperty 
protected var bCollisionEnabled:Boolean

collisionRectproperty 
collisionRect:CRectangle  [read-only]

Returns the collision rect


Implementation
    public function get collisionRect():CRectangle
iBoundPaddingproperty 
protected var iBoundPadding:int = 100

iCollisionFlagsproperty 
protected var iCollisionFlags:int

initXproperty 
initX:Number  [read-only]

A getter that returns the initial X position.


Implementation
    public function get initX():Number
initYproperty 
initY:Number  [read-only]

A getter that returns the initial Y position.


Implementation
    public function get initY():Number
iRemoveOffScreenPaddingproperty 
protected var iRemoveOffScreenPadding:int = 100

nInitialXproperty 
protected var nInitialX:Number

nInitialYproperty 
protected var nInitialY:Number

nPosXproperty 
protected var nPosX:Number

nPosYproperty 
protected var nPosY:Number

physproperty 
phys:PhysObject  [read-only]

Returns the physics object (short-hand). If the physics object doesn't exist, it'll create a new one.


Implementation
    public function get phys():PhysObject
rectBoundsproperty 
protected var rectBounds:Rectangle

rectCollisionproperty 
protected var rectCollision:CRectangle

xproperty 
x:Number

Returns the current calculated x position of this entity


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

Returns the current calculated y position of this entity


Implementation
    public function get y():Number
    public function set y(value:Number):void
Method Detail
_Dispose()method
override public function _Dispose():void

Cleans the entity's data. DO NOT CALL MANUALLY - THIS IS HANDLED BY verEnts!

_Update()method 
override public function _Update():void

Called each engine tick, do not override this. DO NOT CALL MANUALLY - THIS IS HANDLED BY verEnts!

CalcXBoundaries()method 
protected function CalcXBoundaries(nSetPosX:Number):void

Calculates if a position is beyond the Y boundaries

Parameters

nSetPosX:Number

CalcYBoundaries()method 
protected function CalcYBoundaries(nSetPosY:Number):void

Calculates if a position is beyond the Y boundaries

Parameters

nSetPosY:Number

ClearBounds()method 
public function ClearBounds():void

Clears the boundaries of the entity.

DrawCollisionRect()method 
protected function DrawCollisionRect():void

EmitSound()method 
public function EmitSound(sSound:*, nStartVolume:Number = 1, bLoops:Boolean = false, bParent:Boolean = false, bFadeIn:Boolean = false):void

Plays a sound at the location of the entity.

Parameters

sSound:* — The sound to play.
 
nStartVolume:Number (default = 1) — The starting volume of the sound.
 
bLoops:Boolean (default = false) — Should the sound loop or not?
 
bParent:Boolean (default = false) — Set this to true if you want the sound to follow the entity's position.
 
bFadeIn:Boolean (default = false)

EnableCollision()method 
public function EnableCollision(bEnable:Boolean = true):void

Enables/disables calculations for collision. If no collision flags are set, by default, the CO_BASIC collision flag is set.

Parameters

bEnable:Boolean (default = true) — Enables/disables collision

EnablePhysics()method 
public function EnablePhysics(bEnable:Boolean = true, bRemovePhysicsObj:Boolean = true):void

Enables/disables calculations for physics.

Parameters

bEnable:Boolean (default = true) — Enables/disables physics
 
bRemovePhysicsObj:Boolean (default = true) — Remove the physics object on disable?

GetMouseRotation()method 
public function GetMouseRotation():Number

Returns the rotation (0-360) from the relation of the mouse and the entity.

Returns
Number
GetPhysicsObject()method 
public function GetPhysicsObject():PhysObject

Returns the physics object

Returns
PhysObject
GetPos()method 
public function GetPos():Point

Returns the current position as a point

Returns
Point
HasMoved()method 
public function HasMoved():Boolean

Returns if the entity has moved (determined by its previous position set) This is used to optimize collision and physics calculations

Returns
Boolean
IsColliding()method 
public function IsColliding(ent:DynamicEntity):Boolean

Returns the method of basic collision between other types

Parameters

ent:DynamicEntity

Returns
Boolean
IsCollisionEnabled()method 
public function IsCollisionEnabled():Boolean

Returns if collision is enabled

Returns
Boolean
IsCollisionFlagOn()method 
public function IsCollisionFlagOn(iCollisionFlag:int):Boolean

Returns if a collision flag is enabled or not.

Parameters

iCollisionFlag:int — The collision flag to test (found in Verlocity.collision.CO_

Returns
Boolean
IsOnBottomBoundary()method 
public function IsOnBottomBoundary():Boolean

Returns
Boolean
IsOnBoundary()method 
public function IsOnBoundary():Boolean

Returns
Boolean
IsOnLeftBoundary()method 
public function IsOnLeftBoundary():Boolean

Returns
Boolean
IsOnRightBoundary()method 
public function IsOnRightBoundary():Boolean

Returns
Boolean
IsOnScreen()method 
public function IsOnScreen():Boolean

Returns if the entity is within the boundaries of the screen.

Returns
Boolean
IsOnTopBoundary()method 
public function IsOnTopBoundary():Boolean

Returns
Boolean
IsOnXBoundary()method 
public function IsOnXBoundary():Boolean

Returns
Boolean
IsOnYBoundary()method 
public function IsOnYBoundary():Boolean

Returns
Boolean
IsPhysicsEnabled()method 
public function IsPhysicsEnabled():Boolean

Returns if physics is enabled

Returns
Boolean
OnCollide()method 
public function OnCollide(ent:*):void

Called when a rectangle collision occured

Parameters

ent:* — The entity that collided

RemoveOffScreen()method 
public function RemoveOffScreen(bShouldRemove:Boolean = true, iPadding:int = 100):void

Tells the entity to remove itself when its off screen. Useful for bullets.

Parameters

bShouldRemove:Boolean (default = true) — Should the entity be removed off screen?
 
iPadding:int (default = 100) — Padding to use when removing off screen

Reset()method 
override public function Reset():void

Resets the entity to its original values.

ResetPos()method 
public function ResetPos():void

Resets the entity to its initial position.

SetBounds()method 
public function SetBounds(rectSetBounds:Rectangle, iInnerPadding:int = 0):void

Sets the screen boundaries of the entity. This limits the movement of the entity to these boundaries.

Parameters

rectSetBounds:Rectangle — The rectangle boundary
 
iInnerPadding:int (default = 0) — The inner padding of the bounds

SetCollisionFlags()method 
public function SetCollisionFlags(iFlags:int):void

Set collision flags. For multiples, seperate each flag with | These can be found in Verlocity.collision.CO_

Parameters

iFlags:int — The collision flags to test (found in Verlocity.collision.CO_

SetCollisionRect()method 
public function SetCollisionRect(rect:Rectangle, nOffsetX:Number = 0, nOffsetY:Number = 0):void

Sets the collision rect (required for collision)

Parameters

rect:Rectangle — The rectangle to use for collision
 
nOffsetX:Number (default = 0) — The offset from the center point of the entity
 
nOffsetY:Number (default = 0) — The offset from the center point of the entity

SetPhysicsProperties()method 
public function SetPhysicsProperties(nMass:Number, pVelocityDirection:Point, nVelocityMagnitude:Number):void

Sets the physicial properies of this entity

Parameters

nMass:Number — The calculated mass of the entity
 
pVelocityDirection:Point — The initial velocity direction (normalized)
 
nVelocityMagnitude:Number — The initial velocity magnitude

SetPos()method 
public function SetPos(nSetPosX:Number, nSetPosY:Number):void

Sets the X and Y position of the entity

Parameters

nSetPosX:Number — The X position to set the entity to.
 
nSetPosY:Number — The Y position to set the entity to.

StopAllSounds()method 
public function StopAllSounds():void

Stops all sounds that are emitting from this entity.

UpdateCollisionRect()method 
protected function UpdateCollisionRect(nSetPosX:Number, nSetPosY:Number, nSetScaleX:Number, nSetScaleY:Number, nSetWidth:Number, nSetHeight:Number, nSetOffsetX:Number, nSetOffsetY:Number):void

Update the position/scale of the collision rect

Parameters

nSetPosX:Number (default = NaN)
 
nSetPosY:Number (default = NaN)
 
nSetScaleX:Number (default = NaN)
 
nSetScaleY:Number (default = NaN)
 
nSetWidth:Number (default = NaN)
 
nSetHeight:Number (default = NaN)
 
nSetOffsetX:Number (default = NaN)
 
nSetOffsetY:Number (default = NaN)