Hello,
I am currently trying to rewrite the tile game code of http://www.tonypa.pri.ee/ in AS 3.0 and I am running into some issues. The first thing that gets me is the use of prototypes.
Also I change the code base to use the Sprite class
game.Tile0.prototype.walkable = true;
game.Tile0.prototype.frame = 1;
How does a prototype play into the roll of a package in AS 3? Does it exist? I think I understand the ideal of a prototype (a single property of a var that differs from any other property).
package {
import flash.display.Sprite;
public class MyGame extends Sprite {
private var myMap:Array = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1], [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]];
private var speed:Number = 0;
private var damage:Number = 0;
private var fuel:Number = 1000;
public var game:Array = {tileW:30, tileH:30, currentMap:1, visx:7, visy:5};
public function game.Tile0():void { };
game.Tile0.prototype.walkable = true;
game.Tile0.prototype.frame = 1;
public function takeOff():void {
// . . .
}
public function crash():void {
// . . .
}
public function shoot():void {
// . . .
}
public function selfDestruct():void {
// . . .
}
}
}