Game Development Reference
In-Depth Information
since Flash
s 3D capabilities do not include any form of lighting.
However, we can manually adjust this using a ColorTransform.
'
var ct:ColorTransform = tempTile.transform.colorTransform;
ct.redMultiplier *= (_depth - j)/_depth;
ct.greenMultiplier *= (_depth - j)/_depth;
ct.blueMultiplier *= (_depth - j)/_depth;
tempTile.transform.colorTransform = ct;
In order for the tunnel to look like it is truly diminishing from the
player
s point of view, the mouth of the tunnel should look like the
main light source. The light should therefore fall off as the tunnel
descends. We can achieve this effect by multiplying the red, green,
and blue values of each tile
'
'
s colorTransform object by the depth of
the tile. Note that you can
s color-
Transform. You must assign it to a variable, which makes a copy,
modify the copy, and assign it back to the object. All transforms in
ActionScript work this way. We
'
t operate directly on an object
'
'
ve now created the tunnel and its
entire tile set. Let
s look at a few of the other functions the tunnel
uses, including one that is mentioned earlier.
'
protected function radiansToDegrees(value:Number):Number {
return value * (180/Math.PI);
}
protected function degreesToRadians(value:Number):Number {
return value * (Math.PI/180);
}
These two functions simply perform the conversion from radians
to degrees and vice versa that we have discussed earlier in this chap-
ter. For simplicity, they
re included in this class, but the smartest way
to utilize them would be as static methods of a math utilities class.
'
public function get radius():Number {
return _radius;
}
public function get sides():int {
return _sides;
}
public function get depth():int {
return _depth;
}
public function get tunnelTiles():Array {
return _tunnelTiles;
}
Search Nedrilad ::




Custom Search