O'Reilly logo

haXe 2 by Benjamin Dasnois

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action—Drawing the character

In order to draw our character on the screen, we will simply have to create an instance of the Guy class and add it to the stage.

We will also, as there is only one instance of it, store it as a static variable of our main class. So, here is our Game.hx file:

class Game
{
static var player : Guy;
public static function main(): Void
{
player = new Guy();
//Add it to the stage
flash.Lib.current.stage.addChild(player);
//Place it at the good place on stage.
player.x = 200;
player.y = 300;
player.width=50;
player.height = 100;
}
}

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required