|
@@ -1,13 +1,13 @@
|
|
class Base2D extends hxd.App {
|
|
class Base2D extends hxd.App {
|
|
|
|
|
|
- var spr : h2d.Sprite;
|
|
|
|
|
|
+ var obj : h2d.Object;
|
|
var tf : h2d.Text;
|
|
var tf : h2d.Text;
|
|
|
|
|
|
override function init() {
|
|
override function init() {
|
|
- // creates a new sprite and put it at the center of the sceen
|
|
|
|
- spr = new h2d.Sprite(s2d);
|
|
|
|
- spr.x = Std.int(s2d.width / 2);
|
|
|
|
- spr.y = Std.int(s2d.height / 2);
|
|
|
|
|
|
+ // creates a new object and put it at the center of the sceen
|
|
|
|
+ obj = new h2d.Object(s2d);
|
|
|
|
+ obj.x = Std.int(s2d.width / 2);
|
|
|
|
+ obj.y = Std.int(s2d.height / 2);
|
|
|
|
|
|
// load the haxe logo png into a tile
|
|
// load the haxe logo png into a tile
|
|
var tile = hxd.Res.hxlogo.toTile();
|
|
var tile = hxd.Res.hxlogo.toTile();
|
|
@@ -16,8 +16,8 @@ class Base2D extends hxd.App {
|
|
tile = tile.center();
|
|
tile = tile.center();
|
|
|
|
|
|
for( i in 0...15 ) {
|
|
for( i in 0...15 ) {
|
|
- // creates a bitmap into the sprite
|
|
|
|
- var bmp = new h2d.Bitmap(tile, spr);
|
|
|
|
|
|
+ // creates a bitmap into the object
|
|
|
|
+ var bmp = new h2d.Bitmap(tile, obj);
|
|
|
|
|
|
// move its position
|
|
// move its position
|
|
bmp.x = Math.cos(i * Math.PI / 8) * 100;
|
|
bmp.x = Math.cos(i * Math.PI / 8) * 100;
|
|
@@ -30,28 +30,6 @@ class Base2D extends hxd.App {
|
|
bmp.blendMode = Add;
|
|
bmp.blendMode = Add;
|
|
}
|
|
}
|
|
|
|
|
|
- #if (lime || !(cpp || hl))
|
|
|
|
- // load a true type font, can be not very high quality
|
|
|
|
- var font = hxd.Res.trueTypeFont.build(64);
|
|
|
|
-
|
|
|
|
- // creates a text display with the given font
|
|
|
|
- tf = new h2d.Text(font, s2d);
|
|
|
|
-
|
|
|
|
- // set the text color
|
|
|
|
- tf.textColor = 0xFFFFFF;
|
|
|
|
-
|
|
|
|
- // adds a red shadow
|
|
|
|
- tf.dropShadow = { dx : 3, dy : 3, color : 0xFF0000, alpha : 0.8 };
|
|
|
|
-
|
|
|
|
- // set the text color
|
|
|
|
- tf.text = "Héllò h2d !";
|
|
|
|
-
|
|
|
|
- // set the text position
|
|
|
|
- tf.x = 20;
|
|
|
|
- tf.y = s2d.height - 80;
|
|
|
|
-
|
|
|
|
- #end
|
|
|
|
-
|
|
|
|
// load a bitmap font Resource
|
|
// load a bitmap font Resource
|
|
var font = hxd.Res.customFont.toFont();
|
|
var font = hxd.Res.customFont.toFont();
|
|
|
|
|
|
@@ -69,19 +47,19 @@ class Base2D extends hxd.App {
|
|
// if we the window has been resized
|
|
// if we the window has been resized
|
|
override function onResize() {
|
|
override function onResize() {
|
|
|
|
|
|
- if( spr == null ) return;
|
|
|
|
|
|
+ if( obj == null ) return;
|
|
|
|
|
|
- // center our sprite
|
|
|
|
- spr.x = Std.int(s2d.width / 2);
|
|
|
|
- spr.y = Std.int(s2d.height / 2);
|
|
|
|
|
|
+ // center our object
|
|
|
|
+ obj.x = Std.int(s2d.width / 2);
|
|
|
|
+ obj.y = Std.int(s2d.height / 2);
|
|
|
|
|
|
// move our text up/down accordingly
|
|
// move our text up/down accordingly
|
|
if( tf != null ) tf.y = s2d.height - 80;
|
|
if( tf != null ) tf.y = s2d.height - 80;
|
|
}
|
|
}
|
|
|
|
|
|
override function update(dt:Float) {
|
|
override function update(dt:Float) {
|
|
- // rotate our sprite every frame
|
|
|
|
- if( spr != null ) spr.rotation += 0.01 * dt;
|
|
|
|
|
|
+ // rotate our object every frame
|
|
|
|
+ if( obj != null ) obj.rotation += 0.01 * dt;
|
|
}
|
|
}
|
|
|
|
|
|
static function main() {
|
|
static function main() {
|