Skip to content

Instantly share code, notes, and snippets.

@jgranick
Created October 2, 2012 21:46
Show Gist options
  • Save jgranick/3823511 to your computer and use it in GitHub Desktop.
Save jgranick/3823511 to your computer and use it in GitHub Desktop.
How to use nme.display.Tilesheet (NME recipe)
import nme.display.Sprite;
import nme.display.Tilesheet;
import nme.geom.Rectangle;
import nme.Assets;
public class TilesheetExample extends Sprite {
public function new () {
super ();
var tilesheet = new Tilesheet (Assets.getBitmapData ("example.png"));
tilesheet.addTileRect (new Rectangle (0, 0, 100, 100));
tilesheet.addTileRect (new Rectangle (100, 0, 100, 100));
tilesheet.drawTiles (graphics, [ 0, 0, 0, 100, 0, 1 ]);
}
}
@sergey-miryanov
Copy link

I can't find Tilesheet file at source tree (under nme.display), so I have a question - does addTileRect return ID of new created tile?

@thomasuster
Copy link

I can't find Tilesheet under nme.display either, only browser.display and native.display...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment