class ColorHitMap
package away3d.tools.utils
extends EventDispatcher
Available on all platforms
Constructor
new(bitmapData:BitmapData, scaleX:Float = 1, scaleY:Float = 1)
Creates a new ColorHitMap
Parameters:
bitmapData | The bitmapdata with color regions to act as trigger. |
|---|---|
scaleX | [optional] A factor scale along the X axis. Default is 1. |
scaleY | [optional] A factor scale along the Y axis. Default is 1. Note that by default the class is considered as centered, like a plane at 0,0,0. Also by default coordinates offset are set. If a map of 256x256 is set, and no custom offsets are set. The read method using the camera position -128 x and -128 z would return the color value found at 0,0 on the map. |
Variables
Methods
addColorEvent(color:Int, eventID:String, listener:Dynamic ‑> Void):Void
Defines a color event for this class. If read method is called, and the target pixel color has the same value as a previously set listener, an event is triggered.
Parameters:
color | A color Number |
|---|---|
eventID | A string to identify that event |
listener | The function that must be triggered |
getColorAt(x:Float, y:Float):Int
returns the color at x,y coordinates. This method is made to test if the color is indeed the expected one, (the one you set for an event), as due to compression for instance using the Flash IDE library, compression might have altered the color values.
Parameters:
x | X coordinate on the source bitmapData |
|---|---|
y | Y coordinate on the source bitmapData |
Returns:
A uint, the color value at coordinates x, y
See also:
plotAt
plotAt(x:Float, y:Float, color:Int = 0xFF0000):Void
Another method for debug, if you addChild your bitmapdata on screen, this method will colour a pixel at the coordinates helping you to visualize if your scale factors or entered coordinates are correct.
Parameters:
x | X coordinate on the source bitmapData |
|---|---|
y | Y coordinate on the source bitmapData |
read(x:Float, y:Float):Void
If at the given coordinates a color is found that matches a defined color event, the color event will be triggered.
Parameters:
x | X coordinate on the source bmd |
|---|---|
y | Y coordinate on the source bmd |