Update : Adding Images into the game [HaxeFlixel]

The HaxeFlixel maintainer/creator ( Alexander Hohlov ) points out that it’s much easier to embed image using the simple code

loadGraphic(“assets/paper-mario.jpg”, true, true, 180,233);

Yes, it’s true. No need to create classes to handle these images. But In the long run, Using Class is more efficient.

By using Assets Class, we may control the image loaded, hence the quality. If you wants to publish the game into several devices with several image Quality, you can easily use Conditional Statement (If-else) to load HQ sprites for several device screen size.

package;
import nme.display.Bitmap;
import nme.media.Sound;
import nme.Assets;

<strong>import nme.Lib;</strong>

class GameAssets 
{
	public static var imgMario:Class = ClassImgMario;
}

class ClassImgMario extends Bitmap
{
	public function new() 
	{ 
	<strong> if (Lib.current.stage.stageWidth &gt; 1000) { super(Assets.getBitmapData("assets/paper-mario-HQ.jpg")); } else { </strong>
		super(Assets.getBitmapData("assets/paper-mario.jpg")); 
	<strong> } </strong>
	}
}

Anyway, thanks Alexander Hohlov for pointing it out. Your works is highly appreciated. I can’t help you with the HaxeFlixel Coding , so I help you in my own way (writing tutorials). =)

thank you for reading this tutorial. As promised , the next tutorial is about Sprite animation