在 Flash 中重用动画
好的,我是 Flash 新手,所以这是一个如何提问的问题,也是一个最佳实践问题。
我正在尝试制作一款游戏,其中用户拥有一个充满瓷砖的棋盘,类似于内存。我制作了一个图块,看起来不错,然后在上面添加了补间动画。
- 第 1 帧有 stop();
- 第 2 帧 -> X 具有补间动画
- 第 X 帧发出自定义事件
然后在舞台上:
- mc.gotoAndPlay(2);
- addEventListener(mc, "my_custom_event");
- 处理事件,知道动画已完成
因此我可以在元件的时间轴上添加许多更复杂的动画,并调用 gotoAndPlay(57)、gotoAndPlay(104) 等,每次触发不同的动画。
我的问题是我需要添加很多新的图块,几十个。从一个图块到另一个图块唯一改变的是我正在使用的图像;动画完全相同,只是位图不同(大小相同)。所以我想避免的是拥有 50 个不同的影片剪辑并向每个剪辑添加所有动画和事件代码。
我曾想过在符号上放一个空容器,然后对其进行补间。我打算将正确的图形添加到第 1 帧上的容器中。但是符号本身在设计时是空的,因此在每个关键帧处它都会变回空。
有什么好的方法可以实现这个目标呢?
感谢您的任何建议!
Ok, I'm new to flash, so this is sort of a how to question, and sort of a best practices question.
I'm trying to make a game where the user has a board full of tiles, similar to memory. I made one tile, it looks good, and I put a motion tween on it.
- Frame 1 has stop();
- Frame 2->X has a motion tween
- Frame X emits a custom event
Then on the stage:
- mc.gotoAndPlay(2);
- addEventListener(mc, "my_custom_event");
- handle the event, knowing the animation is finished
So I can add many more complicated animations on the symbol's timeline, and call gotoAndPlay(57), gotoAndPlay(104), etc., each time triggering a different animation.
My problem is that I need to add lots of new tiles, dozens of them. The only thing that changes from tile to tile is the image I'm using; the animations are exactly the same, just a different bitmap(all the same size). So what I'd like to avoid is having 50 different movie clips and adding all the animations and event code to each one.
I had thought of putting an empty container on the symbol, and tweening that. I was going to add the proper graphic to the container on frame 1. But the symbol itself is empty at design time, so at every keyframe it goes back to empty.
What's a good way to accomplish this?
Thanks for any advice!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您在 swf 的舞台上有一个动画的空白矩形精灵(并且它是那里唯一的子元素),您可以使用
Loader
类将其加载到主应用程序中,然后使用(Loader. content as Sprite).getChildAt(0).graphics.beginBitmapFill(/*您的图块位图*/)
将其转换为您需要的图块if you have an animated blank rectangular sprite on the stage of an swf (and it's the only child there) you may load it into the main app using the
Loader
class and then use(Loader.content as Sprite).getChildAt(0).graphics.beginBitmapFill(/*your tile bitmap*/)
to convert it to the tile you need