Click en la imagen y controla al personaje con las teclas de dirección.
Estoy haciendo algunos experimentos con OpenFL. Muy rápido y potente a la hora de desarrollar aplicaciones Flash.
import flash.display.Sprite;
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.events.Event;
import openfl.Assets;
class Player extends Sprite {
var bitmapArray : Array
var i : Int= 0;
var moving_up : Bool = false;
var moving_down : Bool = false;
var moving_left : Bool = false;
var moving_right : Bool = false;
public function new () {
super ();
initialize();
}
public function initialize() {
bitmapArray = new Array();
var bitmap : Bitmap = new Bitmap();
bitmap.bitmapData = Assets.getBitmapData ("assets/images/player00.png");
bitmapArray.push(bitmap);
bitmap = new Bitmap();
bitmap.bitmapData = Assets.getBitmapData ("assets/images/player10.png");
bitmapArray.push(bitmap);
bitmap = new Bitmap();
bitmap.bitmapData = Assets.getBitmapData ("assets/images/player11.png");
bitmapArray.push(bitmap);
bitmap = new Bitmap();
bitmap.bitmapData = Assets.getBitmapData ("assets/images/player12.png");
bitmapArray.push(bitmap);
bitmap = new Bitmap();
bitmap.bitmapData = Assets.getBitmapData ("assets/images/player13.png");
bitmapArray.push(bitmap);
bitmap = new Bitmap();
bitmap.bitmapData = Assets.getBitmapData ("assets/images/player14.png");
bitmapArray.push(bitmap);
bitmap = new Bitmap();
bitmap.bitmapData = Assets.getBitmapData ("assets/images/player15.png");
bitmapArray.push(bitmap);
bitmap = new Bitmap();
bitmap.bitmapData = Assets.getBitmapData ("assets/images/player16.png");
bitmapArray.push(bitmap);
bitmap = new Bitmap();
bitmap.bitmapData = Assets.getBitmapData ("assets/images/player17.png");
bitmapArray.push(bitmap);
addChild(bitmapArray[i]);
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(evt:Event) {
if ( moving() ) {
removeChild(bitmapArray[i]);
i = (i + 1) % 9;
addChild(bitmapArray[i]);
}
if ( moving_up ) {
y = y - 1;
}
if ( moving_down ) {
y = y + 1;
}
if ( moving_left ) {
x = x - 1;
}
if ( moving_right ) {
x = x + 1;
}
}
public function moving() : Bool {
return (moving_up || moving_down || moving_left || moving_right);
}
public function up() {
moving_up = true;
}
public function down() {
moving_down = true;
}
public function left() {
moving_left = true;
}
public function right() {
moving_right = true;
}
public function stop() {
moving_up = false;
moving_down = false;
moving_left = false;
moving_right = false;
}
}
Ahora ademas de caminar puede cambiar de dirección, hacia arriba o hacia abajo.
Now, besides walking, the sprite changes direction upside or downside.
Ahora con universo esférico.
Now spherical universe.