Reading and drawing a pixel font in ActionScript
I've created a small pixel-font that开发者_C百科 I want to use in a Flash game.
Each letter is 6 pixels tall, and 7 pixels wide. I've saved a PNG file with all the letters from A-Z lined up next to each other.
Basically, I'd like to be able to have a system where I point to the PNG file and say "A is position (0,0) to (7,6), B is position (7,0) to (14, 6), etc" then render those individually on the screen as letters in my font.
I was inspired to do this by watching (the creator of Minecraft) Notch do it in a video of him making Megagun.
So, has anyone done anything like this before? Is there a simple library that will let me do it already?
Thanks!
What you are talking about is called a "Sprite sheet", and there are a ton of project out there that do this sort of thing. The best starting place is probably Ben Silvis' AS3: Intro to Using Sprite Sheets. Also check out AS3: SpriteSheet Class – Extracting Sprites.
There are also tools for creating sprite sheets from flash animations, such as SWFSheet by Keith Peters
精彩评论