Packagecitrus.objects.platformer.box2d
Classpublic class RewardBox
InheritanceRewardBox Inheritance Box2DPhysicsObject Inheritance APhysicsObject Inheritance CitrusObject Inheritance Object

The RewardBox is a special type of platform that you can "bump" to make a reward come out. It is meant to be similar to those "question blocks" or "mystery blocks" in mario.

This means that you must also create a class that extends Reward for every reward type that you want in your game. If you were making a mario clone, you would make a FireFlowerReward. This is where you would specify the reward's graphics, its initial impulse out of the box, and any custom code such as unique movement or a death timer.



Public Properties
 PropertyDefined By
  animation : String
[override]
RewardBox
 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
  collisionAngle : Number = 90
This is the vector normal that the reward box must be collided with in order for the reward to be created.
RewardBox
 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
 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
  isUsed : Boolean
[read-only]
RewardBox
 Inheritedkill : Boolean = false
Set it to true if you want to remove, clean and destroy the object.
CitrusObject
 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
  onRewardCollect : Signal
Dispatched when the reward that came out of the box is collected by the player.
RewardBox
  onUse : Signal
Dispatched when the box gets "bumped" or used.
RewardBox
 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
  rewardClass : *
Specify the class of the object that you want the reward box to generate.
RewardBox
 Inheritedrotation : Number
Box2DPhysicsObject
 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
  _createReward : Boolean = false
RewardBox
 Inherited_endContactCallEnabled : Boolean = false
Box2DPhysicsObject
 Inherited_fixture : b2Fixture
Box2DPhysicsObject
 Inherited_fixtureDef : b2FixtureDef
Box2DPhysicsObject
 Inherited_height : Number = 1
Box2DPhysicsObject
 Inherited_initialized : Boolean = false
CitrusObject
 Inherited_inverted : Boolean = false
APhysicsObject
  _isUsed : Boolean = false
RewardBox
 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
  _rewardClass : Class
RewardBox
 Inherited_rotation : Number = 0
APhysicsObject
 Inherited_shape : b2Shape
Box2DPhysicsObject
 Inherited_timeDelta : Number
The time elasped between two update call.
CitrusObject
 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
  
RewardBox(name:String, params:Object = null)
RewardBox
 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]
RewardBox
 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
  
handleBeginContact(contact:b2Contact):void
[override]
RewardBox
 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 this method if you want to perform some actions before the collision (deactivate).
Box2DPhysicsObject
 Inherited
initialize(poolObjectParams:Object = null):void
Call in the constructor if the Object is added via the State and the add method.
CitrusObject
 Inherited
setParams(object:Object, params:Object):void
The initialize method usually calls this.
CitrusObject
 Inherited
toString():String
CitrusObject
  
update(timeDelta:Number):void
[override]
RewardBox
Protected Methods
 MethodDefined By
 Inherited
Box2DPhysicsObject
 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
  
defineBody():void
[override]
RewardBox
  
[override]
RewardBox
 Inherited
This method will often need to be overridden to provide additional definition to the Box2D joint object.
Box2DPhysicsObject
  
RewardBox
Property Detail
_createRewardproperty
protected var _createReward:Boolean = false

_isUsedproperty 
protected var _isUsed:Boolean = false

_rewardClassproperty 
protected var _rewardClass:Class

animationproperty 
animation:String[override]


Implementation
    public function get animation():String
    public function set animation(value:String):void
collisionAngleproperty 
public var collisionAngle:Number = 90

This is the vector normal that the reward box must be collided with in order for the reward to be created. On a box with no rotation, 90 is "from below", 0 is "from the right", -180 is "from the left", and -90 is "from above".

isUsedproperty 
isUsed:Boolean  [read-only]


Implementation
    public function get isUsed():Boolean
onRewardCollectproperty 
public var onRewardCollect:Signal

Dispatched when the reward that came out of the box is collected by the player.

onUseproperty 
public var onUse:Signal

Dispatched when the box gets "bumped" or used.

rewardClassproperty 
rewardClass:*

Specify the class of the object that you want the reward box to generate. The class must extend Reward in order to be valid. You can specify the rewardClass in String form (rewardClass = "com.myGame.FireballReward") or via direct reference (rewardClass = FireballReward). You should use the String form when creating RewardBoxes in an external level editor. Make sure and specify the entire classpath.


Implementation
    public function get rewardClass():*
    public function set rewardClass(value:any):void
Constructor Detail
RewardBox()Constructor
public function RewardBox(name:String, params:Object = null)



Parameters
name:String
 
params:Object (default = null)
Method Detail
defineBody()method
override protected function defineBody():void

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

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

handleBeginContact()method 
override public function handleBeginContact(contact:b2Contact):void

Parameters

contact:b2Contact

handleRewardCollected()method 
protected function handleRewardCollected(reward:Reward):void

Parameters

reward:Reward

update()method 
override public function update(timeDelta:Number):void

Parameters

timeDelta:Number