如何在抖动效果上制作动画图像?
我已经实现了游戏应用程序。我想在其中对图像的某些区域进行抖动效果动画。如何可能,请给我建议。
编辑: 我的确切疑问是: 在我的游戏应用程序中,有一个图像。现在我选择了图像的某个区域框架。现在我正在摇动 iPhone,那么只有框架图像的选定区域必须是动画的。
I have implemented game application.In which i want to animate some area of images on shake effect.How it possible please give me advice.
Edit:
My excatly query is that:
In my game application there is one image.Now i am selected some area frame of image.now i am shaking iphone then only selected area of frame image must be animate.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个框架......然后您可以在建议的文档中获得更多详细信息。这确实很简单,但具有随机性,您可以用自己的图像进行实例化。我创建了一个图像容器作为 UIViewController,并在我的 main(您的 AppDelegate 或 RootViewController)中创建 viewDidLoad 中的实例。必须在 AppDelegate 中重载的方法(代码位于帖子末尾)以便接收震动,包括:
您成为viewWillAppear中的响应者并且必须启用设备通知(已验证是否存在已记录的错误),因此调用运动方法。
我喜欢放一个 NSLog(@"%s", FUNCTION);在我所有第一次编写的方法中声明,这样我可以快速确定是否缺少某些内容来获取我的事件、正确初始化等。这只是我的风格。
AnimatedImage.h isA ViewController
AnimatedImage.m
这个“根或主”委托是一个 UIViewController。我留下了细节以显示其简单性,但仍然留下了我认为对于首次调试至关重要的“跟踪”代码。另外,顺便说一句,我相信您必须重载motionBegan,即使您只需要motionEnded 事件。我记得我的应用程序不起作用,然后我添加了motionBegan,它开始调用motionEnded。那样是有道理的,但我没有任何文档来支持它。运行后进行一个简单的实验就可以证实或否定我的评论。
这段代码确实有效——但如果我删掉了太多细节,只需询问,我会确保添加足够的内容来帮助您。这对我来说是一项非常有意义的任务,我很高兴与在相同经历中寻求帮助的人分享它。
Here is a skeleton ... then you can get more detail at the suggested docs. This is real simple-minded but has a randomization and you can instantiate with your own image. I created an image container as a UIViewController and in my main (either your AppDelegate or the RootViewController) you create the instance in viewDidLoad. The methods that have to be overloaded in your AppDelegate, (the code is at the end of the post) so it receives shakes, are:
You become a responder in viewWillAppear and you have to enable the device notifications (verified that there is a documented bug) so the motion methods get invoked.
I like to put an NSLog(@"%s", FUNCTION); statement in all my first-time written methods, that way I can quickly determine if something is missing to get my events, properly initialized, etc. Its just my style.
AnimatedImage.h isA ViewController
AnimatedImage.m
This "root or main" delegate is a UIViewController. I have left of detail to show its simplicity, but still left my 'trace' code that I find essential for first-time debugging. Also, as an aside, I believe you have to overload motionBegan, even if you only need the motionEnded event. I recall that my app did not work and then I added the motionBegan and it started to call motionEnded. It kinda' makes sense that it would be that way, but I don't have any documentation to back it up. A simple experiment after you get it working can confirm or deny my comment.
This code does work -- but if I snipped out too much detail, just ask and I will make certain to add enough to help you along. This was a really rewarding task for me and I am excited to share it with someone looking for some help in the same experience.
查看 LocateMe 示例代码,这是 SDK 中的第一个示例,并使用和更改弹回中心代码。
Have a look at LocateMe example code, one of the first samples in the SDK and use and change the bounce back to centre code.