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游戏开发经典实例
294
10
使用外设
iOS
设备能和各种各样的外部设备进行交互,包括外接屏幕和游戏控制器,这些设
备对于我们的游戏来说尤其有用。
iOS
iOS 2
开始支持多屏显示,但直到
iOS7
开始才支持游戏控制器。游戏控制器
是一种手持装置,专门用于向游戏玩家提供物理按键。与触摸屏相比,游戏控制器
既有优点,又有缺点。由于游戏控制器提供了物理按键,玩家的双手的操纵感更强,
更容易让玩家将注意力集中到游戏画面。另外,游戏控制器具备模拟输入的特性:
当按钮被按下时,控制器能感受到力道的大小,从而让游戏做出相应的反应。但是,
游戏控制器的按键是固定的,其位置和外观都无法改变,或者无法在运行时改变。
能在
iOS
上使用的游戏控制器必须遵循苹果的一系列设计规范;这些规范规定无论
什么厂商制造的游戏控制器,其行为都是一致的,在游戏中的操作方式也是一样的。
更麻烦的是,游戏控制器有不同的版本。最简单的一种(通常也是最便宜的)是标
准游戏控制器(见图
10-1
),它有两个侧按键,
4
个字母键,一个暂停键,一个十
字方向键。另外一种是增强型游戏手柄(见图
10-2
),包含了标准型的所有按键以
及两个摇杆,两个扳机。你的游戏不一定每个按键都要使用,但多一个键总是好的。
除了游戏控制器,
iOS
游戏也可以使用外接屏幕。外接屏幕可以通过线缆直接连接
iOS
设备,也可以通过
AirPlay
进行无线连接。要使用外接屏幕,我们需要做许
多事情,例如,要让我们的游戏除了能在内置屏幕上显示,还要能在大屏上显示。
甚至将
iPhone
变成游戏控制器,而将游戏画面显示到电视机上 ...
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