新闻资讯
看你所看,想你所想

Objective-C和Sprite Kit游戏开发从入门到精通

Objective-C和Sprite Kit游戏开发从入门到精通

Objective-C和Sprite Kit游戏开发从入门到精通

《Objective-C和Sprite Kit游戏开发从入门到精通》是于2017年1月清华大学出版社出版的一本图书,作者是曹化

前言

为什幺要写这本书这是一个真实的故事。儿时与兄弟们玩街机和FC游戏的场景仍历历在目,不知不觉中就玩到了20世纪90年代。在学习和使用计算机过程中,发现除了能敲出自己的名字,还可以玩一些那幺有吸引力的游戏——海阔开空、千军万马,数不清的战斗!数不清的不眠之夜!玩果然是天性!

图书简介

本书是一执行绪序员凝聚自己多年开发经验的结晶之作,深入浅出地讲解Objective-C语言、
Foundation框架、SpriteKit框架,以及其他开发iOS和Mac游戏所需要的基础知识,帮助读者零基础实践
iOS和Mac游戏开发。

目录

第1章準备工作·····1
1.1本书内容················1
1.2使用Xcode··············2
1.3第一个Objective-C程式··················4
1.4获取帮助················7
第2章Objective-C开发基础·········8
2.1代码档案················9
2.2注释·12
2.3变数·12
2.4常量·13
2.5整数·15
2.5.1取值範围················15
2.5.2算术运算················16
2.5.3NSLog()函式与格式化输出·············17
2.5.4组合运算符·············17
2.5.5增量与减量运算·······18
2.5.6二进制与位运算·······18
2.6浮点数··················23
2.7布尔类型···············24
2.7.1BOOL类型··············24
2.7.2布尔运算················25
2.8字元·26
2.9指针·28
2.10自定义函式··········29
2.10.1返回值类型···········30
2.10.2函式名·················30
2.10.3参数30
2.10.4参数指针··············31
2.11static关键字··········32
2.12块(block)··········33
2.13枚举···················35
2.14结构···················37
2.15随机数················38
2.16预处理················38
2.16.1#define和#undef指令39
2.16.2条件编译指令········39
2.16.3#import指令···········40
第3章代码流程控制·················41
3.1比较运算···············41
3.2条件语句···············42
3.2.1if语句42
3.2.2?:运算符·················43
3.3选择语句···············44
3.4循环语句···············46
3.4.1for语句结构············46
3.4.2while语句结构·········47
3.4.3do-while语句结构·····47
3.4.4break语句···············48
3.4.5continue语句···········48
3.5goto语句与标籤······49
3.6异常处理···············49
第4章面向对象编程·················51
4.1面向对象编程基础···51
4.2类与对象···············53
4.2.1接口部分················53
4.2.2实现部分················54
4.2.3创建对象(实例化)·55
4.2.4类的成员················56
4.3方法(任务)·········58
4.3.1创建方法················58
4.3.2description方法与NSLog()函式·········61
4.4属性·61
4.4.1使用@proeprty和@synthesize指令·····62
4.4.2使用setter和getter方法···················63
4.5初始化方法············64
4.6继承·65
4.6.1成员的访问·············65
4.6.2重写属性和方法·······67
4.6.3继承关係中的初始化·67
4.7分类·69
4.7.1命名分类················70
4.7.2匿名分类················71
4.8对象複製与传递······71
4.8.1对象的複製·············71
4.8.2对象作为参数··········72
4.9动态处理类和对象···72
4.9.1对象类型判断··········72
4.9.2方法存在判断··········73
4.9.3动态调用方法··········74
第5章协定·········75
5.1创建协定···············75
5.2实现协定···············76
5.3可选成员···············77
5.4实现多个协定·········78
5.5对象深複製(实现NSCopying
协定)··················79
第6章数组、集合与字典···········82
6.1C风格数组·············82
6.2不可变数组(NSArray类型)·········84
6.2.1创建NSArray对象·····84
6.2.2数字对象(NSNumber类)·············84
6.2.3使用NSValue类········85
6.2.4数组成员操作··········86
6.2.5保存与载入·············87
6.3可变数组(NSMutableArray类型)··88
6.3.1创建NSMutableArray对象···············89
6.3.2添加成员················89
6.3.3删除成员················90
6.3.4替换成员················90
6.4集合(Set)···········91
6.4.1不可变集合(NSSet类)················91
6.4.2可变集合(NSMutableSet类)·········92
6.5字典(NSDictionary)··················93
6.5.1创建字典对象··········93
6.5.2常用成员················93
6.5.3NSMutableDictionary类··················94
第7章字元串······96
7.1C风格字元串··········96
7.2不可变字元串(NSString类)·········97
7.2.1创建NSString对象·····97
7.2.2返回字元数量··········98
7.2.3截取子字元串和字元·98
7.2.4大小写转换·············99
7.2.5转换为C风格字元串··99
7.2.6字元串比较与匹配··100
7.2.7转换为数值···········101
7.2.8保存与读取···········101
7.3
可变字元串(NSMutableString
类)···················102
7.3.1创建NSMutableString对象·············102
7.3.2NSMutableString常用成员·············102
7.4使用NSURL类······103
第8章本地化字元串················105
8.1判断系统语言类型·105
8.2NSLocalizedString··106
8.3NSLocalizedStringFromTable·········107
8.4综合套用·············108
第9章日期与时间···················109
9.1NSDate类············109
9.1.1获取时间信息········110
9.1.2时间的计算和比较··110
9.2NSDateComponents类·················111
9.3NSCalendar类·······112
9.4时区与区域设定····113
9.4.1NSTimeZone类·······113
9.4.2NSDateFormatter类·114
9.4.3NSLocale类···········115
9.5封装CDate类········115
9.5.1初始化方法···········117
9.5.2时间、区域和时区··118
9.5.3日期与时间数据·····119
9.5.4测试120
9.6获取中国农曆信息·120
9.6.1初始化方法···········121
9.6.2年份与名称···········122
9.6.3月份与名称···········123
9.6.4日期与名称···········124
9.6.5属相125
9.6.6测试125
第10章档案与目录·················127
10.1获取系统信息·····127
10.1.1获取文稿目录(Documents)·······128
10.1.2获取临时目录与GUID················128
10.1.3更多系统信息······129
10.2NSData与NSMutableData类········130
10.3使用NSFileManager类···············130
10.3.1档案或目录是否存在·················131
10.3.2複製档案和目录···131
10.3.3删除档案和目录···132
10.3.4移动、重命名档案和目录···········133
10.3.5档案与目录的属性133
10.4档案操作···········134
10.4.1读取档案内容······134
10.4.2写入档案············134
10.4.3比较档案内容······135
10.4.4检测档案读写许可权135
10.5目录操作···········135
第11章归档······137
11.1归档与解档········137
11.1.1实现NSCoding协定137
11.1.2使用NSKeyedArchiver类和
NSKeyedUnarchiver类···············139
11.2利用归档複製对象···················140
第12章通知中心与对话框········142
12.1通知中心···········142
12.2OSX对话框········146
12.3iOS对话框··········147
12.3.1回顾UIAlertView类150
12.3.2使用UIAlertController类··············152
12.3.3iPad中的UIAlertController···········154
第13章SpriteKit基础··············156
13.1第一个SpriteKit项目················156
13.1.1启动界面············159
13.1.2视图··················161
13.1.3创建场景············162
13.2iOS设备与系统信息··················163
13.2.1设备类型与iOS版本···················163
13.2.2萤幕尺寸············164
13.3颜色·················167
13.4节点树··············168
13.6.2坐标转换············174
13.7场景切换(SKTransition)·········174
13.8游戏循环···········176
13.9场景(SKScene)中显示对话框··178
13.10Mac中的SpriteKit项目·············180
13.10.1项目初始化········180
13.10.2回响滑鼠与键盘··181
13.10.3萤幕与尺寸········182
第14章精灵、纹理与角色控制···185
14.1SKSpriteNode类···185
14.1.1创建精灵节点······185
14.1.2NSBundle类·········187
14.1.3组合节点············188
14.2SKTexture类·······189
14.2.1截取纹理内容······189
14.2.2精灵动画——翻滚的小行星·········191
14.2.3更多的小行星······191
14.3移动与碰撞········192
14.3.1场景初始化·········193
14.3.2碰撞检测与游戏状态·················197
14.4触摸控制···········200
14.4.1触摸回响方法······200
14.4.2控制太空船·········201
14.4.3单击··················202
14.4.4手势··················202
14.5Mac中的太空船···207
14.5.1处理滑鼠操作······210
14.5.2处理键盘控制······212
14.5.3在update:方法中处理键盘控制·····213
第15章动作与声音播放···········216
15.1基本动作类型·····217
15.1.1移动··················217
15.1.2尺寸与缩放·········218
15.1.3显示和隐藏·········219
15.1.4旋转··················220
15.1.5等待··················221
15.2动作的组合········221
15.2.1动作组···············221
15.2.2动作序列············222
15.2.3动作重複············222
15.2.4动画动作············223
15.3声音播放···········223
15.3.1使用动作播放声音223
15.3.2使用AVAudioPlayer播放声音········224
15.4动作的使用········224
15.4.1执行动作············225
15.4.2通过键(Key)执行动作············225
15.4.3取消所有动作······226
15.4.4判断节点是否有动作执行···········226
15.4.5修改动作速度······226
第16章更多节点类型··············227
16.1SKShapeNode······228
16.1.1基本图形节点······229
16.1.2根据路径创建图形节点··············230
16.2SKVideoNode······231
16.3SKCropNode·······232
16.4SKEffectNode······233
16.5SKEmitterNode与粒子效果·········234
16.5.1在Xcode中创建粒子··················234
16.5.2下雪场景············235
16.5.3模拟爆炸············236
16.5.4SKEmitterNode类·238
16.6节点的组合········240
第17章SpriteKit游戏常用算法···242
17.1两点距离···········242
17.2碰撞测试···········243
17.3角度·················245
17.4视线·················246
17.5躲避障碍物········249
第18章综合测试——Mac版
坦克大战251
18.1场景初始化········252
18.1.1创建坦克············254
18.1.2创建敌人············254
18.1.3创建岩石············255
18.2坦克的操作········255
18.2.1坦克的动作·········256
18.2.2滑鼠和键盘控制···257
18.2.3自动执行············258
18.3敌人的AI···········259
18.4处理已发射炮弹··261
18.5自己动手···········262
第19章加速计与陀螺仪···········263
19.1自动回响···········264
19.2调用数据···········267
19.3游戏控制方法小结···················269
19.3.1触控萤幕···············269
19.3.2键盘与滑鼠·········270
第20章网路状态271
20.1检测网路状态·····271
20.2监视网路状态·····272
第21章GameCenter排行榜·····274
21.1配置排行榜········274
21.2在套用中处理排行榜················275
21.2.1GameCenter登录状态················275
21.2.2提交成绩············277
第22章套用内购买·················280
22.1準备测试用户和设备················280
22.2创建App内购买···281
22.3在项目中使用App内购买···········282
22.3.1检测访问限制与网路·················282
22.3.2执行购买操作······285
22.3.3恢复已购项目······287
22.3.4在场景(SKScene)中执行购买操作···287
22.3.5在场景(SKScene)中执行恢复操作··290

相关推荐

声明:此文信息来源于网络,登载此文只为提供信息参考,并不用于任何商业目的。如有侵权,请及时联系我们:yongganaa@126.com