-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
巧用 ARKit 和 SpriteKit 从零开始做 AR 游戏 #2043
Conversation
校对认领 @sqrthree |
@LJ147 好的呢 🍺 |
校对认领 @sqrthree |
@KnightJoker 妥妥哒 🍻 |
|
||
You can extend this app by adding game rules, introducing bonus points or changing the images and sound. Also, using [Pusher](https://pusher.com/), you could add multi-player features by syncing the state of the game. | ||
你可以通过增加游戏规则来扩展这个应用,引入奖励分数或者改变图像和声音。同样的,使用 [Pusher](https://pusher.com/),你可以同步游戏状态来增加多人游戏的特性。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
『你可以通过增加游戏规则来扩展这个应用,引入奖励分数或者改变图像和声音。』=>『你可以通过增加游戏规则,引入奖励分数或者改变图像和声音来扩展这个应用。』
> * 原文地址:[Building an AR game with ARKit and Spritekit](https://blog.pusher.com/building-ar-game-arkit-spritekit/) | ||
> * 原文作者:[Esteban Herrera](https://github.com/eh3rrera) | ||
> * 译文出自:[掘金翻译计划](https://github.com/xitu/gold-miner) | ||
> * 本文永久链接:[https://github.com/xitu/gold-miner/blob/master/TODO/building-ar-game-arkit-spritekit.md](https://github.com/xitu/gold-miner/blob/master/TODO/building-ar-game-arkit-spritekit.md) | ||
> * 译者: | ||
> * 译者:[Danny Lau](https://github.com/Danny1451) | ||
> * 校对者: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
In this tutorial, we’re going to explore the basics of ARKit and SpriteKit by building a game, something inspired by Pokemon Go, but with ghosts, check out this video: | ||
在这个教程里,我们将通过创建一个游戏来学习 ARKit 和 SpriteKit 的基础,游戏是受 Pokemon Go 的启发,但是有幽灵的元素,看下下面这个视频吧: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
『但是有幽灵的元素』=>『添加了幽灵元素』
Every few seconds, a little ghost appears randomly in the scene and a counter in the bottom left part of the screen is incremented. When you tap on a ghost, it fades out playing a sound and decrementing the counter. | ||
|
||
The code of this project is hosted on [GitHub](https://github.com/eh3rrera/ARKitGameSpriteKit). | ||
每几秒钟,就会有一个小幽灵随机出现在场景里,同时在屏幕的左下角会有一个计数器不停在增加。当你点击幽灵的时候,它会播放一个音效同时淡出而且计数器也会减小。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
『它会播放一个音效同时淡出而且计数器也会减小。』=>『它会播放一个淡出音效并减少计数器。』
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这边指的是淡出的同时播放音效,“播放一个淡出音效” 好像没有淡出的动作啊。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok,确实这边应该是一个淡出动作+音效的播放
|
||
ARKit is a feature of iOS 11, so you’ll need to have this version installed and use Xcode 9 for development. At the time of writing, iOS 11 and Xcode 9 are still in beta, so you’ll need to enroll in the [Apple Developer Program](https://developer.apple.com/programs/), however, Apple has now released both to the public so a paid developer account is no longer required. You can find more info about installing [iOS 11 beta here](https://9to5mac.com/2017/06/26/how-to-install-ios-11-public-beta-on-your-eligible-iphone-ipad-or-ipod-touch/) and [Xcode beta here](https://developer.apple.com/download/). | ||
首先,为了完整的 AR 体验,ARKit 要求一个带有 A9 或者更新的处理器的 iOS 设备。换句话说,你至少需要一台 iPhone6s 或者更新的设备,比如 iPhoneSE,所有版本的 iPad Pro,或者 2017 版的 iPad。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
『所有版本的 iPad Pro』=>『任何版本的 iPad Pro』
sceneView.session.run(configuration) | ||
} | ||
``` | ||
|
||
You can configure the session with the `ARWorldTrackingSessionConfiguration` class to track the device’s movement with [six degrees of freedom (6DOF)](https://en.wikipedia.org/wiki/Six_degrees_of_freedom). The three rotation axes: | ||
你可以用 `ARWorldTrackingSessionConfiguration` 类来配置该会话通过[六个自由度](https://en.wikipedia.org/wiki/Six_degrees_of_freedom)中追踪物体的移动。三个旋转角度: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
『六个自由度』=>『六个自由度(6DOF)』
|
||
In the 3D programming world, matrices are used to represent graphical transformations like translation, scaling, rotation, and projection. Through matrix multiplication, multiple transformations can be concatenated into a single transformation matrix. | ||
在 3D 编程的世界里,矩阵用来代表图形化的转换比如平移,缩放,旋转和投影。通过矩阵的乘法,多个转换可以连接成一个独立的转换。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
『多个转换可以连接成一个独立的转换。』=>『多个转换可以连接成一个独立的变换矩阵。』
0 1 2 3 // 列号 | ||
1.0 0.0 0.0 0.0 // 这一行代表着 X | ||
0.0 1.0 0.0 0.0 // 这一行代表着 Y | ||
0.0 0.0 1.0 -0.2 // This row represents Z 这一行代表着 Z |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个地方原文忘了删除了吧
1.0 0.0 0.0 0.0 // 这一行代表着 X | ||
0.0 1.0 0.0 0.0 // 这一行代表着 Y | ||
0.0 0.0 1.0 -0.2 // This row represents Z 这一行代表着 Z | ||
0.0 0.0 0.0 1.0 // This row represents W 这一行代表着 W |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
原文忘了删
|
||
``` | ||
override func update(_ currentTime: TimeInterval) { | ||
// Called before each frame is rendered | ||
// 在每一帧渲染的时候调用 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
『在每一帧渲染的时候调用』=>『在每一帧渲染之前调用』
@Danny1451 @sqrthree @LJ147 |
@LJ147 不要忘了来校对啊 |
|
||
[ARKit](https://developer.apple.com/arkit/) is the new Apple framework that integrates device motion tracking, camera capture, and scene processing to build [augmented reality (AR)](https://en.wikipedia.org/wiki/Augmented_reality) experiences. | ||
[ARKit](https://developer.apple.com/arkit/) 是一个全新的苹果框架,它将设备运动追踪,相机捕获和场景处理整合到了一起,可以用来构建[增强现实( AR )](https://en.wikipedia.org/wiki/Augmented_reality) 的体验。 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
“增强现实”此处为首次出现,应标注英文全称,参考修改:增强现实(augmented reality, AR)
|
||
ARKit is a feature of iOS 11, so you’ll need to have this version installed and use Xcode 9 for development. At the time of writing, iOS 11 and Xcode 9 are still in beta, so you’ll need to enroll in the [Apple Developer Program](https://developer.apple.com/programs/), however, Apple has now released both to the public so a paid developer account is no longer required. You can find more info about installing [iOS 11 beta here](https://9to5mac.com/2017/06/26/how-to-install-ios-11-public-beta-on-your-eligible-iphone-ipad-or-ipod-touch/) and [Xcode beta here](https://developer.apple.com/download/). | ||
首先,为了完整的 AR 体验,ARKit 要求一个带有 A9 或者更新的处理器的 iOS 设备。换句话说,你至少需要一台 iPhone6s 或者更新的设备,比如 iPhoneSE,所有版本的 iPad Pro,或者 2017 版的 iPad。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
『更新的处理器的 iOS 设备』=>『更高版本处理器的 iOS 设备』
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的更新可能会有歧义
|
||
In case something changes in a later version, the app of this tutorial was built with Xcode beta 2. | ||
ARKit 是 iOS 11 的一个特性,所以你必须先装上这个版本的 SDK,并用 Xcode 9 来开发。在写这篇文章的时候,iOS 11 和 Xcode 9 仍然是在测试版本,所以你要先加入到[苹果开发者计划](https://developer.apple.com/programs/),不过苹果现在也向公众发布了所以不再需要付过费的开发者账号。你可以在[这里](https://9to5mac.com/2017/06/26/how-to-install-ios-11-public-beta-on-your-eligible-iphone-ipad-or-ipod-touch/)找到更多关于安装 iOS 11 beta 的信息和[这里](https://developer.apple.com/download/)找到关于安装 Xcode beta 的信息。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
『不过苹果现在也向公众发布了所以不再需要付过费的开发者账号』=>『不过苹果现在也向公众发布了免费的开发者账号』
You can use a site like [iOS Fonts](http://iosfonts.com/) to visually choose the font for the labels. | ||
你可以用像 [iOS Fonts](http://iosfonts.com/) 的站点来可视化的选择标签的字体。 | ||
|
||
这个位置坐标代表着屏幕左下角的部分(相关代码稍后会解释)。我选择把它们放在屏幕的这个区域是为了避免转向的问题,因为场景的大小会随着方向改变而变化,但是,坐标保持不变,会引起标签显示超过屏幕或者在一些奇怪的位置(可以通过重写 `didChangeSize` 方法或者使用 [UILabels](https://developer.apple.com/documentation/uikit/uilabel) 替换 [SKLabelNodes](https://developer.apple.com/documentation/spritekit/sklabelnode))。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
可以通过重写didChangeSize或者使用UILabels替换SKLabelNodes 来解决这一问题
@sqrthree 二校完成 抱歉耽误了时间 |
@Danny1451 两位校对者都已经校对好了~ 可以来根据校对意见进行调整了哈 ┏ (゜ω゜)=☞ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
一丢丢小问题
|
||
Let’s start by reviewing what you’ll need to develop and run this project. | ||
项目的代码已经放在了 [GitHub] | ||
(https://github.com/eh3rrera/ARKitGameSpriteKit) 上了。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里不能加换行哈。
@KnightJoker @LJ147 @sqrthree 修改完成了 看看还有啥问题不 |
@Danny1451 嗯,我觉得 ok |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Danny1451 @sqrthree 嗯,我觉得还不错
Every few seconds, a little ghost appears randomly in the scene and a counter in the bottom left part of the screen is incremented. When you tap on a ghost, it fades out playing a sound and decrementing the counter. | ||
|
||
The code of this project is hosted on [GitHub](https://github.com/eh3rrera/ARKitGameSpriteKit). | ||
每几秒钟,就会有一个小幽灵随机出现在场景里,同时在屏幕的左下角会有一个计数器不停在增加。当你点击幽灵的时候,它会播放一个音效同时淡出而且计数器也会减小。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok,确实这边应该是一个淡出动作+音效的播放
@Danny1451 已经 merge 啦~ 快快麻溜发布到掘金专栏然后给我发下链接,方便及时添加积分哟。 |
…slate * 'master' of https://github.com/xitu/gold-miner: (178 commits) 🚀 添加文章『关于 React Router 4 的一切』到文章列表 🚀 添加文章『为什么我们渴求女性来设计 AI 』到文章列表 🚀 添加文章『如何在 Webpack 2 中使用 tree-shaking』到文章列表 🚀 添加文章『Redux 有多棒?』到文章列表 🚀 添加文章『别再使用图片轮播了』到文章列表 🚀 添加文章『将 Android 项目迁移到 Kotlin 语言』到文章列表 🚀 添加文章『巧用 ARKit 和 SpriteKit 从零开始做 AR 游戏』到文章列表 别再使用图片轮播了 (xitu#2073) Update how-to-do-proper-tree-shaking-in-webpack-2.md (xitu#2100) 为什么我们渴求女性来设计 AI (xitu#2074) 如何在 webpack2 中使用 tree-shaking (xitu#2076) 怎么写出完美的错误消息 (xitu#2080) 巧用 ARKit 和 SpriteKit 从零开始做 AR 游戏 (xitu#2043) 将 Android 程序移植为 Kotlin 程序 (xitu#2039) Redux 有多棒? (xitu#2003) 🚀 添加文章『函数式响应编程入门指南』到文章列表 🚀 添加文章『虚拟现实是如何改变用户体验的:从原型到设备的设计』到文章列表 ✨ Create angular-vs-react-which-is-better-for-web-development.md ✨ Create evolving-the-facebook-news-feed-to-serve-you-better.md ✨ Create why-context-value-matters-and-how-to-improve-it.md ...
翻译完成