0

我是 AS3 的新手,我正在尝试用它创建一个简单的游戏。
到目前为止,我已经能够绘制这样的图像:

[Embed(source = 'C:/mypath/myimage.png')]
public static var myImageClass:Class;
private var myImage:Bitmap = new myImageClass();

然后渲染 myImage。
但这仅绘制没有动画的图片。
我想要的是导入这张图片:

在此处输入图像描述

然后将图像切割成一系列子图像并从中绘制动画,而不是单个图像。我该怎么做?
谢谢!

4

2 回答 2

1

This is called "Blitting". You could accomplish it with fairly decent results, depending on your deployment target and how many animations you require, using BitmapData.copyPixels(), but it's more ideal to use the Starling Framework, which employs Stage3D hardware acceleration.

More here:

于 2012-10-20T16:34:50.857 回答
1

您正在寻找的是SpriteSheet支持。您可以轻松地自己编写或使用现有的库(例如Starling)。

这个想法是在每一帧绘制图像的一个区域来实际创建动画。根据精灵表的格式,您可能需要添加另一个文件来描述要绘制的每个矩形的位置。

这个页面解释了如何实现它。

于 2012-10-20T16:36:01.453 回答