Packagecitrus.objects.platformer.box2d
Classpublic class Hills
InheritanceHills Inheritance Box2DPhysicsObject Inheritance APhysicsObject Inheritance CitrusObject Inheritance Object

This class creates perpetual hills like the games Tiny Wings, Ski Safari... Write a class to manage graphics, and extends this one to call graphics function. For more information, check out CE's Tiny Wings example. Thanks to Lorenzo Nuvoletta. Thanks to Emanuele Feronato.



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
 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
  hillStartY : Number = 0
This is the height of the first point.
Hills
 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
 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
 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
  rider : Box2DPhysicsObject
This is the physics object from which the Hills read its position and create/delete hills.
Hills
 Inheritedrotation : Number
Box2DPhysicsObject
  roundFactor : uint = 10
This is the factor that defined the roundness of the hills.
Hills
  sliceHeight : uint = 240
This is the height of a slice.
Hills
  sliceWidth : uint = 30
This is the width of a slice.
Hills
 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
  widthHills : Number = 550
This is the width of the hills visible.
Hills
 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
  _currentYPoint : Number = 0
Hills
  _downAmplitude : Number
Hills
 Inherited_endContactCallEnabled : Boolean = false
Box2DPhysicsObject
 Inherited_fixture : b2Fixture
Box2DPhysicsObject
 Inherited_fixtureDef : b2FixtureDef
Box2DPhysicsObject
 Inherited_height : Number = 1
Box2DPhysicsObject
  _indexSliceInCurrentHill : uint
Hills
 Inherited_initialized : Boolean = false
CitrusObject
 Inherited_inverted : Boolean = false
APhysicsObject
  _nextYPoint : Number = 0
Hills
 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
  _randomHeight : Number = 0
Hills
  _realHeight : Number = 240
Hills
  _realWidth : Number = 0
Hills
 Inherited_rotation : Number = 0
APhysicsObject
 Inherited_shape : b2Shape
Box2DPhysicsObject
  _slices : Vector.<b2Body>
Hills
  _slicesCreated : uint
Hills
  _slicesInCurrentHill : uint
Hills
  _sliceVectorConstructor : Vector.<b2Vec2>
Hills
 Inherited_timeDelta : Number
The time elasped between two update call.
CitrusObject
 Inherited_touchable : Boolean = false
APhysicsObject
  _upAmplitude : Number
Hills
 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
  
Hills(name:String, params:Object = null)
Hills
  
addPhysics():void
[override]
Hills
 Inherited
destroy():void
[override]
Box2DPhysicsObject
 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 this method if you want to perform some actions before the collision (deactivate).
Box2DPhysicsObject
  
initialize(poolObjectParams:Object = null):void
[override]
Hills
 Inherited
setParams(object:Object, params:Object):void
The initialize method usually calls this.
CitrusObject
 Inherited
toString():String
CitrusObject
  
update(timeDelta:Number):void
[override]
Hills
Protected Methods
 MethodDefined By
  
Hills
  
Hills
 Inherited
Box2DPhysicsObject
  
_deleteHill(index:uint):void
Hills
  
Hills
  
_pushHill():void
Hills
  
createBody():void
[override]
Hills
  
[override]
Hills
 Inherited
This method will often need to be overridden to customize the Box2D joint object.
Box2DPhysicsObject
  
[override]
Hills
  
defineBody():void
[override] Bodies are generated automatically, those functions aren't needed.
Hills
  
[override]
Hills
 Inherited
This method will often need to be overridden to provide additional definition to the Box2D joint object.
Box2DPhysicsObject
Property Detail
_currentYPointproperty
protected var _currentYPoint:Number = 0

_downAmplitudeproperty 
protected var _downAmplitude:Number

_indexSliceInCurrentHillproperty 
protected var _indexSliceInCurrentHill:uint

_nextYPointproperty 
protected var _nextYPoint:Number = 0

_randomHeightproperty 
protected var _randomHeight:Number = 0

_realHeightproperty 
protected var _realHeight:Number = 240

_realWidthproperty 
protected var _realWidth:Number = 0

_slicesproperty 
protected var _slices:Vector.<b2Body>

_slicesCreatedproperty 
protected var _slicesCreated:uint

_slicesInCurrentHillproperty 
protected var _slicesInCurrentHill:uint

_sliceVectorConstructorproperty 
protected var _sliceVectorConstructor:Vector.<b2Vec2>

_upAmplitudeproperty 
protected var _upAmplitude:Number

hillStartYproperty 
public var hillStartY:Number = 0

This is the height of the first point.

riderproperty 
public var rider:Box2DPhysicsObject

This is the physics object from which the Hills read its position and create/delete hills.

roundFactorproperty 
public var roundFactor:uint = 10

This is the factor that defined the roundness of the hills.

sliceHeightproperty 
public var sliceHeight:uint = 240

This is the height of a slice.

sliceWidthproperty 
public var sliceWidth:uint = 30

This is the width of a slice.

widthHillsproperty 
public var widthHills:Number = 550

This is the width of the hills visible. Most of the time your stage width.

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



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

_createSlice()method 
protected function _createSlice():void

_deleteHill()method 
protected function _deleteHill(index:uint):void

Parameters

index:uint

_prepareSlices()method 
protected function _prepareSlices():void

_pushHill()method 
protected function _pushHill():void

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

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

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

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

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

Bodies are generated automatically, those functions aren't needed.

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

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

Parameters

poolObjectParams:Object (default = null)

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

Parameters

timeDelta:Number