Skip to Content
Swift游戏开发经典实例
book

Swift游戏开发经典实例

by Jonathon Manning, Paris Buttfield-Addison
January 2020
Intermediate to advanced
356 pages
6h 4m
Chinese
China Electric Power Press Ltd.
Content preview from Swift游戏开发经典实例
318
10
你还可以让录制器捕获麦克风和摄像头:
recorder.isMicrophoneEnabled = true
//
需要在
Info.plist
中配置
"Privacy - Camera Usage Description"
recorder.isCameraEnabled = true
10.9
ARKit
显示
AR
画面
问题
你想显示
AR
画面,也就是通过摄像头在玩家真实画面之上绘制
3D
对象,使这些
对象看起来像真的一样。
解决方案
ARKit
是苹果用于绘制
AR
场景的框架。将摄像头中的图像和
3D
运动传感器结合,
ARKit
能够将游戏中的镜头位置和真实世界中设备的位置进行匹配,从而计算出镜
头在虚拟空间中的位置。
ARKit
无法用于
iOS
模拟器,因为它需要访问设备的摄像头和运动传感器。
你只能在真机上使用该框架。
ARKit
和其他框架结合,就能操作
3D
图形,在本例中,我们将使用
SceneKit
Xcode
带有一个
ARKit
的模板,它已经为你实现了本例中介绍的许多步骤。
为了了解其中的细节,我们将在本例中手动操作这些步骤。
1.
首先,在
Xcode
中新建
Single-View Application
。创建好项目后,打开
File
菜单,
选择
New
File
。选择
SceneKit Scene
,然后点
Next
。给新文件命名为
Cube
使用外设
319
千万不要错选成“
SpriteKit Scene
”。这是完全不一样的,二者很容易搞混。
2.
在场景编辑器中打开这个场景(图
10-5
)。新创建的场景中包含了一个对象, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

精通機器學習

精通機器學習

Aurélien Géron
FreeBSD® Unleashed

FreeBSD® Unleashed

Brian Tiemann, Michael C. Urban
深入淺出代數

深入淺出代數

Tracey Pilone, Dan Pilone
Swift学习手册

Swift学习手册

Jon Manning, Paris Buttfield-Addison, Tim Nugent

Publisher Resources

ISBN: 9787519840129