-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path14. Dynamic Animation Demo.srt
9574 lines (7660 loc) · 218 KB
/
14. Dynamic Animation Demo.srt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1
00:00:00,401 --> 00:00:04,135
[MUSIC]
(音乐)
2
00:00:04,204 --> 00:00:07,305
Stanford University,
斯坦福大学,
3
00:00:07,373 --> 00:00:11,475
>> All right, well welcome to Stanford CS193P developing
> >好吧,欢迎来到斯坦福CS193P发展
4
00:00:11,544 --> 00:00:14,311
applications for iOS Winter 2017,
iOS应用程序2017年冬天,
5
00:00:14,380 --> 00:00:16,180
This is Lecture 15, I think,
我认为,这是讲座15
6
00:00:17,716 --> 00:00:19,015
Yeah, 14, something like that,
是的,14日,
7
00:00:19,083 --> 00:00:21,717
And today is all demo,
今天的演示,是
8
00:00:21,786 --> 00:00:24,720
We're gonna do a demo of this dynamic animation stuff,
我们要做这个动态的演示动画,
9
00:00:24,789 --> 00:00:26,988
And I'm gonna cover push behaviors, and
我要盖推动行为,
10
00:00:27,057 --> 00:00:29,958
collision behaviors, and dynamic item behaviors,
碰撞行为和动态项行为,
11
00:00:30,026 --> 00:00:32,793
collision delegates, gravity behaviors, etc,
碰撞的代表,重力的行为等,
12
00:00:32,862 --> 00:00:34,862
I'm not gonna get back to the slides,
我不会回到幻灯片,
13
00:00:34,931 --> 00:00:37,597
So, let me talk about what's coming up now which is we
所以,让我谈谈现在的我们
14
00:00:37,666 --> 00:00:39,032
have no section this week,
本周没有节,
15
00:00:39,101 --> 00:00:39,932
And then next week,
然后下个星期,
16
00:00:40,001 --> 00:00:42,435
I actually posted what I'm gonna talk about next week,
我下周我要讲什么,
17
00:00:42,504 --> 00:00:45,504
But it's application lifecycle, alerts and action
但它的应用程序生命周期,警报和行动
18
00:00:45,573 --> 00:00:49,542
sheets, segues, might even get core motion to fit in there,
表,segue,甚至可能得到核心运动适合在那里,
19
00:00:49,610 --> 00:00:52,644
I'll try and cover as much of the general infrastructure
我会和覆盖尽可能多的通用基础设施
20
00:00:52,713 --> 00:00:55,180
stuff that might help you, with your assignment,
东西可能会帮助你,和你的任务,
21
00:00:56,449 --> 00:01:00,251
Okay, so let's get right to the demo,
好的,我们马上开始演示,
22
00:01:00,319 --> 00:01:05,723
And this, now, we're demoing Dynamic Animator here,
现在,我们在这里演示动态动画师,
23
00:01:05,791 --> 00:01:09,259
And generally, dynamic animation is mostly used to
和一般情况下,动态动画主要是用来
24
00:01:09,328 --> 00:01:13,062
animate things that are happening in your UI normally,
有生命的东西通常发生在UI,
25
00:01:13,131 --> 00:01:15,831
And I use that example of when you swipe up from the bottom
我用这个例子从底部当你刷卡
26
00:01:15,900 --> 00:01:19,034
on your iPhone and it brings that little UI view comes up,
在你的iPhone和用户界面视图,它将那个小
27
00:01:19,103 --> 00:01:22,170
And it kinda bounces a bit and then sits steady,
它有点反弹一点然后坐在稳定,
28
00:01:22,239 --> 00:01:26,541
That is really what dynamic animation kind of is used for
这就是动态动画的使用
29
00:01:26,610 --> 00:01:28,410
You wouldn't probably use it for building a video game,
你可能不会使用它来构建一个视频游戏,
30
00:01:28,411 --> 00:01:30,211
the most,
最多,
31
00:01:30,280 --> 00:01:32,846
even though that's the demo I'm gonna do today,
尽管今天的演示我要做的是,
32
00:01:32,915 --> 00:01:34,782
There are other things like Spy Kid and
还有其他间谍的孩子和之类的东西
33
00:01:34,851 --> 00:01:37,117
things like that that you might use for that,
类似这样的事情,你可能会使用,
34
00:01:37,185 --> 00:01:40,320
But I like doing the video game because this is kinda fun
但我喜欢做游戏,因为这是有点有趣
35
00:01:40,389 --> 00:01:43,589
and it also as a opportunity for me to quickly and densely
同时也作为一个机会,可以让我快速、密集
36
00:01:43,658 --> 00:01:46,458
show you lots of different kinds of behaviors and
给你很多不同的行为
37
00:01:46,527 --> 00:01:47,793
how they work,
它们是如何工作的,
38
00:01:47,861 --> 00:01:52,797
So, we're gonna build a space game, asteroid game,
因此,我们要建立一个空间游戏,游戏的小行星,
39
00:01:52,866 --> 00:01:55,400
We're just gonna have a field of asteroids flying by, and
我们要有一个小行星飞行领域,和
40
00:01:55,469 --> 00:01:57,335
we're gonna have a ship in the middle, and
我们会有一个船在中间,和
41
00:01:57,404 --> 00:01:58,970
our ship is gonna have some shields,
我们的船会有盾牌,
42
00:01:59,038 --> 00:02:01,405
And every time an asteroid hits the shields,
每一次小行星撞击盾牌,
43
00:02:01,474 --> 00:02:03,674
the shields will turn on and get depleted,
盾牌打开或会减少,
44
00:02:03,742 --> 00:02:06,443
And eventually our ship will probably be destroyed
最终我们的船可能会被摧毁
45
00:02:06,512 --> 00:02:08,077
from too many asteroid hits,
从太多的小行星撞击,
46
00:02:08,146 --> 00:02:10,880
And, we're gonna be able to do all of those behaviors that I
,我们将能够做所有的这些行为
47
00:02:10,949 --> 00:02:11,747
mentioned before,
之前提到过,
48
00:02:11,815 --> 00:02:15,984
So, let's get started here, I'm gonna create a new app,
所以,让我们从这里开始,我要创建一个新的应用,
49
00:02:17,087 --> 00:02:21,756
I'm gonna call this app asteroids and
我要调用这个程序小行星和
50
00:02:21,825 --> 00:02:25,193
we'll make it work on both iPad and all the iPhones,
我们会让它工作在iPad和iphone,
51
00:02:25,261 --> 00:02:27,260
That's no problem for this one and
为此,没问题
52
00:02:27,329 --> 00:02:29,729
I'll put it in the same place that I always put everything,
我把它在同一个地方,我总是把一切,
53
00:02:29,798 --> 00:02:32,164
Now I wanna focus all my
现在我想我所有的焦点
54
00:02:32,233 --> 00:02:35,034
demonstration time here on the dynamic animation stuff,
在动态动画演示时间的东西,
55
00:02:35,103 --> 00:02:37,603
So, this is one of those demos where I actually do have some
所以,这是一个演示,我确实有一些
56
00:02:37,672 --> 00:02:40,572
code and some stuff I'm gonna drag in,
代码和一些东西我要拖,
57
00:02:40,641 --> 00:02:43,208
I'll show it to you briefly, but it's mostly just
我会给你短暂的,但它是
58
00:02:43,277 --> 00:02:47,078
drawing things, drawing the ship, drawing an asteroid,
画的东西,画船,一颗小行星,
59
00:02:47,146 --> 00:02:49,380
And, all the animations stuff that we're gonna do,
所有动画的东西,我们要做的,
60
00:02:49,449 --> 00:02:53,483
100% of it is gonna be in code that I do in the demo here,
100%的会在我做演示的代码,
61
00:02:53,552 --> 00:02:57,254
So, let's start by moving some of these things out of the way
所以,让我们开始通过移动一些东西的
62
00:02:57,322 --> 00:03:01,125
as we usually do, put these things in supporting files,
我们通常做,把这些东西在支持文件,
63
00:03:01,193 --> 00:03:05,728
Just to clean up what we're looking at here,
清理我们看这里,
64
00:03:05,797 --> 00:03:07,564
I'll even put main storyboard up here,
我甚至会把主要的故事板,
65
00:03:07,632 --> 00:03:10,966
Now, I've left XC Assets out of supporting files at
现在,我离开我资产的支持文件
66
00:03:11,035 --> 00:03:12,401
Cuz I actually am going to have some assets, some image
因为我要有一些资产,一些形象
67
00:03:12,402 --> 00:03:13,768
the time,
时间,
68
00:03:13,838 --> 00:03:16,905
assets, specifically my asteroids and my ship,
资产,特别是我的小行星和船,
69
00:03:16,974 --> 00:03:21,175
So, let's drag those in, so I'm just gonna go over here to
让我们拖的,所以我要到这里
70
00:03:21,244 --> 00:03:23,177
this little directory I have of stuff,
这个小目录我的东西,
71
00:03:23,246 --> 00:03:26,013
And you can see that I've got some kind of random pictures
你可以看到我有某种随机图片
72
00:03:26,082 --> 00:03:27,047
of asteroids here,
小行星,
73
00:03:27,115 --> 00:03:29,715
And I'm just gonna take these asteroids and
我要把这些小行星和
74
00:03:29,784 --> 00:03:31,684
add them to my images down here,
将它们添加到我的下面的图片,
75
00:03:31,753 --> 00:03:33,385
I'm gonna do it for explosion,
我要做爆炸,
76
00:03:33,454 --> 00:03:36,321
also my ship knows how to explode, so we'll have that,
还我的船知道如何爆炸,所以我们会有,
77
00:03:36,390 --> 00:03:37,555
And then here's my ship,
这是我的船,
78
00:03:37,624 --> 00:03:40,892
cute little ship, here's where it's, it's engines are firing,
可爱的船,在这里,它是发动机点火,
79
00:03:40,961 --> 00:03:43,460
Okay, so we have those two images right there,
好的,我们有这两个图片,
80
00:03:43,529 --> 00:03:47,398
Now when you drag images into your XE assets you'll see that
现在当你拖动图片到你你会发现XE资产
81
00:03:47,467 --> 00:03:51,168
they have a one times, a two times and a three times slot,
有一次,两次,三次槽,
82
00:03:51,237 --> 00:03:53,737
And that's talking about the resolution,
讨论解决,
83
00:03:53,805 --> 00:03:56,072
Okay, it's really talking about the number of pixels per
好的,真是谈论每像素的数量
84
00:03:56,141 --> 00:03:57,339
point, okay?
点,好吗?
85
00:03:57,408 --> 00:03:59,007
In the size of the image,
在图像的大小,
86
00:03:59,076 --> 00:04:00,208
Normally you're gonna have all three,
通常你会有三个,
87
00:04:00,277 --> 00:04:03,011
I'm only gonna use the 1x because my 1x is pretty high
我只会用1 x 1因为我是相当高的
88
00:04:03,080 --> 00:04:05,746
resolution, it'll look fine on 2x and 3x,
分辨率,它会看起来罚款2倍3倍,
89
00:04:05,815 --> 00:04:07,114
But if you got a real app,
但是如果你有一个真正的应用程序,
90
00:04:07,183 --> 00:04:09,784
you'd wanna pick resolutions at these different sizes,
你想选择决议在这些大小不同,
91
00:04:09,852 --> 00:04:12,987
Because it allows a one X app to be much smaller,
因为它允许一个X应用程序小得多,
92
00:04:13,055 --> 00:04:16,156
cuz obviously a lower resolution is much smaller,
因为很明显较低的分辨率要小得多,
93
00:04:16,224 --> 00:04:17,824
And it's really cool actually when
实际上,这是很酷的时候
94
00:04:17,893 --> 00:04:19,325
people download things from the App Store,
人们从App Store下载东西,
95
00:04:19,394 --> 00:04:22,228
You only get the resolutions that are appropriate
你只得到适当的决议
96
00:04:22,296 --> 00:04:22,828
for your device,
你的设备,
97
00:04:22,896 --> 00:04:23,862
So, it's kind of fun,
所以,这是一种乐趣,
98
00:04:23,931 --> 00:04:25,797
You don't get all that extra junk that you don't need,
你没有得到所有你不需要额外的垃圾,
99
00:04:26,832 --> 00:04:28,666
So anyway, so those are my images,
总之,这是我的照片,
100
00:04:28,735 --> 00:04:30,567
And then I do have a bit of code here too,
然后我有一些代码,
101
00:04:30,636 --> 00:04:32,202
at least four files,
至少有四个文件,
102
00:04:32,271 --> 00:04:35,138
Just like I said we're gonna take a look at here,
就像我说的我们要看一看,
103
00:04:35,207 --> 00:04:40,010
Drag those in and we will copy them, yes,
拖的,我们将复制他们,是的,
104
00:04:41,413 --> 00:04:42,311
All right, so let's look at
好吧,让我们看看
105
00:04:42,379 --> 00:04:43,846
the code we just dragged in there,
刚刚拖的代码,
106
00:04:45,515 --> 00:04:47,448
First one here is asteroid view,
第一个是小行星的观点,
107
00:04:47,517 --> 00:04:49,784
This is the entire thing that you see on the screen right
这是整个你在屏幕上看到的东西
108
00:04:49,852 --> 00:04:53,186
here, very simple little subclass of UI image view,
这里,非常简单的小的子类UI图像视图,
109
00:04:53,255 --> 00:04:56,757
It just picks a random one of those asteroids images, right?
它只是选择一个随机的小行星的图片,对吗?
110
00:04:56,825 --> 00:04:59,992
See these asteroid images one, two through asteroid nine,
看到这些小行星图片1、2通过小行星九,
111
00:05:00,061 --> 00:05:01,961
this thing just picks one of those and
这个东西只是选择其中的一个
112
00:05:02,030 --> 00:05:03,562
makes an image view out of it,
使一个图像视图,
113
00:05:03,631 --> 00:05:07,199
Okay, that's all AsteriodView is, so that looks really easy
好了,这就是AsteriodView,这样看起来很容易
114
00:05:07,268 --> 00:05:10,035
when we move that into supporting files as well,
当我们搬到支持文件,
115
00:05:10,103 --> 00:05:14,506
Here is a little exte, file of extensions that I made to
这里是一个小,我做文件的扩展
116
00:05:14,574 --> 00:05:18,943
CGFloat, and CGSize and CGRect, and CGPoint,
CGFloat,CGSize CGRect中,CGPoint
117
00:05:19,012 --> 00:05:21,812
And these are just little convenience functions, like
这些只是小便利的函数,如
118
00:05:21,880 --> 00:05:24,781
here's the area of a CGSize right just with time height,
这里CGSize的面积只是随着时间的高度,
119
00:05:24,850 --> 00:05:28,351
Or here's a CG float, it generates a random number in
或者这是CG浮动,它生成一个随机数
120
00:05:28,420 --> 00:05:31,554
a certain range of floats which is kind of cool,
一定范围的浮动是挺酷的,
121
00:05:31,623 --> 00:05:33,923
A random float, okay and returns it,
一个随机浮动,好并返回它,
122
00:05:33,992 --> 00:05:35,424
Here's CGRect,
这是CGRect中,
123
00:05:35,493 --> 00:05:37,726
I have a random point which generates a random point
我有一个随机点生成一个随机点
124
00:05:37,795 --> 00:05:39,060
inside the rectangle anywhere,
矩形内的任何地方,
125
00:05:39,129 --> 00:05:41,729
Cuz obviously I'm
因为很明显,我
126
00:05:41,798 --> 00:05:43,998
It's nice to have a little, var here,
很高兴有一个小,var在这里,
127
00:05:44,067 --> 00:05:45,666
random points, for rect,
随机点,为矩形,
128
00:05:45,735 --> 00:05:47,935
So, you can go look at these later,
所以,你可以去看看这些后,
129
00:05:48,004 --> 00:05:50,837
as I'm writing the code, I'll try and reference
我写的代码,我会和参考
130
00:05:50,905 --> 00:05:53,706
these are one of my little CGRect extensions that I did,
这是我的一个小CGRect中扩展,
131
00:05:53,775 --> 00:05:57,076
And I do this but I think my code reads a lot nicer when I,
我这样做,但我想我读了很多书更好的代码,
132
00:05:57,145 --> 00:05:58,895
kinda condense this math into these nice little, extensions,
有点凝结这数学到这些好的小,扩展,
133
00:05:58,896 --> 00:06:00,646
you know,
你知道的,
134
00:06:00,715 --> 00:06:03,548
But all of these make perfect sense as extensions of
但是所有的这些完美的意义的延伸
135
00:06:03,616 --> 00:06:04,415
each of their classes,
他们的课程,
136
00:06:04,484 --> 00:06:06,017
None of them are spaceship or
他们都没有宇宙飞船或
137
00:06:06,086 --> 00:06:08,753
asteroid specific extensions to core graphics,
小行星特定扩展核心图形,
138
00:06:10,222 --> 00:06:13,289
So, move that to supporting files as well,
所以,此举支持文件,
139
00:06:13,358 --> 00:06:15,558
Then next we have the spaceship view,
那么接下来我们有宇宙飞船视图,
140
00:06:15,627 --> 00:06:16,392
Okay, the spaceship view
好的,飞船的观点
141
00:06:16,461 --> 00:06:18,894
just draws that little spaceship I showed you,
只是吸引小飞船我给你们,
142
00:06:18,963 --> 00:06:21,663
It knows how to draw it with the little flame
它知道如何画的小火焰
143
00:06:21,732 --> 00:06:23,665
coming out the back if the engines are firing,
出来后如果发动机点火,
144
00:06:23,734 --> 00:06:25,500
This is the entire public API of it right here,
这是整个公共API的在这里,
145
00:06:25,569 --> 00:06:27,134
this is the only API we'll be using,
这是唯一我们将使用API,
146
00:06:27,203 --> 00:06:29,937
So, that's just a bully that turns on that little fire
所以,这只是一个恶霸,转小火
147
00:06:30,006 --> 00:06:32,039
coming out the back or not is all it does,
出来的都是它,
148
00:06:32,107 --> 00:06:34,841
Direction is the direction the ship is pointing and
是这艘船的方向指向和方向
149
00:06:34,910 --> 00:06:37,811
that's you know zero to two pi, so it's in radians,
你知道从0到2π,所以弧度,
150
00:06:37,879 --> 00:06:41,514
You know, we've hopefully learned by now the zero two pi
你知道,我们希望学到现在0 2π
151
00:06:41,582 --> 00:06:45,884
circle where zero is out to the right and we go around,
圆零是正确的,我们去的地方,
152
00:06:45,953 --> 00:06:48,921
Shield level, so this ship has a little round shield around
保护水平,所以这艘船有一个小圆盾
153
00:06:48,990 --> 00:06:51,155
it and the shield level goes from zero to a hundred,
它和保护水平的范围是从0到一百,
154
00:06:51,224 --> 00:06:52,490
When a hundred, it's a full shield and
在一百年,这是一个完整的盾牌和
155
00:06:52,559 --> 00:06:53,591
it doesn't even show the shield,
它甚至不显示盾,
156
00:06:53,660 --> 00:06:55,693
But as soon as the shield gets damaged,
但当盾牌被损坏,
157
00:06:55,761 --> 00:06:58,161
It kinda shows the shield partially damaged,
它显示了屏蔽部分受损,
158
00:06:58,230 --> 00:07:03,033
until you get to shield level zero, the ship explodes, okay?
直到你得到保护水平为零,船爆炸了,好吗?
159
00:07:03,101 --> 00:07:05,835
This shield is active, it's purely a drawing thing,
这盾牌是活跃的,纯粹的一幅画的事情,
160
00:07:05,904 --> 00:07:08,571
When the shield is active it kinda glows a little bit,
盾牌是活跃的时候稍微有点发光,
161
00:07:08,639 --> 00:07:10,406
And so, we're gonna have our ship,
所以,我们要有我们的船,
162
00:07:10,474 --> 00:07:13,242
just to make our UI simple, it's going to automatically
为了让我们的UI简单,自动的
163
00:07:13,310 --> 00:07:15,811
turn it's shields on when an asteroid impacts it,
把它的盾牌当一个小行星撞击,
164
00:07:15,879 --> 00:07:18,346
Okay, so we're kind of a auto shield deployment, so
好的,所以我们的自动防御系统部署,所以
165
00:07:18,415 --> 00:07:20,314
we're gonna turn this on so we can see it,
我们会把这个我们可以看到它,
166
00:07:20,383 --> 00:07:22,549
the asteroids causing the shields to turn on,
小行星导致盾打开,
167
00:07:22,618 --> 00:07:26,486
And then finally there's this little shield boundary guy,
最后的这个小盾边界的家伙,
168
00:07:26,555 --> 00:07:29,623
that just gives us a UIBezierPath that describes
只给了我们一个UIBezierPath来描述
169
00:07:29,692 --> 00:07:30,490
the shield,
盾,
170
00:07:30,559 --> 00:07:32,625
It's just gonna be a simple arc around because
它只是将一个简单的弧因为
171
00:07:32,694 --> 00:07:34,560
it's a circle, just gives us that back,
它是一个圆,只给了我们,
172
00:07:34,628 --> 00:07:37,329
Notice that it can give it to us in any views coordinate
注意,它可以给我们任何视图坐标
173
00:07:37,397 --> 00:07:40,366
space and that's because we're gonna find that when we do
空间,因为我们会发现,当我们做的事
174
00:07:40,434 --> 00:07:41,032
animation,
生气勃勃,
175
00:07:41,101 --> 00:07:42,900
We're gonna specify a reference view for
我们会指定一个参考视图
176
00:07:42,969 --> 00:07:44,068
all of our animation, and
我们所有的动画
177
00:07:44,137 --> 00:07:46,036
when we have these things like boundaries,
当我们有这些东西就像边界,
178
00:07:46,104 --> 00:07:48,371
We have to always specify them in that reference view's
我们必须总是在引用视图的指定它们
179
00:07:48,440 --> 00:07:49,272
coordinate system,
坐标系统,
180
00:07:49,340 --> 00:07:52,542
So, if we're gonna get the boundary of the ship's shields
所以,如果我们要得到的边界船的盾牌
181
00:07:52,611 --> 00:07:54,177
as a UIBezierPath,
UIBezierPath,
182
00:07:54,245 --> 00:07:56,578
it has to be in the right coordinate system,
它必须是正确的坐标系统,
183
00:07:56,647 --> 00:07:59,414
So, that's why it has this in view argument right there, but
所以,这就是为什么它在观点的论点,但是
184
00:07:59,482 --> 00:08:02,650
it's just returned to UIBezierPath Okay so that's
只是回到UIBezierPath好了这是
185
00:08:02,719 --> 00:08:05,786
the spaceship view I can do anything else with that,
飞船的观点我可以做什么,
186
00:08:05,855 --> 00:08:09,056
And then here is the last one the asteroid field view this
这是最后一个小行星把这个领域
187
00:08:09,125 --> 00:08:10,958
is the entire thing right here,
是整个,
188
00:08:11,027 --> 00:08:14,427
It only have one method in it, which is add some asteroids,
它只有一个方法,添加一些小行星,
189
00:08:14,496 --> 00:08:16,996
Okay, and all this code here is doing is just putting
好的,所有这些代码所做的仅仅是把
190
00:08:17,065 --> 00:08:19,699
a random sized asteroid at
一个随机大小的小行星
191
00:08:19,767 --> 00:08:21,634
a random point inside it's bounds,
一个随机点里面的界限,
192
00:08:21,702 --> 00:08:25,037
Okay, so really very super simple right here,
好的,所以非常超级简单,
193
00:08:25,105 --> 00:08:27,539
It does have this little thing of exclusion zone where it
它确实有这小东西的禁区
194
00:08:27,608 --> 00:08:28,973
won't put an asteroid there, and
不会把一颗小行星,
195
00:08:29,042 --> 00:08:30,275
you'll see why we want that,
你就会明白为什么我们想要的,
196
00:08:30,344 --> 00:08:31,475
We don't wanna put an asteroid on top of
我们不想把小行星上
197
00:08:31,544 --> 00:08:33,310
our ship when we start,
当我们开始,我们的船
198
00:08:33,379 --> 00:08:35,778
Now this one I'm not gonna put in supporting files, cuz we
现在这个我不会把在支持文件,因为我们
199
00:08:35,847 --> 00:08:38,315
are gonna actually add a small amount of code to this guide,
要添加少量的代码本指南,
200
00:08:38,384 --> 00:08:40,683
Because we want our asteroid behaviors,
因为我们希望我们的小行星的行为,