Game Development Reference
In-Depth Information
public function get vy():Number
{
return _vy;
}
public function set vy(value:Number):void
{
_vy = value;
}
The last methods in the class are just the accessors required by the
IBall interface. The x and y velocity values are simply stored as mem-
ber variables. We don
t do anything with these values since they are
set and read by the engine. The final result from this class is a ball
that looks and reacts like a real ball would as it moves around the
labyrinth.
'
HazardPit and StandardWall
These last two game classes exist simply to fulfill the interface
requirements for the game engine. As such, they implement their
respective interfaces, cache themselves as bitmaps, and that
'
sit.
Here both of them are back to back since they
'
re almost identical.
import com.flashgamebook.iphone.engines.labyrinth.IHazard;
final public class HazardPit extends Sprite implements IHazard
{
public function HazardPit()
{
cacheAsBitmap = true;
}
}
import com.flashgamebook.iphone.engines.labyrinth.IWall;
final public class StandardWall extends Sprite implements IWall
{
public function StandardWall()
{
cacheAsBitmap = true;
}
}
If we wanted to have a hazard that consisted of a spinning
blade or a wall that animated in some kind of nonstandard way,
we would create new classes similar to these and add the required
functionality. This is where the extra effort of programming to
interfaces bears fruit. Although both of these classes are Sprites,
there
'
snoreasonwecouldn
'
t use a MovieClip instead or extend
Search Nedrilad ::




Custom Search