Game Development Reference
In-Depth Information
Figure 9-5. The dice tile sheet with the chosen tile highlighted (for illustration only)
There is one more significant addition to the Block class that we made to create the Die class. It
is the following function:
public function makeDieClickedComputer() : void {
this.filters=[new flash.filters.GlowFilter(0xFF0000,70,4,4,3,3,false,false)];
}
Notice, that this function is nearly identical to the following function:
public function makeDieClicked() : void {
this.filters=[new flash.filters.GlowFilter(0xFFFF00,70,4,4,3,3,false,false)];
}
makeDieClickedComputer simply makes the dice red instead of yellow when they are clicked. Why
two function instead of one? It's lazy coding folks, end of story. We apologize. We could have
passed in the color value to change instead of making two functions, but we thought this example
would help illustrate the computer AI a bit more than strictly optimized code.
The full code of the Die class follows:
package com.efg.games.dicebattle
{
import flash.filters.GlowFilter;
import flash.events.MouseEvent;
import flash.display.Bitmap;
import flash.display.BitmapData;
import com.efg.framework.BlitSprite;
import com.efg.framework.TileSheet;
public class Die extends BlitSprite {
public var dieColor:Number;
public var dieValue:Number;
Search WWH ::




Custom Search