Skip to content

Instantly share code, notes, and snippets.

@RichardMarks
Created January 29, 2011 20:23
Show Gist options
  • Save RichardMarks/802157 to your computer and use it in GitHub Desktop.
Save RichardMarks/802157 to your computer and use it in GitHub Desktop.
// sprites.png is 640x240 with the left 320x240 holding player sprite frames
// and the right 320x240 holding the enemy frames
[Embed(source="../assets/sprites.png")] private const SPRITES_PNG:Class;
var sprites:BitmapData = (new SPRITES_PNG).bitmapData;
var playerSprites:BitmapData = new BitmapData(320, 240);
var enemySprites:BitmapData = new BitmapData(320, 240);
playerSprites.copyPixels(sprites, new Rectangle(0,0, 320, 240), new Point);
enemySprites.copyPixels(sprites, new Rectangle(320,0, 320, 240), new Point);
var playerSpritemap:Spritemap = new Spritemap(playerSprites, 32, 32);
var enemySpritemap:Spritemap = new Spritemap(enemySprites, 32, 32);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment