由帧动画的iOS框架,通过脚本 [英] iOS frame by frame animation, by script

查看:111
本文介绍了由帧动画的iOS框架,通过脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关于由帧动画(帧如帧动画框架几个问题的SO >和其他类似的问题),但是我觉得我的是不同的,所以在这里不用。

There are a few SO questions regarding frame by frame animation (such as frame by frame animation and other similar questions), however I feel mine is different so here goes.

这是部分从别人用很少的ios体验一个设计问题。

This is partially a design question from someone with very little ios experience.

我不知道一帧一帧是什么,我想这样做,让我描述的正确描述。基本上,我有一个动画电影剧本,我想打这个剧本。结果
这个脚本是描述一组场景的JSON文件。在每个场景有一些元件,诸如背景图像,与它们的位置和背景音片段行动者的列表。此外,对于每个演员和背景有这么重presents它的图像文件。 (这是一个有点复杂 - 每个演员都有一个行为,如它是如何闪烁,他怎么说话等等)。所以,我的工作就是按照给定的脚本引用行为和背景以及每一帧,将演员在其指定的位置,画出正确的背景和播放声音文件。结果
这部电影可能会被暂停,擦洗向前或向后类似于YouTube的视频播放器的功能。结果
大多数我见过的问题,这是指帧一帧动画有不同的要求比我(我将列出一些要求更高版本)。他们通常建议使用的 animationImages 的一个的的UIImageView 的财产。这是罚款动画按钮或一个复选框,但他们都认为有一个短期和predefined设置需要播放的图像。结果
如果我去animationImages我不得不pre-创建的所有图像前面,我的纯猜测是,它不能扩展(想想30fps的一分钟,你会得到60 * 30 = 1800图片,再加上磨砂和暂停/播放能力,似乎在这种情况下,具有挑战性的)。

I'm not sure "frame by frame" is the correct description of what I want to do so let me describe that. Basically, I have a "script" of an animated movie and I'd like to play this script.
This script is a json file which describes a set of scenes. In each scene there are a few elements such as a background image, a list of actors with their positions and a background sound clip. Further, for each actor and background there's an image file that represents it. (it's a bit more complex - each actor has a "behavior" such as how it blinks, how he talks etc). So my job is to follow the given script referencing actors and background and with every frame, place the actors in their designated position, draw the correct background and play the sound file.
The movie may be paused, scrubbed forward or backward similar to youtube's movie player functionality.
Most of the questions I've seen which refer to frame-by-frame animation have different requirements than I do (I'll list some more requirements later). They usually suggest to use animationImages property of a UIImageView. This is fine for animating a button or a checkbox but they all assume there's a short and predefined set of images that need to be played.
If I were to go with animationImages I'd have to pre-create all the images up front and my pure guess is that it won't scale (think about 30fps for one minute, you get 60*30=1800 images. Plus the scrub and pause/play abilities seem challenging in this case).

所以我在寻找这样做的正确方法。我的直觉,而我学习更多,我去,是有可能实现这个三个或四个主要方式。

