Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The short answer is that you will want to use <a href="http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&amp;file=00001400.html" rel="nofollow noreferrer">BitmapData.copyPixels()</a> to copy only a small section from your source sprite sheet to your display sprite that is actually on the screen.</p> <p>Something like:</p> <pre><code>private function DrawSpriteIndex( displayBitmap:Bitmap, spriteSheet:Bitmap, spriteIndex:int ):void { var spriteW:int = 32; var spriteH:int = 32; var sheetW:int = 5; displayBitmap.bitmapData.copyPixels(spriteSheet.bitmapData, new Rectangle( (spriteIndex % sheetW) * spriteW, Math.floor(spriteIndex / sheetW) * spriteH, 32, 32), new Point(0,0) ); } </code></pre> <p>You may find these links helpful -- they helped me when I was learning this:</p> <ul> <li><a href="http://www.8bitrocket.com/2008/07/02/tutorial-as3-the-basics-of-tile-sheet-animation-or-blitting/" rel="nofollow noreferrer">http://www.8bitrocket.com/2008/07/02/tutorial-as3-the-basics-of-tile-sheet-animation-or-blitting/</a></li> <li><a href="http://www.8bitrocket.com/newsdisplay.aspx?newspage=13430" rel="nofollow noreferrer">http://www.8bitrocket.com/newsdisplay.aspx?newspage=13430</a></li> <li><a href="http://www.8bitrocket.com/newsdisplay.aspx?newspage=14591" rel="nofollow noreferrer">http://www.8bitrocket.com/newsdisplay.aspx?newspage=14591</a></li> <li><a href="http://www.8bitrocket.com/newsdisplay.aspx?newspage=15967" rel="nofollow noreferrer">http://www.8bitrocket.com/newsdisplay.aspx?newspage=15967</a></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload