Packagecitrus.objects.platformer.box2d
Classpublic class Cannon
InheritanceCannon Inheritance Platform Inheritance Box2DPhysicsObject Inheritance APhysicsObject Inheritance CitrusObject Inheritance Object

A cannon is an object which fires missiles. A cannon is a static body so it extends Platform.



Public Properties
 PropertyDefined By
 Inheritedanimation : String
Animations management works the same way than label whether it uses MovieClip, SpriteSheet or whatever.
APhysicsObject
 Inheritedart : ICitrusArt
[read-only]
APhysicsObject
 InheritedbeginContactCallEnabled : Boolean
This flag determines if the handleBeginContact method is called or not.
Box2DPhysicsObject
 Inheritedbody : b2Body
[read-only] A direct reference to the Box2D body associated with this object.
Box2DPhysicsObject
 Inheriteddepth : Number
[read-only] No depth in a 2D Physics world.
Box2DPhysicsObject
 InheritedendContactCallEnabled : Boolean
This flag determines if the handleEndContact method is called or not.
Box2DPhysicsObject
  fireRate : Number = 2000
The frequency that missiles are fired.
Cannon
 Inheritedgroup : uint
The group is similar to a z-index sorting.
APhysicsObject
 Inheritedheight : Number
This can only be set in the constructor parameters.
Box2DPhysicsObject
 InheritedhideParamWarnings : Boolean = false
[static]
CitrusObject
 InheritedID : uint
[read-only]
CitrusObject
 Inheritedinverted : Boolean
[read-only] Used to invert the view on the y-axis, number of animations friendly!
APhysicsObject
 Inheritedkill : Boolean = false
Set it to true if you want to remove, clean and destroy the object.
CitrusObject
  missileAngle : Number = 0
Cannon
  missileExplodeDuration : Number = 1000
Cannon
  missileFuseDuration : Number = 10000
Cannon
  missileHeight : uint = 20
Cannon
  missileSpeed : Number = 2
Cannon
  missileView : *
Cannon
  missileWidth : uint = 20
Cannon
 Inheritedname : String
A name to identify easily an objet.
CitrusObject
 InheritedoffsetX : Number
offsetX allows to move graphics on x axis compared to their initial point.
APhysicsObject
 InheritedoffsetY : Number
offsetY allows to move graphics on y axis compared to their initial point.
APhysicsObject
 InheritedoneWay : Boolean
Makes the platform only collidable when falling from above it.
Platform
  onGiveDamage : Signal
Dispatched when the missile explodes on a Box2DPhysicsObject.
Cannon
  openFire : Boolean = true
Indicate if the cannon shoot at start or not.
Cannon
 InheritedparallaxX : Number
APhysicsObject
 InheritedparallaxY : Number
APhysicsObject
 Inheritedpoints : Array
Used to define vertices' x and y points.
Box2DPhysicsObject
 InheritedpostContactCallEnabled : Boolean
This flag determines if the handlePostSolve method is called or not.
Box2DPhysicsObject
 InheritedpreContactCallEnabled : Boolean
This flag determines if the handlePreSolve method is called or not.
Box2DPhysicsObject
 Inheritedradius : Number
This can only be set in the constructor parameters.
Box2DPhysicsObject
 Inheritedregistration : String
Flash registration point is topLeft, whereas physics engine use mostly center.
APhysicsObject
 Inheritedrotation : Number
Box2DPhysicsObject
  startingDirection : String = right
The direction that missiles are fired
Cannon
 Inheritedtouchable : Boolean
APhysicsObject
 Inheritedtype : String = classicObject
Added to the CE's render list via the State and the add method.
CitrusObject
 InheritedupdateCallEnabled : Boolean = false
This property prevent the update method to be called by the enter frame, it will save performances.
CitrusObject
 Inheritedvelocity : Array
Box2DPhysicsObject
 Inheritedview : *
The view can be a class, a string to a file, or a display object.
APhysicsObject
 Inheritedvisible : Boolean
You can easily change if an object is visible or not.
APhysicsObject
 Inheritedwidth : Number
This can only be set in the constructor parameters.
Box2DPhysicsObject
 Inheritedx : Number
Box2DPhysicsObject
 Inheritedy : Number
Box2DPhysicsObject
 Inheritedz : Number
[read-only]
Box2DPhysicsObject
Protected Properties
 PropertyDefined By
 Inherited_animation : String
APhysicsObject
 Inherited_art : ICitrusArt
APhysicsObject
 Inherited_beginContactCallEnabled : Boolean = false
Box2DPhysicsObject
 Inherited_body : b2Body
Box2DPhysicsObject
 Inherited_bodyDef : b2BodyDef
Box2DPhysicsObject
 Inherited_box2D : Box2D
Box2DPhysicsObject
 Inherited_ce : CitrusEngine
CitrusObject
 Inherited_endContactCallEnabled : Boolean = false
Box2DPhysicsObject
  _firing : Boolean = false
Cannon
 Inherited_fixture : b2Fixture
Box2DPhysicsObject
 Inherited_fixtureDef : b2FixtureDef
Box2DPhysicsObject
 Inherited_height : Number = 1
Box2DPhysicsObject
 Inherited_initialized : Boolean = false
CitrusObject
 Inherited_inverted : Boolean = false
APhysicsObject
 Inherited_parallaxX : Number = 1
APhysicsObject
 Inherited_parallaxY : Number = 1
APhysicsObject
 Inherited_params : Object
CitrusObject
 Inherited_postContactCallEnabled : Boolean = false
Box2DPhysicsObject
 Inherited_preContactCallEnabled : Boolean = false
Box2DPhysicsObject
 Inherited_radius : Number = 0
