ios - Spritekit : How to make a node "jump" and also move it left or right, 取决于节点位置和触摸长度?

标签 ios sprite-kit

这是我的第一篇文章,所以放轻松哈哈。

我是“iOS”、“编码”、“Xcode”和“spritekit”的新手。如果我触摸屏幕上的任何地方,我希望使图像节点在正 y 轴上“跳跃”一段距离,尽管如果我触摸图像左侧或右侧的某处并保持一定时间,它会移动在各自的左或右方向上,距离分别为触摸的长度。

不确定这是否很清楚,但我们将不胜感激!谢谢!

最佳答案

你可以像这样移动一个节点

在 touchesEnded: 或 touchesBegan: 方法中:

{
node.position.y += 50;
}

为了让 Sprite 移动到某个地方,您也可以使用 Action ,有一系列 Action ,例如 moveTo Action 。

我建议您选择有关 sprite kit 的教程或书籍。提供免费教程的好网站是 raywenderlich.com

关于ios - Spritekit : How to make a node "jump" and also move it left or right, 取决于节点位置和触摸长度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23601322/

相关文章:

ios - Swift 可解码 : how to transform one of values during decoding?

android - 使用基于Cordova框架开发的混合应用程序打开默认邮件应用程序

ios - SpriteKit : how to iterate through ancestors of a node?

swift - 正确检测同时 SKAction 的完成情况

xcode - 在 spritekit 场景编辑器中使用自定义 SKNodes

swift - didBeginContact 未调用 GameOver 场景。有什么需要补充的吗?

ios - CGContext清除警告

ios - 在设置包中,对开关切换类型执行操作以隐藏或更改设置包 ios 中另一个字段的字段类型

ios - 无法配置数据源和委托(delegate)

ios - SKSpriteNode - 不同的 Sprite 但功能相同