在 ActionScript 中读取和绘制像素字体
我创建了一个小像素字体,我想在 Flash 游戏中使用它。
每个字母高 6 像素,宽 7 像素。我保存了一个 PNG 文件,其中 AZ 的所有字母都彼此相邻排列。
基本上,我希望能够有一个系统,我可以指向 PNG 文件并说“A 是位置 (0,0) 到 (7,6),B 是位置 (7,0) 到 (14, 6) 等”,然后将它们分别呈现在屏幕上作为我的字体中的字母。
我之所以这样做是因为观看了 Notch(《我的世界》的创建者)在的视频中所做的事情他正在制作Megagun。
那么,以前有人做过这样的事情吗?有没有一个简单的库可以让我做到这一点?
谢谢!
I've created a small pixel-font that 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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您所说的称为“Sprite Sheet”,并且有大量项目可以执行此类操作。最好的起点可能是 Ben Silvis 的 AS3:使用 Sprite Sheets 简介。另请查看AS3:SpriteSheet 类 - 提取精灵。
还有一些用于从 Flash 动画创建精灵表的工具,例如 Keith Peters 的 SWFSheet
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