Haxe questions

8 posts

Flag Post

Hey I’m finally working on a project again, I’m using haxe because I thought it would be interesting, but I’m having some really basic issues that I can’t seem to solve.

First off I can’t get debug to work at all. It just absolutely refuses to stop on breakpoints. I’m using FD for my IDE.

Secondly, I can’t get copypixels to work at all.

This works and displays my image:

var davetest:Bitmap = new Bitmap();
		
davetest.bitmapData = Assets.getBitmapData("assets/DaveHeadIdle.png");
		
addChild(davetest);

This gives me an empty bitmap:

var davetest:Bitmap = new Bitmap();
	
davetest.bitmapData = Assets.getBitmapData("assets/DaveHeadIdle.png");
		
var davetest2:Bitmap = new Bitmap();
		
davetest2.bitmapData = new BitmapData(davetest.bitmapData.width, davetest.bitmapData.height);
		
davetest2.bitmapData.copyPixels(davetest.bitmapData, new Rectangle(davetest.bitmapData.width, davetest.bitmapData.height), new Point());
		
addChild(davetest2);

Thank you in advance.

 
Flag Post

I don’t use the FD IDE, but the Haxe compiler has some debug flags one can activate, maybe that is needed?

As for your bitmapdata problem, try something like drawing a red square to davetest before you draw davetest to davetest2, and see if that red square is shown or not. That will tell you whether the image is not being embedded at all, or if there is something wrong when it’s being drawn to the other bitmap.

 
Flag Post

The debug flag is being sent when I compile and it’s using the default flash debugger. I just can’t get it to actually do any debugging :\

Running process: D:\Haxe\Haxe\haxelib.exe run nme run "C:\Users\Obscura\Dropbox\TestProject\TestProject.nmml" flash -debug -DSWF_PLAYER="C:\Program Files (x86)\FlashDevelop\Tools\flexlibs\runtimes\player\11.1\win\FlashPlayerDebugger.exe"

The image is being embedded correctly. The first example works fine.

 
Flag Post

hmm, while googling around I found this:

“For haxe it must be enabled per project – see ‘Enable Debugger’ in the Project’s Compiler options.”

Could you check that option?

As for the bitmaps, something must then be wrong with the second bitmap. Try drawing directly with some drawing commands to see if it’s working at all. Usually when something like this happens to be it turns out that I was creating it with 0 width and height properties, or something of that sort.

 
Flag Post

Flag is set.

.draw works.

Works:

davetest.bitmapData = Assets.getBitmapData("assets/DaveHeadIdle.png");
		
var davetest2:Bitmap = new Bitmap();
		
davetest2.bitmapData = davetest.bitmapData;

addChild(davetest2);

Doesn’t work:

davetest.bitmapData = Assets.getBitmapData("assets/DaveHeadIdle.png");
		
var davetest2:Bitmap = new Bitmap();
		
davetest2.bitmapData = davetest.bitmapData;
		
davetest.bitmapData = new BitmapData(davetest.bitmapData.width, davetest.bitmapData.height);
		
davetest.bitmapData.copyPixels(davetest2.bitmapData, new Rectangle(davetest.bitmapData.width/2, davetest.bitmapData.height), new Point(0, 0));

addChild(davetest);

Also doesn’t work if I use constants instead of the width/height calls.

 
Flag Post

new Rectangle(0, 0, davetest.bitmapData.width/2, davetest.bitmapData.height)

or just

davetest.bitmapData.rect

??

 
Flag Post

I’m an idiot. I didn’t think rectangles had an x/y coord in addition to their width/height.

Solved my problem. Thanks a ton Amibtious.

 
Flag Post
Originally posted by JamesObscura:

I’m an idiot. I didn’t think rectangles had an x/y coord in addition to their width/height.

Solved my problem. Thanks a ton Amibtious.

When making a bitmap object from a bitmapData you want to put the bitmapData in the constructor

instead of:

var davetest2:Bitmap = new Bitmap();
davetest2.bitmapData = davetest.bitmapData;

you want

var davetest2:Bitmap = new Bitmap(davetest.bitmapData);