APhysicsObject
 Inherited_rotation : Number = 0
APhysicsObject
 Inherited_shape : b2Shape
Box2DPhysicsObject
 Inherited_timeDelta : Number
The time elasped between two update call.
CitrusObject
  _timer : Timer
Cannon
 Inherited_touchable : Boolean = false
APhysicsObject
 Inherited_vertices : Array
Box2DPhysicsObject
 Inherited_view : *
APhysicsObject
 Inherited_visible : Boolean = true
APhysicsObject
 Inherited_width : Number = 1
Box2DPhysicsObject
 Inherited_x : Number = 0
APhysicsObject
 Inherited_y : Number = 0
APhysicsObject
 Inherited_z : Number = 0
APhysicsObject
Public Methods
 MethodDefined By
  
Cannon(name:String, params:Object = null)
Cannon
 Inherited
addPhysics():void
[override] All your init physics code must be added in this method, no physics code into the constructor.
Box2DPhysicsObject
  
destroy():void
[override]
Cannon
 Inherited
This method doesn't depend of your application enter frame.
APhysicsObject
 Inherited
[override]
Box2DPhysicsObject
 Inherited
called when the art changes.
APhysicsObject
 Inherited
handleArtReady(citrusArt:ICitrusArt):void
called when the art is created (and loaded if loading is required)
APhysicsObject
 Inherited
handleBeginContact(contact:b2Contact):void
Override this method to handle the begin contact collision.
Box2DPhysicsObject
 Inherited
handleEndContact(contact:b2Contact):void
Override this method to handle the end contact collision.
Box2DPhysicsObject
 Inherited
handlePostSolve(contact:b2Contact, impulse:b2ContactImpulse):void
Override this method if you want to perform some actions after the collision.
Box2DPhysicsObject
 Inherited
handlePreSolve(contact:b2Contact, oldManifold:b2Manifold):void
[override]
Platform
  
initialize(poolObjectParams:Object = null):void
[override]
Cannon
 Inherited
setParams(object:Object, params:Object):void
The initialize method usually calls this.
CitrusObject
  
startFire():void
Cannon starts to fire.
Cannon
  
stopFire():void
Cannon stops to fire, timer is stopped.
Cannon
 Inherited
toString():String
CitrusObject
 Inherited
update(timeDelta:Number):void
[override] You should override this method to extend the functionality of your physics object.
APhysicsObject
Protected Methods
 MethodDefined By
 Inherited
Box2DPhysicsObject
  
_damage(missile:Missile, contact:Box2DPhysicsObject):void
Dispatch onGiveDamage's Signal if a missile fired by the cannon explodes.
Cannon
  
_fire(tEvt:TimerEvent):void
Cannon fires a missile.
Cannon
  
_playingChanged(playing:Boolean):void
Start or stop the timer.
Cannon
  
Cannon
 Inherited
createBody():void
This method will often need to be overridden to customize the Box2D body object.
Box2DPhysicsObject
 Inherited
This method will often need to be overridden to customize the Box2D fixture object.
Box2DPhysicsObject
 Inherited
This method will often need to be overridden to customize the Box2D joint object.
Box2DPhysicsObject
 Inherited
This method will often need to be overridden to customize the Box2D shape object.
Box2DPhysicsObject
 Inherited
defineBody():void
[override]
Platform
 Inherited
[override]
Platform
 Inherited
This method will often need to be overridden to provide additional definition to the Box2D joint object.
Box2DPhysicsObject
Property Detail
_firingproperty
protected var _firing:Boolean = false

_timerproperty 
protected var _timer:Timer

fireRateproperty 
public var fireRate:Number = 2000

The frequency that missiles are fired.

missileAngleproperty 
public var missileAngle:Number = 0

missileExplodeDurationproperty 
public var missileExplodeDuration:Number = 1000

missileFuseDurationproperty 
public var missileFuseDuration:Number = 10000

missileHeightproperty 
public var missileHeight:uint = 20

missileSpeedproperty 
public var missileSpeed:Number = 2

missileViewproperty 
public var missileView:*

missileWidthproperty 
public var missileWidth:uint = 20

onGiveDamageproperty 
public var onGiveDamage:Signal

Dispatched when the missile explodes on a Box2DPhysicsObject. Passes one parameter: The Object it exploded on (Box2DPhysicsObject)

openFireproperty 
public var openFire:Boolean = true

Indicate if the cannon shoot at start or not.

startingDirectionproperty 
public var startingDirection:String = right

The direction that missiles are fired

Constructor Detail
Cannon()Constructor
public function Cannon(name:String, params:Object = null)



Parameters
name:String
 
params:Object (default = null)
Method Detail
_damage()method
protected function _damage(missile:Missile, contact:Box2DPhysicsObject):void

Dispatch onGiveDamage's Signal if a missile fired by the cannon explodes.

Parameters

missile:Missile
 
contact:Box2DPhysicsObject

_fire()method 
protected function _fire(tEvt:TimerEvent):void

Cannon fires a missile. This missile called the _damage function on missile's explosion.

Parameters

tEvt:TimerEvent

_playingChanged()method 
protected function _playingChanged(playing:Boolean):void

Start or stop the timer. Automatically called by the engine when the game is paused/unpaused.

Parameters

playing:Boolean

_updateAnimation()method 
protected function _updateAnimation():void

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

initialize()method 
override public function initialize(poolObjectParams:Object = null):void

Parameters

poolObjectParams:Object (default = null)

startFire()method 
public function startFire():void

Cannon starts to fire. The timer is also started with the fireRate's frequency.

stopFire()method 
public function stopFire():void

Cannon stops to fire, timer is stopped.