在 iPad 上轻松实现帧图像动画效果

发布于 2024-12-16 02:27:15 字数 748 浏览 0 评论 0原文

让我向您展示示例(360 度 3D 对象旋转器):
演示:http://activeden.net/item/interactive-renders-360-deg-3d-object-rotator/39718?ref=mixDesign

在此处输入图像描述
如您所见,有一个相机在鼠标事件上进行 3D 旋转。实际上,它是根据鼠标事件逐帧动画的图像(帧)集合。

我想使用滑动手势通过objective - c实现此动画(或者也许我应该使用其他手势?)。这样我就可以用手指进行旋转,向(我想要具有平滑缓动效果的动画,具体取决于滑动速度速度)。

注意:我已经为每一帧准备好了图像。

示例代码、在线教程对我很有帮助。

<强>!我应该使用一些外部图形库来保持性能吗?我有数百张图像 (PNG),每张大小为 300kb


预先感谢您,我真的需要您的帮助!

Let me show you example (360 Deg 3D Object Rotator):
Demo: http://activeden.net/item/interactive-renders-360-deg-3d-object-rotator/39718?ref=mixDesign

enter image description here
As you see, there is a camera 3D rotating on mouse event. Actually, it is a collection of images (frames) animating frame by frame depending on mouse event.

I want to implement this animation with objective - c using swipe gesture (or maybe I should use another gesture?). So that I can make rotation by my finger, to the left, to the right (I want animation with smooth ease effect, depending on swipe speed velocity).

Note: I have ready images for each frame.

Sample codes, online tutorials doing this will really help me.

! Should I use some external graphics library, in order to keep performance? I have hundreds of images (PNG), each with size of 300kb

Thank you in advance, I really need your help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

牵强ㄟ 2024-12-23 02:27:15

也许在这里使用 touchesBegan:touchesMoved:touchesEnded: 会更容易?这将使您能够非常快速地对速度和方向的变化做出反应。

更新:示例可以在此处找到。

Maybe it will be easier to go with touchesBegan:, touchesMoved:, and touchesEnded: here? This will allow you to react to velocity and direction changes very fast.

Update: example can be found here.

顾铮苏瑾 2024-12-23 02:27:15

我认为你不应该在这里使用滑动手势。我推荐您使用较短的最小按压持续时间的 LongPressGesture。

让我展示示例代码:

longPress = [ [UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPressGesture:)] 
longPress.delegate = self;
longPress.minimumPressDuration = 0.05;
[viewWithImage addGestureRecognizer:longPress];


float startX; 
float displacement = 0;
-(IBAction)handleLongPressGesture:(UILongPressGestureRecognizer *)sender
{   

float nowX;
    if ( sender.state == UIGestureRecognizerStateBegan ) 
    {
        startX = [sender locationInView:viewWithImage].x;
    }
    if ( sender.state == UIGestureRecognizerStateEnded || sender.state == UIGestureRecognizerStateCancelled)
    {
       ... do something at end ... 
    }
nowX = [sender locationInView:mainWidgetView].x;
displacement = nowX - startX; 

  // set right rotation with displacement value
  [self rotateImageWith:displacement];
}

I don't think you should use swipe gesture here. I recommend you LongPressGesture with short minimumPressDuration.

Let me show example code:

longPress = [ [UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPressGesture:)] 
longPress.delegate = self;
longPress.minimumPressDuration = 0.05;
[viewWithImage addGestureRecognizer:longPress];


float startX; 
float displacement = 0;
-(IBAction)handleLongPressGesture:(UILongPressGestureRecognizer *)sender
{   

float nowX;
    if ( sender.state == UIGestureRecognizerStateBegan ) 
    {
        startX = [sender locationInView:viewWithImage].x;
    }
    if ( sender.state == UIGestureRecognizerStateEnded || sender.state == UIGestureRecognizerStateCancelled)
    {
       ... do something at end ... 
    }
nowX = [sender locationInView:mainWidgetView].x;
displacement = nowX - startX; 

  // set right rotation with displacement value
  [self rotateImageWith:displacement];
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文