Game Development Reference
In-Depth Information
this.x = x;
this.y = y;
this.parentContainer = parentContainer;
this.circleColor = circleColor;
circle = new Shape();
circle.graphics.clear();
circle.graphics.lineStyle(1, circleColor);
circle.graphics.drawCircle(-1, -1, 2);
addChild(circle);
}
public function show():void {
parentContainer.addChild(this);
}
public function hide():void {
parentContainer.removeChild(this);
}
}
}
This class takes in a four parameters:
The x value for its screen location
The y value for its screen location
The parent display object that it will add and remove its self from
A color value for the viewable circle around the point
The LookAheadPoint instances need not show themselves to the player. They are turned off and
on with calls to the public show and hide functions.
Creating the CarBlitSprite class
The CarBlitSprite class is a child of the BlitSprite class introduced in Chapter 7. We have
added in some attributes that will be used by the game for controlling the car. These will be
identified in the DriveSheSaid.as code later in the chapter when they come into use. We have
also created an override of the updateTile function from the BlitSprite class to handle the
reverse direction for our car.
This added functionality will allow us to move the animation of the car tiles backward as well as
forward through the tileList array. The backward direction will allow us to display the car with
wheels moving in the opposite direction than the forward motion. To the player, the car will
appear to be moving in reverse.
This is the file location:
/source/classes/com/efg/framework/CarBlitSprite.as
And here is the source code for this class:
package com.efg.framework
{
import com.efg.framework.BlitSprite;
import com.efg.framework.TileSheet;
Search WWH ::




Custom Search