0

我想创建将拍摄对象旋转 360 度的能力。

  • 它会根据您“轻弹”的速度无休止地旋转。
  • 您可以通过向左或向右轻弹对象来向左或向右旋转它。
  • 触摸时停止旋转,如果它正在旋转则停止。

在此处输入图像描述

类似于 Theodore Grey 的应用程序 The Elements。

这是我正在尝试重新创建的应用程序部分的视频。(即 3D 微调器)

https://youtu.be/6T0hE0jGiYY

这是我的手指与之交互的视频。

https://youtu.be/qjzeewpVN9o

我正在寻找使用 Swift 和可能的 SpriteKit。

  1. 我怎样才能从现实生活中的物体变成高质量和实用的东西?我配备了 Mac、Nikon D810 和绿屏。

    即,我猜测一系列定格动画是要走的路……但我觉得这可能不够流畅。

    出于这个问题的目的,我想弄清楚什么对编程最有意义。例如,我正在按命令倒带和快进的视频或定格帧的纹理图集等。

    注意:捕获软件和摄影技术将是有用的信息,因为我在那个部门一无所知。但是,我知道我可以在https://photo.stackexchange.com/上问这个问题。


  1. 对于这个对象,我的代码的基本逻辑是什么?按照:

A. 设置对象的动画或视频的功能,或者是让图像准备好在我的代码中使用的最佳方式。

B. spin() 函数和

C. stopSpin() 函数。

不需要整个项目示例(尽管我想它会很好)。但是,这三个功能足以让我继续前进。


  1. SpriteKit 是最明智的选择吗?
4

1 回答 1

2

这是我的答案的第二稿,展示了简单精灵动画的基本功能:

class GameScene: SKScene {

  // Left spin is ascending indices, right spin is descending indices.
  var initialTextures = [SKTexture]()

  // Reset then reload this from 0-6 with the correct image sequences from initialTextures:
  var nextTextures = [SKTexture]()

  var sprite = SKSpriteNode()

  // Use gesture recognizer or other means to set how fast the spin should be.
  var velocity = TimeInterval(0.1)

  enum Direction { case left, right }

  func spin(direction: Direction, timePerFrame: TimeInterval) {

    nextTextures = []
    for _ in 0...6 {

      var index = initialTextures.index(of: sprite.texture!)

      // Left is ascending, right is descending:
      switch direction {
      case .left:
        if index == (initialTextures.count - 1) { index = 0 } else { index! += 1 }
      case .right:
        if index == 0 { index = (initialTextures.count - 1) } else { index! -= 1 }
      }

      let nextTexture = initialTextures[index!]
      nextTextures.append(nextTexture)
      sprite.texture = nextTexture
    }

    let action = SKAction.repeatForever(.animate(with: nextTextures, timePerFrame: timePerFrame))
    sprite.run(action)
  }

  override func didMove(to view: SKView) {
    removeAllChildren()

    // Make our textures for spinning:
    for i in 0...6 {
      initialTextures.append(SKTexture(imageNamed: "img_\(i)"))
    }
    nextTextures = initialTextures

    sprite.texture = nextTextures.first!
    sprite.size = nextTextures.first!.size()
    addChild(sprite)
    spin(direction: .left, timePerFrame: 0.10)
  }

  override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
    spin(direction: .right, timePerFrame: velocity)
  }

  override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
    spin(direction: .left, timePerFrame: velocity)
  }
}

现在您只需单击/释放以交替右左。

下一个草案的待办事项:
- 实现速度手势识别器
- 如果需要,实现衰减(因此它会随着时间的推移而减慢)

(旧视频,新代码不会将帧重置为0):

在此处输入图像描述

可在此处找到动画的图像资源: https ://drive.google.com/open?id=0B3OoSBYuhlkgaGRtbERfbHVWb28

于 2017-06-28T02:56:21.927 回答