Packagecom.boristhebrave.Box2DWith.Flint
Classpublic class BodyZone
Implementsorg.flintparticles.twoD.zones.Zone2D

A BodyZone allows 2D particles to be picked randomly from inside a body.



Public Properties
 PropertyDefined by
  body : b2Body
The body to pick points from.
BodyZone
  byMass : Boolean
Are points randomly weighted by mass, or by volume.
BodyZone
  local : Boolean
Is the returned point in local or world co-ordinates.
BodyZone
  scale : Number
The scale factor between Flint pixels and Box2D units, in pixels/unit.
BodyZone
Public Methods
 MethodDefined by
  
BodyZone(body:b2Body, byMass:Boolean = true, local:Boolean = true, scale:Number)
Basic constructor
BodyZone
  
contains(x:Number, y:Number):Boolean
The contains method determines whether a point is inside the zone.
BodyZone
  
getArea():Number
The getArea method returns the size of the zone.
BodyZone
  
getLocation():Point
The getLocation method returns a random point inside the zone.
BodyZone
  
getShapeWeights():FastWeightedArray
Returns a FastWeightedArray with an entry for each shape in the body, and weightings according to mass or volume.
BodyZone
Property detail
bodyproperty
public var body:b2Body

The body to pick points from.

byMassproperty 
public var byMass:Boolean

Are points randomly weighted by mass, or by volume.

localproperty 
public var local:Boolean

Is the returned point in local or world co-ordinates.

scaleproperty 
public var scale:Number

The scale factor between Flint pixels and Box2D units, in pixels/unit.

Constructor detail
BodyZone()constructor
public function BodyZone(body:b2Body, byMass:Boolean = true, local:Boolean = true, scale:Number)

Basic constructor

Parameters
body:b2Body — The body get shapes from.
 
byMass:Boolean (default = true) — Scaling factor between Flint pixels and Box2D units in pixels/unit.
 
local:Boolean (default = true) — Should random locations be weighted by mass or by area.
 
scale:Number — If true, points are considered in the bodies local co-ordinates, not world co-ordinates.
Method detail
contains()method
public function contains(x:Number, y:Number):Boolean

The contains method determines whether a point is inside the zone.

Parameters
x:Number — The x coordinate of the location to test for.
 
y:Number — The y coordinate of the location to test for.

Returns
Boolean — true if point is inside the zone, false if it is outside.
getArea()method 
public function getArea():Number

The getArea method returns the size of the zone. It's used by the MultiZone class to manage the balancing between the different zones.

Returns
Number — the size of the zone.
getLocation()method 
public function getLocation():Point

The getLocation method returns a random point inside the zone.

Returns
Point — a random point inside the zone.
getShapeWeights()method 
public function getShapeWeights():FastWeightedArray

Returns a FastWeightedArray with an entry for each shape in the body, and weightings according to mass or volume.

Returns
FastWeightedArray