So I'm looking for the right way to do this. My instinct, and I'm learning more as I go, is that there are probably three or four main ways to achieve this.


  1. 将采用酷动画和定义关键点和过场动画的B / W的关键点。例如,如果一个演员必须在A点在时间t1和B点在时间t2那么我需要做的动画之间有什么在不在。我已经做了过去在ActionScript类似的东西,这是不错,但尤其具有挑战性落实擦洗动作,并保持everytyhing同步,所以我没有办法的大风扇。试想一下,你必须实现在动画或擦洗中间暂停,以动画的中间。这是可行的,但并不令人愉快。

  2. 设置一个计时器,说30次,并在每一个刻度参考模型(该模型是与演员的描述和背景沿着脚本JSON文件),并得出需要在这个时候要绘制什么。使用Quartz 2D的API和drawRect中。这可能是一个简单的办法,但我没有足够的经验来告诉它要如何在不同的设备上工作,可能是CPU明智的,这一切都取决于计算,我需要在每个tick的数量和金额工作需要的ios绘制的一切。我没有预感。

  3. 类似2,但使用OpenGL绘制。我preFER 2 B / C的API是更容易,但也许是明智的资源OpenGL是更合适的。

  4. 使用一个游戏框架,如的cocos2d 这我之前从来没有使用过,但似乎被解决或多或少类似的问题。他们似乎有一个很好的API,所以我会很高兴,如果我能找到我的所有要求他们回答。

  1. By using Core Animations and defining "keypoints" and animated transitions b/w those keypoints. For example if an actor needs to be at point A at time t1 and point B at time t2 then all I need to do it animate what's in between. I've done something similar in ActionScript in the past and it was nice but was particularly challenging to implement the scrub action and keep everytyhing in sync so I'm not a big fan of the approach. Imagine that you have to implement a pause in the middle of an animation or scrub to a middle of an animation. It's doable but not pleasant.
  2. Set a timer for, say 30 times a second and on every tick consult the model (the model is the script json file along with the description of the actors and the backgrounds) and draw what needs to be drawn at this time. Use Quartz 2D's API and drawRect. This is probably the simple approach and but I don't have enough experience to tell how well it's going to work on different devices, probably CPU wise, it all depends on the amount of calculations I need to make on each tick and the amount of effort it takes ios to draw everything. I don't have a hunch.
  3. Similar to 2, but use OpenGL to draw. I prefer 2 b/c the API is easier but perhaps resource wise OpenGL is more suitable.
  4. Use a game framework such as cocos2d which I'd never used before but seems to be solving more or less similar problems. They seem to have a nice API so I'd be happy if I could find all my requirements answered by them.

顶上我刚才所描述的要求(播放短片给它的脚本文件和演员,背景和声音的描述),还有另一套要求 -

Atop of the requirements I'd just described (play a movie given it's "script" file and a description of the actors, backgrounds and sounds), there's another set of requirements -


  • 电影需要在全屏模式或部分屏幕模式(其中屏幕的其余部分是专门为其他控件)
  • 来播放
  • 我开始与自然的一个iPad应遵循的iphone。

  • 我希望能够创造这部电影的本地电话使用(在我的应用程序画廊显示它)的缩略图。缩略图可能只是影片的第一帧。

  • 我希望能够出口的结果作为一个电影的东西,可以很容易地上传到YouTube或Facebook。

因此​​,最大的问题是在这里是否有任何建议1-4实现我的想法(或其他人,你可能会建议)中能以某种方式导出这样的电影。结果
如果四个失败的电影导出任务那么我心目中的替代品。另一种方法是使用它运行的ffmpeg并接受所有电影图像的捆绑的服务器(我不得不得出他们在电话,并上传至其序列断绝),然后服务器会编译所有图片与他们的配乐,以一个单一的电影。结果
显然,为了简单起见我preFER做到这一点的服务器少,即能够将电影从iPhone中导出,但如果这是过分的要求,那么最后一个要求是,至少能导出设置(电影中的关键帧)的所有图像,这样我可以捆绑他们,并上传到服务器。

So the big question here is whether any of the suggested 1-4 implementations I have in mind (or others you might suggest) can somehow export such a movie.
If all four fail on the movie export task then I have an alternative in mind. The alternative is to use a server which runs ffmpeg and which accept a bundle of all the movie images (I'd have to draw them in the phone and upload them to the sever by their sequence) and then the server would compile all the images with their soundtrack to a single movie.
Obviously to keep things simple I'd prefer to do this server-less, i.e. be able to export the movie from the iphone but if that's too much to ask then the last requirement would be to at least be able to export the set of all images (keyframes in the movie) so I can bundle them and upload to a server.

电影的长度被认为是一个或两分钟。我希望这个问题不是太长久,而且很明显...

The length of the movie is supposed to be a one or two minutes. I hope the question wasn't too long and that it's clear...

谢谢!

推荐答案

写得很好的问题。为您的视频出口需要退房AVFoundation(可作为的iOS 4的)。如果我要实现这一点,我想尝试#1或#4。我觉得#1可能是最快的只是尝试,但是这可能是因为我没有与任何的cocos2d经验。我想你将能够暂停和擦洗CoreAnimation:检查出它采用CAMediaTiming协议

well written question. for your video export needs check out AVFoundation (available as of iOS 4). If I were going to implement this, I'd try #1 or #4. I think #1 might be the quickest to just try out, but that's probably because I don't have any experience with cocos2d. I think you will be able to pause and scrub CoreAnimation: check out the CAMediaTiming protocol it adopts.

这篇关于由帧动画的iOS框架,通过脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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