Game Development Reference
In-Depth Information
The step class
The step class is very simple. It is a sprite representation of the 2D art asset. The
following is the source code for the class:
package jjf.game
{
import flash.display.BitmapData;
import flash.display.Sprite;
import mx.core.BitmapAsset;
public class Step extends Sprite
{
public static var WIDTH:int;
[Embed(source="jjf\\rsrc\\step.png")]
public static const StepClass: Class;
public function Step()
{
super();
var bma:BitmapAsset;
bma = new StepClass() as BitmapAsset;
var bmd:BitmapData = bma.bitmapData;
graphics.beginBitmapFill(bmd);
graphics.drawRoundRect(0, 0,
bmd.width,
bmd.height,
7, 7);
graphics.endFill();
WIDTH = bmd.width;
}
}
The frog class
The Frog class, in addition to drawing itself depending on its spot and position in the
race, updates its position coordinates on the screen. The m_spot property determines
which of the 10 spots the frog is currently at. If there is more than one frog in the spot,
the m_position property determines at which position the frog is at; 0 being
the bottommost. With any update to m_spot or m_position , the x and y of the frog is
also updated.
 
Search WWH ::




Custom Search