Game Development Reference
In-Depth Information
}
}
public function render() : void {
if (isFalling) {
y=nextYLocation;
if (y >= fallEndY) {
y = fallEndY;
isFalling=false;
}
}
if (isFading) {
alpha -= fadeValue;
if (alpha <=0) {
alpha = 0;
isFading = false;
}
}
}
public function onMouseDownListener(e:MouseEvent) : void {
dispatchEvent(new CustomEventClickDie(CustomEventClickDie.EVENT_CLICK_DIE, this));
}
public function makeDieClicked() : void {
this.filters=[new flash.filters.GlowFilter(0xFFFF00,70,4,4,3,3,false,false)];
}
public function makeDieClickedComputer() :void {
this.filters=[new flash.filters.GlowFilter(0xFF0000,70,4,4,3,3,false,false)];
}
}
}
By the way, with a few changes, we could have used the Block class as the basis for Die and
extended it in an object-oriented fashion. However, we will leave that effort for you to explore
yourself.
Creating the CustomEventClickDie class
The CustomeEventClickDie class is a minor rewrite of the CustomEventClickBlock class from
Color Drop in Chapter 8. In theory, we could have simply reused CustomEventClickBlock , or
even created a reusable class and put it into the com.efg.framework package. However, we
chose to simply rewrite the class here, because we wanted to reinforce the idea that you can
create these kinds of custom events for your games. While the game framework is a very
helpful tool, it will not write games for you. There will always be times to create classes that are
local to your game class.
Search WWH ::




Custom Search