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游戏开发经典实例
256
8
let lookAtConstraint = SCNLookAtConstraint(target: capsuleNode)
//
设置
gimbalLockEnabled
true
时,该约束将使被约束对象围绕
//
一个轴旋转
lookAtConstraint.gimbalLockEnabled = true
pointerNode.constraints = [lookAtConstraint]
讨论
一个约束对象用于告诉
Scene Kit
,某个物体的位置和旋转角度将在某种程度上受
制于另外一个对象。例如,我们可以使一个阴影块的
x
轴和
z
轴总是等于玩家角色
x
轴和
z
轴,即这个阴影总是位于角色的下方,但当角色向上跃起时,阴影并不
会随之上移。
有几种不同的约束,如:
Look-at
约束,这种约束使一个对象指向另一个对象。
Transform
约束,这种约束可以让我们将一个闭包附着在上面,这样可以在每
一帧刷新时改变对象的位置和方向。
Inverse kinematics (IK)
约束,这种约束允许我们将多个对象链在一起(就像人
的手掌、前臂和上臂一样),当向一个地方移动的时候,会受到每个关节弯曲
度的限制。
8.12
加载
3D
模型文件
问题
有一个对象,它是用
3D
编辑软件建模的,我们如何将它加到
Scene Kit
场景中?
解决方案
我们可以加载
COLLADA
(交互
3D
数字资产交换方案)文件格式的
3D
模型。要
使用
COLLADA
,需要先从磁盘上以文件的方式加载它:
let critterDataURL ...
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