将Flash动画转换为Cocos2D [英] Converting Flash Animation to Cocos2D

查看:176
本文介绍了将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.

这种技术工作得很好,我们可以得到相当多的艺术到20MB的空气下载限制由于spritesheets和pvrtc。然而,随着我们的成长,我们正在寻找更大更好的游戏,这将意味着更多的艺术!

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.

ie使用当前技术,一个字符将采取:

i.e. Using the current technique, one character would take:


具有10帧(例如100×300分辨率,30k像素)的步行序列将具有
10,每个姿态的全尺寸人。 (总共1000 * 300
分辨率,一个动画 300k像素

说5个类似的动画, 150万像素

Say 5 similar animations for a total of 1.5 million pixels

同一个字符的所需结果:

The desired outcome for the same character:


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 * 1200像素)

1 left arm (40 * 30, 1200 pixels)

1个右臂(40 * 30,1200像素)

1 right arm (40 * 30, 1200 pixels)

1个头,900像素)

1 head (30 * 30, 900 pixels)

所有动画 总共(8200像素)

Total (8200 pixels) for all animations

和一个xml文件,用于解释每个帧的每个部分的变换。

And an xml file to explain the transform of each part for each frame.

。我已经出口了大量的艺术,所以这不是一个问题,但我没有太多经验在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

  • Step through each frame
  • Get the children on the stage on that frame and note their transform
  • Go through each of their children and note their transform with relation to their parent
  • Do this recursively until the children have no children or you have reached a DrawingObject
  • Save the information as XML

  • 从库中导出您需要的每个符号,精灵表。 (我这样使用JSFL)


  • XML应包含一组框架,每个框架都有一个子元素列表,并递归地包含每个子元素。

  • 读取此XML,将动画的帧添加到动画的帧中,并将子帧添加到其父项。应用儿童的转换。

希望这有助于别人。

这篇关于将Flash动画转换为Cocos2D的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