Packageorg.flintparticles.twoD.zones
Classpublic class BitmapDataZone
InheritanceBitmapDataZone Inheritance Object
Implements Zone2D

The BitmapData zone defines a shaped zone based on a BitmapData object. The zone contains all pixels in the bitmap that are not transparent - i.e. they have an alpha value greater than zero.



Public Properties
 PropertyDefined By
  bitmapData : BitmapData
The bitmapData object that defines the zone.
BitmapDataZone
  offsetX : Number
A horizontal offset to apply to the pixels in the BitmapData object to reposition the zone
BitmapDataZone
  offsetY : Number
A vertical offset to apply to the pixels in the BitmapData object to reposition the zone
BitmapDataZone
  scaleX : Number
A scale factor to stretch the bitmap horizontally
BitmapDataZone
  scaleY : Number
A scale factor to stretch the bitmap vertically
BitmapDataZone
Public Methods
 MethodDefined By
  
BitmapDataZone(bitmapData:BitmapData = null, offsetX:Number = 0, offsetY:Number = 0, scaleX:Number = 1, scaleY:Number = 1)
The constructor creates a BitmapDataZone object.
BitmapDataZone
  
collideParticle(particle:Particle2D, bounce:Number = 1):Boolean
Manages collisions between a particle and the zone.
BitmapDataZone
  
contains(x:Number, y:Number):Boolean
The contains method determines whether a point is inside the zone.
BitmapDataZone
  
getArea():Number
The getArea method returns the size of the zone.
BitmapDataZone
  
getLocation():Point
The getLocation method returns a random point inside the zone.
BitmapDataZone
  
invalidate():void
This method forces the zone to revaluate itself.
BitmapDataZone
Property Detail
bitmapDataproperty
bitmapData:BitmapData

The bitmapData object that defines the zone.


Implementation
    public function get bitmapData():BitmapData
    public function set bitmapData(value:BitmapData):void
offsetXproperty 
offsetX:Number

A horizontal offset to apply to the pixels in the BitmapData object to reposition the zone


Implementation
    public function get offsetX():Number
    public function set offsetX(value:Number):void
offsetYproperty 
offsetY:Number

A vertical offset to apply to the pixels in the BitmapData object to reposition the zone


Implementation
    public function get offsetY():Number
    public function set offsetY(value:Number):void
scaleXproperty 
scaleX:Number

A scale factor to stretch the bitmap horizontally


Implementation
    public function get scaleX():Number
    public function set scaleX(value:Number):void
scaleYproperty 
scaleY:Number

A scale factor to stretch the bitmap vertically


Implementation
    public function get scaleY():Number
    public function set scaleY(value:Number):void
Constructor Detail
BitmapDataZone()Constructor
public function BitmapDataZone(bitmapData:BitmapData = null, offsetX:Number = 0, offsetY:Number = 0, scaleX:Number = 1, scaleY:Number = 1)

The constructor creates a BitmapDataZone object.

Parameters
bitmapData:BitmapData (default = null) — The bitmapData object that defines the zone.
 
offsetX:Number (default = 0) — A horizontal offset to apply to the pixels in the BitmapData object to reposition the zone
 
offsetY:Number (default = 0) — A vertical offset to apply to the pixels in the BitmapData object to reposition the zone
 
scaleX:Number (default = 1) — A scale factor to stretch the bitmap horizontally
 
scaleY:Number (default = 1) — A scale factor to stretch the bitmap vertically
Method Detail
collideParticle()method
public function collideParticle(particle:Particle2D, bounce:Number = 1):Boolean

Manages collisions between a particle and the zone. The particle will collide with the edges of the zone, from the inside or outside. In the interests of speed, these collisions do not take account of the collisionRadius of the particle and they do not calculate an accurate bounce direction from the shape of the zone. Priority is placed on keeping particles inside or outside the zone.

Parameters

particle:Particle2D — The particle to be tested for collision with the zone.
 
bounce:Number (default = 1) — The coefficient of restitution for the collision.

Returns
Boolean — Whether a collision occured.
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 location to test for.
 
y:Number

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.
invalidate()method 
public function invalidate():void

This method forces the zone to revaluate itself. It should be called whenever the contents of the BitmapData object change. However, it is an intensive method and calling it frequently will likely slow your code down.