Converting Flash Animation to Cocos2D(将 Flash 动画转换为 Cocos2D)
问题描述
我需要一种技术,给定一个单一但分层的 Flash 动画,将每一帧中每个关键影片剪辑的位置和旋转导出为 XML.
What I require is a technique, given a single, but layered Flash animation, to export the position and rotation of each key movie clip in every frame as XML.
代码将此信息读入 cocos2d-ready 格式会节省大量时间,但没有必要,因为我知道如何实现这一点.
Code to read in this information into a cocos2d-ready format would save a lot of time but isn't necessary as I know how to achieve this.
我们的艺术家经常使用 Flash 绘制矢量,并制作出精彩而令人印象深刻的动画.我们过去将这种艺术融入游戏的技术是将单独的动画导出为一系列 png,将它们粘贴到 sprite sheet 中,然后将它们转换为 CCAnimations.
Our artists often draw vector using Flash and have wonderful and impressive animations. Our technique in the past to put this art into our games is to export the separate animations as a sequence of pngs, stick them in a sprite sheet, and turn them into CCAnimations.
这种技术效果很好,借助 spritesheets 和 pvrtc,我们可以在 20MB 的空中下载限制中获得相当多的艺术作品.然而,随着我们的成长,我们正在寻求制作更大更好的游戏,这意味着更多的艺术!
This technique works well and we can get quite a lot of art into the 20MB over the air download limit thanks to spritesheets and pvrtc. As we grow, however, we are looking to make bigger and better games, and this would mean more art!
我现在想要实现的是大量减少艺术作品,方法是使用关键帧技术来模仿 Flash 行为,删除重复的艺术作品.
What I'd like to achieve now is a mass reduction in the amount of art by using a keyframing technique to mimic Flash behaviour, removing duplicate pieces of art.
即使用当前的技术,一个字符会占用:
i.e. Using the current technique, one character would take:
具有 10 帧(例如 100 * 300 分辨率,30k 像素)的步行序列将具有10,每个姿势的全尺寸人类.(总共 1000 * 300分辨率,一个动画 300k 像素)
A walk sequence with 10 frames (say 100 * 300 resolution, 30k pixels) would have 10, full sized humans in each stance. (for a total of 1000 * 300 resolution, 300k pixels for one animation)
说出 5 个相似的动画,总共 150 万像素
Say 5 similar animations for a total of 1.5 million pixels
相同角色的期望结果:
1 条右腿:(40 * 30, 1200 像素)
1 right leg: (40 * 30, 1200 pixels)
1 条左腿:(40 * 30, 1200 像素)
1 left leg: (40 * 30, 1200 pixels)
1 个躯干(50 * 50, 2500 像素)
1 torso (50 * 50, 2500 pixels)
1 个左臂(40 * 30, 1200 像素)
1 left arm (40 * 30, 1200 pixels)
1 个右臂(40 * 30, 1200 像素)
1 right arm (40 * 30, 1200 pixels)
1 个头(30 * 30, 900 像素)
1 head (30 * 30, 900 pixels)
所有动画的总和(8200 像素)
还有一个xml文件来解释每一帧的每一部分的变换.
And an xml file to explain the transform of each part for each frame.
我对 Flash 的了解有限.我已经导出了很多艺术作品,所以这不是问题,但我在 Actionscript 或导出其他信息方面没有太多经验.我注意到 Export Motion as XML 选项,但它没有提供我需要的信息(它不会遍历影片剪辑的子级来获取它们的变换).
My knowledge of Flash is limited. I have exported a LOT of art, so that's not a problem, but I don't have much experience in Actionscript or in exporting other information. I have noticed the Export Motion as XML option but it doesn't provide the information I need (It doesn't traverse to the children of movie clips to get their transform).
Objective-c 方面的问题不大,我知道如何解析 XML,不过如果有人也写过这个,如果你愿意分享,我将不胜感激.
The Objective-c side of things is less of a problem, I know how to parse XML, though if somebody has already written this too, I'd be very grateful if you'd like to share.
推荐答案
我从来没有发现任何现有的工具,所以最终学习了一点 ActionScript 并自己编写了解决方案.
I never did find out about any existing tools and so ended up learning a bit of ActionScript and writing the solution myself.
很遗憾,由于公司政策,我无法分享我的代码,但我会概述我需要采取的步骤
Unfortunately due to corporate policies I won't be able to share my code but I will outline the steps I needed to take
- 逐帧浏览
- 让孩子们在该框架上的舞台上并注意他们的变换
- 遍历他们的每个孩子,并注意他们与父母之间的转换
- 递归执行此操作,直到孩子没有孩子或您已到达 DrawingObject
- 将信息保存为 XML
- 从库中导出您需要的每个符号并添加到精灵表中.(我是用 JSFL 做的)
- XML 应该包含一组框架,每个框架都有一个子框架的列表,并且递归地列出它们的每个子框架.每个子节点都包含变换信息.
- 读入此 XML,在您找到动画帧时将子代添加到动画帧中,并将子代添加到它们各自的父代.应用孩子的变换.
希望这对其他人有所帮助.
Hope this helps somebody else.
这篇关于将 Flash 动画转换为 Cocos2D的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将 Flash 动画转换为 Cocos2D
基础教程推荐
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01