Search code examples
htmlhaxe

Can I mask a Sprite in Haxe NME HTML5 target?


I have a really large PNG file that I would like to animate over time. Basically a "sprite sheet" using plain old HTML div background-position-x and y you can do this pretty easy. In Haxe NME I would like to so something like the following.

var sprite1 = new Sprite();
addChild(sprite1);

var spriteSheet = new Bitmap(Assets.getBitmapData("assets/someasset.png");
sprite1.addChild(spriteSheet);

var spriteMask = new Sprite();
spriteMask.graphics.beginFill(0xff0000, 1);
spriteMask.drawRect(0,0,400, 330);
spriteMask.endFill();
addChild(spriteMask);

sprite1.mask = spriteMask;

In Flash target this seems to work just fine but in HTML5 target all I get is a red square over the top of my sprite.

Any thoughts on how to get this to work. It would be really helpful to create animations using something like this.


Solution

  • Sadly neither mask nor scrollRect are implemented in Jeash (NME's HTML5). https://bugs.launchpad.net/jeash/+bug/1001797