-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
2634 lines (1603 loc) · 106 KB
/
index.html
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
<!DOCTYPE html>
<!--[if IEMobile 7 ]><html class="no-js iem7"><![endif]-->
<!--[if lt IE 9]><html class="no-js lte-ie8"><![endif]-->
<!--[if (gt IE 8)|(gt IEMobile 7)|!(IEMobile)|!(IE)]><!--><html class="no-js" lang="en"><!--<![endif]-->
<head>
<meta charset="utf-8">
<title>小桑博客</title>
<meta name="author" content="alfred sang">
<meta name="description" content="rootviewcontroller 上增加了一个tableviewcontroller,tablecell里有一个view,view里又有一个button view大于2层就很难受了,delegate传来传去的。 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
view1 …">
<!-- http://t.co/dKP3o1e -->
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="canonical" href="http://shiren1118.github.com/">
<link href="/favicon.png" rel="icon">
<link href="/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css">
<script src="/javascripts/modernizr-2.0.js"></script>
<script src="/javascripts/ender.js"></script>
<script src="/javascripts/octopress.js" type="text/javascript"></script>
<link href="/atom.xml" rel="alternate" title="小桑博客" type="application/atom+xml">
<!--Fonts from Google"s Web font directory at http://google.com/webfonts -->
<link href="http://fonts.googleapis.com/css?family=PT+Serif:regular,italic,bold,bolditalic" rel="stylesheet" type="text/css">
<link href="http://fonts.googleapis.com/css?family=PT+Sans:regular,italic,bold,bolditalic" rel="stylesheet" type="text/css">
</head>
<body >
<header role="banner"><hgroup>
<h1><a href="/">小桑博客</a></h1>
<h2>如果渡不过这不可渡的海,将成为这海中捞不起的沙</h2>
</hgroup>
</header>
<nav role="navigation"><ul class="subscription" data-subscription="rss">
<li><a href="/atom.xml" rel="subscribe-rss" title="subscribe via RSS">RSS</a></li>
</ul>
<form action="http://google.com/search" method="get">
<fieldset role="search">
<input type="hidden" name="q" value="site:shiren1118.github.com" />
<input class="search" type="text" name="q" results="0" placeholder="Search"/>
</fieldset>
</form>
<ul class="main-navigation">
<li><a href="/">博客</a></li>
<li><a href="/blog/archives">归档</a></li>
<li><a href="/about">About</a></li>
</ul>
</nav>
<div id="main">
<div id="content">
<div class="blog-index">
<article>
<header>
<h1 class="entry-title"><a href="/blog/2013/03/18/about-delegete/">About Delegete</a></h1>
<p class="meta">
<time datetime="2013-03-18T00:29:00+08:00" pubdate data-updated="true">Mar 18<span>th</span>, 2013</time>
</p>
</header>
<div class="entry-content"><p>rootviewcontroller 上增加了一个tableviewcontroller,tablecell里有一个view,view里又有一个button</p>
<p>view大于2层就很难受了,delegate传来传去的。</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
<span class='line-number'>9</span>
<span class='line-number'>10</span>
<span class='line-number'>11</span>
<span class='line-number'>12</span>
<span class='line-number'>13</span>
<span class='line-number'>14</span>
<span class='line-number'>15</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>view1:
</span><span class='line'> button - click
</span><span class='line'> -(void)click_event_callback;
</span><span class='line'>
</span><span class='line'>tableviewcontroller
</span><span class='line'> view1.delegate = self;
</span><span class='line'>
</span><span class='line'> -(void)click_event_callback;
</span><span class='line'>
</span><span class='line'>
</span><span class='line'>rootviewcontroller
</span><span class='line'> tableviewcontroller *tbvc.delegate = self;
</span><span class='line'>
</span><span class='line'> -(void)click_event_callback;
</span><span class='line'> </span></code></pre></td></tr></table></div></figure>
<p>这样做的原因是点击button的时候,需要在rootviewcontroller.navagationcontroller中push一个viewcontroller,而tableviewcontroller是没有navagationcontroller的。</p>
<p>我们通常设置delegate</p>
<pre><code>@property(nonatomic,assign,readwrite) id<*Protocol> _delegate;
</code></pre>
<p>用assign是防止产生交替dealloc死锁内存问题。</p>
</div>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/2013/03/04/transitions/">[Cocos2d-x wiki翻译]Transitions</a></h1>
<p class="meta">
<time datetime="2013-03-04T16:58:00+08:00" pubdate data-updated="true">Mar 4<span>th</span>, 2013</time>
</p>
</header>
<div class="entry-content"><h2>转场动画 (Transitions)</h2>
<h3>介绍</h3>
<div style='display:none;'>
One of the cool features that Cocos2d-x has to offer is the power of transitions within two different scene. Transitions are effects such as: wipe, fade, zoom, and split. You can use transitions to switch between Cocos2d-x Scene objects. Sceneclass is derived from CocosNode and it is similar to Layer. You can add other CocosNode, such as Layer(s) and Sprite(s) into a Scene.
</div>
<p>Cocos2d-x提供的最爽的一个特性是在2个不同场景间转场的能力.转场的效果有:wipe, fade, zoom, 和 split. 你可以使用转场动画在Cocos2d-x场景对象中切换.Sceneclass继承自CocosNode,它和Layer非常相似.你可以增加其他CocosNode,如 Layer(s) 和 Sprite(s) 放到场景中.</p>
<div style='display:none;'>
Technically, a transition scene is an scene that performs a transition effect before setting control to the new scene.
</div>
<p>技巧上说,转场的场景是一个在设置控制到新的场景前执行转场效果的场景.</p>
<h3>创建转场动画</h3>
<div style='display:none;'>
Time is the number of seconds for the transition. To apply transition to scenes, the syntax is as follows:
</div>
<p>Time 是转场的秒数.为了把转场动画应用到场景中,语法如下:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>CCDirector::sharedDirector()->replaceScene(CCTransitionFade::create(0.5,newScene));</span></code></pre></td></tr></table></div></figure>
<div style='display:none;'>
Some transitions has custom parameter(s); for example, FadeTransition has the fade color as extra parameter.
static CCTransitionFade* create(float duration,CCScene* scene, const ccColor3B& color);
To enable a transition, it is not much more difficult. Here we have an small example:
</div>
<p>一些转场可以有自定义参数;例如,FadeTransition有fade color作为额外参数.</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>static CCTransitionFade* create(float duration,CCScene* scene, const ccColor3B& color);</span></code></pre></td></tr></table></div></figure>
<p>运行转场动画其实一点不难,这儿有一个小例子:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>CCScene *s = SecondPage::scene();
</span><span class='line'>
</span><span class='line'>CCDirector::sharedDirector()->setDepthTest(true);
</span><span class='line'>
</span><span class='line'>CCTransitionScene *transition = CCTransitionPageTurn::create(3.0f, s, false);</span></code></pre></td></tr></table></div></figure>
<div style='display:none;'>
If you run this you will have a “page turn” effect. This is, like turning the page on a paper made book.
</div>
<p>如果运行这段代码,你会看到翻页效果.看起来就像是一页一页翻书。</p>
<p><img src="http://www.cocos2d-x.org/attachments/download/1623" alt="" /></p>
<h3>更多转场动画</h3>
<div style='display:none;'>
There are many more transition types, you can see the full list in the class reference, in the official Cocos2D-X documentation.
</div>
<p>想知道更多转场动画类型,你可以在官方Cocos2D-X文档的相关类中参考完整列表。</p>
<div style='display:none;'>
Last updated by Zhe Wang at Updated about 1 month ago.
</div>
<h3>Comment</h3>
</div>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/2013/03/04/particles/">[Cocos2d-x wiki翻译]Particles</a></h1>
<p class="meta">
<time datetime="2013-03-04T16:58:00+08:00" pubdate data-updated="true">Mar 4<span>th</span>, 2013</time>
</p>
</header>
<div class="entry-content"><h1>粒子(Particles)</h1>
<h2>简介</h2>
<div style='display:none;'>
The term particle system refers to a computer graphics technique that uses a large number of very small sprites or other graphic objects to simulate certain kinds of “fuzzy” phenomena, which are otherwise very hard to reproduce with conventional rendering techniques - usually highly chaotic systems, natural phenomena, and/or processes caused by chemical reactions.
</div>
<p>术语粒子系统关系到计算机图形学技术,使用大量非常小的sprite或其他图像对象来模拟特定种类的”模糊”现象,通过常规的渲染技术是很难制造的——一般来说有混乱系统、自然现象、或者活学反应引起的过程。</p>
<p><img src="http://www.cocos2d-x.org/attachments/download/1631" alt="" /></p>
<h2>Point vs Quad</h2>
<div style='display:none;'>
In early versions of Cocos2d-x, there were two types of particle system in cocos2d-x: Quad and Point particle system:
</div>
<p>在Cocos2d-x早期版本中,Cocos2d-x里粒子系统有两种类型:Quad 和 Point粒子系统:</p>
<ul>
<li>CCParticleSystemQuad</li>
<li>CCParticleSystemPoint</li>
</ul>
<div style='display:none;'>
The CCParticleSystemQuad has these additional features that CCParticleSystemPoint doesn’t support:
</div>
<p>CCParticleSystemQuad有很多特性是CCParticleSystemPoint不支持的:</p>
<div style='display:none;'>
- Spinning particles: particles can rotate around its axis. CCParticleSystemPoint ignores this property.
- Particles can have any size. In CCParticleSystemPoint if the size is bigger than 64, it will be treated as 64.
- The whole system can be scaled using the scale property.
</div>
<ul>
<li>Spinning particles:粒子可以绕自身的轴旋转。CCParticleSystemPoint忽略了该属性。</li>
<li>粒子可以为任意大小。在CCParticleSystemPoint中,如果大小大于64时,就视为64。</li>
<li>通过scale属性可以缩放整个系统。</li>
</ul>
<div style='display:none;'>
Because of CCParticleSystemPoint does not support CCParticleBatchNode. As the result, CCParticleSystemPoint has been removed from cocos2d-x particle system.
</div>
<p>由于CCParticleSystemPoint不支持CCParticleBatchNode.所以,CCParticleSystemPoint已经从cocos2d-x粒子系统里移除了.</p>
<h2>CCParticleBatchNode</h2>
<div style='display:none;'>
A CCParticleBatchNode can reference one and only one texture (one image file, one texture atlas). Only the CCParticleSystems that are contained in that texture can be added to the CCSpriteBatchNode. All CCParticleSystems added to a CCSpriteBatchNode are drawn in one OpenGL ES draw call. If the CCParticleSystems are not added to a CCParticleBatchNode then an OpenGL ES draw call will be needed for each one, which is less efficient.
</div>
<p>CCParticleBatchNode可以引用且只可以引用1个texture(一个图片文件,一个texture图集).只有CCParticleSystem可以增加到CCSpriteBatchNode中.
所有增加到CCSpriteBatchNode中的CCParticleSystem是在OpenGL ES调用绘图函数时绘制的.
如果CCParticleSystem没有增加到CCParticleBatchNode中,OpenGL ES会调用每个粒子系统的绘图函数,这样做是低效的.</p>
<h3>创建Quad粒子系统</h3>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>CCParticleSystemQuad* m_emitter = newCCParticleSystemQuad();
</span><span class='line'>m_emitter = CCParticleFire::create();</span></code></pre></td></tr></table></div></figure>
<h2>重力和半径模式</h2>
<h3>重力模式 Gravity Mode</h3>
<div style='display:none;'>
Gravity Mode lets particles fly toward or away from a center point. Its strength is that it allows very dynamic, organic effects. You can set gravity mode with this line:
</div>
<p>重力模式让粒子围绕一个中心点移近或移远.它的优点是非常动态,有组织有规则的效果.你可以通过下面这行代码设置重力模式:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>// Gravity Mode
</span><span class='line'>this->m_nEmitterMode = kCCParticleModeGravity;
</span><span class='line'>
</span><span class='line'>// Gravity Mode: gravity
</span><span class='line'>this->modeA.gravity = ccp(0,-90);</span></code></pre></td></tr></table></div></figure>
<div style='display:none;'>
These properties are only valid in Gravity Mode:
</div>
<p><strong>下面这些属性只在重力模式下支持:</strong></p>
<div style='display:none;'>
- gravity (a CGPoint). The gravity of the particle system
- speed (a float). The speed at which the particles are emitted
- speedVar (a float). The speed variance.
- tangencialAccel (a float). The tangential acceleration of the particles.
- tangencialAccelVar (a float). The tangential acceleration variance.
- radialAccel (a float). The radial acceleration of the particles.
- radialAccelVar (a float). The radial acceleration variance.
</div>
<ul>
<li>重力(CGPoint)。粒子系统的重力。</li>
<li>速度(float)。粒子发射时的速度。</li>
<li>速度变量speedVar(float)。速度的变异数。</li>
<li>tangencialAccel(float)。粒子的正切加速度。</li>
<li>tangencialAccelVar(float)。粒子正切加速度的差异数。</li>
<li>radialAccel(float)。粒子的径向加速度。</li>
<li>radialAccelVar(float)。粒子径向加速度的差异数。</li>
</ul>
<h3>半径模式 Radius Mode</h3>
<div style='display:none;'>
Radius Mode causes particles to rotate in a circle. It also allows you to create spiral effects with particles either rushing inward or orating outward. You set radius mode with this line:
</div>
<p>半径模式会使粒子以圆圈方式旋转.它也可以创造螺旋效果让粒子急速前进或后退.你可以通过下面这行代码设置半径模式:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>// Radius Mode
</span><span class='line'>this->m_nEmitterMode = kCCParticleModeRadius;
</span><span class='line'>
</span><span class='line'>// Radius Mode: startRadius
</span><span class='line'>this->modeB.startRadius = 0;
</span><span class='line'>this->modeB.startRadiusVar = 0;//ccp(0,0);</span></code></pre></td></tr></table></div></figure>
<div style='display:none;'>
These properties are only valid in Radius Mode:
</div>
<p><strong>下面这些属性只在半径模式下支持:</strong></p>
<div style='display:none;'>
- startRadius (a float). The starting radius of the particles
- startRadiusVar (a float). The starting radius variance
- endRadius (a float). The ending radius of the particles.
- endRadiusVar (a float). The ending radius variance
- rotatePerSecond (a float). Number of degress to rotate a particle around the source pos per second.
- rotatePerSecondVar (a float). Number of degrees variance.
</div>
<ul>
<li>startRadius(float)。粒子开始时的半径。</li>
<li>startRadiusVar(float)。粒子开始时的半径变异数。</li>
<li>endRadius(float)。粒子结束时的半径。</li>
<li>endRadiusVar(float)。结束时粒子的半径变异数。</li>
<li>rotatePerSecond(float)。粒子围绕原点每秒旋转的度数。</li>
<li>rotatePerSecondVar(float)。度数的变异数。</li>
</ul>
<h2>各模式下的通用属性</h2>
<h3>粒子通用属性:</h3>
<div style='display:none;'>
- startSize: Start size of the particles in pixels
- startSizeVar
- endSize: Use kCCParticleStartSizeEqualToEndSize if you want that the start size == end size.
- endSizeVar
- startColor (a ccColor4F)
- startColorVar (a ccColor4F)
- endColor (a ccColor4F)
- endColorVar (a ccColor4F)
- startSpin. Only used in CCParticleSystemQuad
- startSpinVar. Only used in CCParticleSystemQuad
- endSpin. Only used in CCParticleSystemQuad
- endSpinVar. Only used in CCParticleSystemQuad
- life: time to live of the particles in seconds
- lifeVar:
- angle: (a float). Starting degrees of the particle
- angleVar
- positon: (a CGPoint)
- posVar
- centerOfGravity (a CGPoint)
</div>
<ul>
<li>startSize: 开始时粒子的像素大小</li>
<li>startSizeVar</li>
<li>endSize: 如果你愿意的话使用kCCParticleStartSizeEqualToEndSize,这样开始大小 == 结束大小</li>
<li>endSizeVar</li>
<li>startColor开始颜色 (ccColor4F)</li>
<li>startColorVar (ccColor4F)</li>
<li>endColor结束颜色 (ccColor4F)</li>
<li>startSpin开始的旋转角度。只用于CCParticleSystemQuad</li>
<li>startSpinVar.只用于CCParticleSystemQuad</li>
<li>endSpin结束时的旋转角度。只用于CCParticleSystemQuad</li>
<li>endSpinVar。只用于CCParticleSystemQuad</li>
<li>life:粒子存活的时间,单位秒</li>
<li>lifeVar:</li>
<li>angle:(float)。粒子发射时的角度</li>
<li>angleVar</li>
<li>positon:(CGPoint)</li>
<li>posVar</li>
<li>centerOfGravity(CGPoint)重力中心点</li>
</ul>
<h3>粒子系统通用属性:</h3>
<div style='display:none;'>
- emissionRate (a float). How many particle are emitted per second
- duration (a float). How many seconds does the particle system (different than the life property) lives. Use kCCParticleDurationInfinity for infity.
- blendFunc (a ccBlendFunc). The OpenGL blending function used for the system
- positionType (a tCCPositionType). Use kCCPositionTypeFree (default one) for moving particles freely. Or use kCCPositionTypeGrouped to move them in a group.
- texture (a CCTexture2D). The texture used for the particles
</div>
<ul>
<li>emissionRate (float)。每秒发射多少粒子。</li>
<li>duration (float)。粒子系统可以存活多少秒(与life属性不同)。使用kCCParticleDurationInfinity为无限时间。</li>
<li>blendFunc (ccBlendFunc)。系统中使用的OpenGL混合方法。</li>
<li>positionType (CCPositionType)。粒子自由移动使用kCCPositionTypeFree(默认)。或者使用kCCPositionTypeGrouped,使粒子在集合中移动。</li>
<li>texture纹理(CCTexture2D)。粒子使用的纹理。</li>
</ul>
<h2>示例</h2>
<div style='display:none;'>
cocos2d-x comes with some predefined particles that can be customized in runtime. List of predefined particles:
</div>
<p>cocos2d-x里内置的预制粒子是可以在运行时自定义的.内置粒子列表:</p>
<ul>
<li>CCParticleFire: Point particle system. 使用重力模式.</li>
<li>CCParticleFireworks: Point particle system. 使用重力模式.</li>
<li>CCParticleSun: Point particle system. 使用重力模式.</li>
<li>CCParticleGalaxy: Point particle system. 使用重力模式.</li>
<li>CCParticleFlower: Point particle system. 使用重力模式.</li>
<li>CCParticleMeteor: Point particle system. 使用重力模式.</li>
<li>CCParticleSpiral: Point particle system. 使用重力模式.</li>
<li>CCParticleExplosion: Point particle system. 使用重力模式.</li>
<li>CCParticleSmoke: Point particle system. 使用重力模式.</li>
<li>CCParticleSnow: Point particle system. 使用重力模式.</li>
<li>CCParticleRain: Point particle system. 使用重力模式.</li>
</ul>
<h2>参考</h2>
<p><a href="http://en.wikipedia.org/wiki/Particles">粒子</a>
<a href="http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:particles">cocos2d中的粒子系统</a></p>
</div>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/2013/03/04/effects/">[Cocos2d-x wiki翻译]Effects</a></h1>
<p class="meta">
<time datetime="2013-03-04T16:58:00+08:00" pubdate data-updated="true">Mar 4<span>th</span>, 2013</time>
</p>
</header>
<div class="entry-content"><h1>Effects</h1>
<h2>介绍</h2>
<div style='display:none;'>
Effects are a special kind of action. Instead of modifying normal properties like opacity, position, rotation, or scale, they modify a new kind of property: the grid property.
</div>
<p>Effect是特殊类型的动作.与修改常规的属性如透明度、位置、旋转或缩放等不同,它们修改的是一种新类型的属性:grid属性.</p>
<div style='display:none;'>
A grid property is like a matrix, it is a network of lines that cross each other to form a series of squares or rectangles.
</div>
<p>grid属性像是一个矩阵,是由相互交叉形成一系列正方形和矩形的线组成的网络。</p>
<div style='display:none;'>
These special actions render any CocosNode object (Layer, Scene, Sprite, etc.) into the grid, and you can transform the grid by moving its vertices.
</div>
<p>这些特殊的动作可以渲染任一CocosNode对象 (Layer, Scene, Sprite, 等.)到grid中,你可以通过顶点来变换grid.</p>
<div style='display:none;'>
There are 2 kind of grids: tiled grids and non-tiled grids. The difference is that the tiled grid is composed of individual tiles while the non-tiled grid is composed of vertices.
</div>
<p>一共有2类grid: 瓦片grid(tiled grids)和非瓦片grid(non-tiled grids).它们的区别在于瓦片grid是由独立的瓦片(tile)组成,而非瓦片grid由顶点组成。</p>
<p><img src="http://www.cocos2d-x.org/attachments/1575/tiled_and_nontiled_grid.png" alt="" /></p>
<div style='display:none;'>
The following is an example of Ripple3D action, who uses a Grid3D (non-tiled) grid:
</div>
<p></p>
<p>下面是Ripple3D动作例子,它使用的是 Grid3D (非瓦片的) grid:
<img src="http://www.cocos2d-x.org/attachments/1576/effect_ripple3d.png" alt="" />
<img src="http://www.cocos2d-x.org/attachments/1577/effect_ripple3d_grid.png" alt="" /></p>
<div style='display:none;'>
and the following is an example of FadeOutTR action, who uses a TiledGrid3D (tiled) grid:
</div>
<p></p>
<p>接下来是FadeOutTR动作例子,它用的是TiledGrid3D (瓦片) grid:</p>
<p><img src="http://www.cocos2d-x.org/attachments/1578/effect_fadeouttiles.png" alt="" />
<img src="http://www.cocos2d-x.org/attachments/1579/effect_fadeouttiles_grid.png" alt="" /></p>
<h2>用法</h2>
<div style='display:none;'>
Like any other action, it is executed by the runAction. eg:
</div>
<p>和其他动作一样,是通过runAction执行的.例如:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>// Create an sprite
</span><span class='line'>CCSprite* grossini = CCSprite::create("grossini.png");
</span><span class='line'>grossini->runAction(CCLiquid::create(4, 20, ccg(10,10), 5));</span></code></pre></td></tr></table></div></figure>
<div style='display:none;'>
Liquid, like any other grid action, receives the grid parameter. You can adjust the quality of the effect by increasing the size of the grid. But it also implies less FPS.
The Effects are IntervalAction actions so you can treat them like any other action. eg:
</div>
<p>和其他grid动作一样,Liquid会接收一个grid参数.你可以通过增加grid的大小来调整effect(效果)的品质.但是它也意味着有很少的FPS. <br/>
Effect是IntervalAction动作(延时动作),所以你可以用像其他动作的处理方式一样来处理它们.例如:</p>
<figure class='code'><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
<span class='line-number'>2</span>
<span class='line-number'>3</span>
<span class='line-number'>4</span>
<span class='line-number'>5</span>
<span class='line-number'>6</span>
<span class='line-number'>7</span>
<span class='line-number'>8</span>
</pre></td><td class='code'><pre><code class=''><span class='line'>// create a Lens3D action
</span><span class='line'>CCActionInterval* lens = CCLens3D::create(ccp(240,160),240,ccg(15,10),8);
</span><span class='line'>
</span><span class='line'>// create a Waved3D action
</span><span class='line'>CCActionInterval* waves = CCWaves3D::create(18,80,ccg(15,10),10);
</span><span class='line'>
</span><span class='line'>// create a sequence an repeat it forever
</span><span class='line'>grossini->runAction(CCRepeatForever::create((CCSequence*)CCSequence::create(waves, lens, NULL ) ) );</span></code></pre></td></tr></table></div></figure>
<div style='display:none;'>
The following is the list of the available Grid3D (non-tiled) actions in v2.1.0:
</div>
<p>下面是v2.1.0版本中Grid3D(non-tiled) actions的可用列表:</p>
<table>
<thead>
<tr>
<th>Shaky3D</th>
<th>Waves3D</th>
<th>FlipX3D</th>
<th>FlipY3D</th>
</tr>
</thead>
<tbody>
<tr>
<td><img src="http://www.cocos2d-x.org/attachments/1580/IMG_0001.PNG" alt="" /></td>
<td><img src="http://www.cocos2d-x.org/attachments/1581/IMG_0002.PNG" alt="" /></td>
<td><img src="http://www.cocos2d-x.org/attachments/1582/IMG_0003.PNG" alt="" /></td>
<td><img src="http://www.cocos2d-x.org/attachments/1583/IMG_0004.PNG" alt="" /></td>
</tr>
</tbody>
</table>
<table>
<thead>
<tr>
<th>Lens3D</th>
<th>Liquid</th>
<th>Waves</th>
<th>Twirl </th>
</tr>
</thead>
<tbody>
<tr>
<td><img src="http://www.cocos2d-x.org/attachments/1584/IMG_0005.PNG" alt="" /></td>
<td><img src="http://www.cocos2d-x.org/attachments/1585/IMG_0007.PNG" alt="" /></td>
<td><img src="http://www.cocos2d-x.org/attachments/1586/IMG_0008.PNG" alt="" /></td>
<td><img src="http://www.cocos2d-x.org/attachments/1587/IMG_0011.PNG" alt="" /></td>
</tr>
</tbody>
</table>
<table>
<thead>
<tr>
<th>Ripple3D</th>
</tr>
</thead>
<tbody>
<tr>
<td><img src="http://www.cocos2d-x.org/attachments/1588/IMG_0002_2.PNG" alt="" />|</td>
</tr>
</tbody>
</table>
<div style='display:none;'>
The following is the list of the available TiledGrid3D (tiled) actions
</div>
<p>下面是TiledGrid3D(tiled) 动作可用的列表:</p>
<table>
<thead>
<tr>
<th>ShakyTiles3D</th>
<th>ShatteredTiles3D</th>
<th>ShuffleTiles</th>
<th>FadeOutTRTiles </th>
</tr>
</thead>
<tbody>
<tr>
<td><img src="http://www.cocos2d-x.org/attachments/1593/IMG_0012.PNG" alt="" /></td>
<td><img src="http://www.cocos2d-x.org/attachments/1594/IMG_0013.PNG" alt="" /></td>
<td><img src="http://www.cocos2d-x.org/attachments/1595/IMG_0014.PNG" alt="" /></td>
<td><img src="http://www.cocos2d-x.org/attachments/1596/IMG_0015.PNG" alt="" /></td>
</tr>
</tbody>
</table>
<table>
<thead>
<tr>
<th>FadeOutBLTiles</th>
<th>FadeOutUpTiles</th>
<th>FadeOutDownTiles</th>
<th>TurnOffTiles </th>
</tr>
</thead>
<tbody>
<tr>
<td><img src="http://www.cocos2d-x.org/attachments/1597/IMG_0016.PNG" alt="" /></td>
<td><img src="http://www.cocos2d-x.org/attachments/1598/IMG_0017.PNG" alt="" /></td>
<td><img src="http://www.cocos2d-x.org/attachments/1599/IMG_0019.PNG" alt="" /></td>
<td><img src="http://www.cocos2d-x.org/attachments/1600/IMG_0020.PNG" alt="" /></td>
</tr>
</tbody>
</table>
<table>
<thead>
<tr>
<th>WavesTiles3D</th>
<th>JumpTiles3D</th>
<th>SplitRows</th>
<th>SplitCols </th>
</tr>
</thead>
<tbody>
<tr>
<td><img src="http://www.cocos2d-x.org/attachments/1601/IMG_0021.PNG" alt="" /></td>
<td><img src="http://www.cocos2d-x.org/attachments/1602/IMG_0022.PNG" alt="" /></td>
<td><img src="http://www.cocos2d-x.org/attachments/1603/IMG_0023.PNG" alt="" /></td>
<td><img src="http://www.cocos2d-x.org/attachments/1604/IMG_0024.PNG" alt="" /></td>
</tr>
</tbody>
</table>
<h2>参考</h2>
<p>cocos2d-iphone <a href="http://www.cocos2d-iphone.org/archives/40">cocos2d’s effects简介</a></p>
</div>
</article>
<article>
<header>
<h1 class="entry-title"><a href="/blog/2013/03/04/skeletal-animation/">[Cocos2d-x Wiki翻译]骨骼动画</a></h1>
<p class="meta">
<time datetime="2013-03-04T16:57:00+08:00" pubdate data-updated="true">Mar 4<span>th</span>, 2013</time>
</p>
</header>
<div class="entry-content"><!-- Skeletal animation -->
<h2>骨骼动画 vs. 精灵表</h2>
<!-- ## Skeletal animation vs. Sprite sheets -->
<div style='display:none;'>
You can creat animations using “sprite sheets” which is quick and easy. Until you realize your game needs lots of animations and the memory consumption goes way up, together with the time required to load all the data. Also, to limit the size, you need to limit yourself to a low FPS for the animation, which also means the animation doesn’t look as smooth as you’d like. This is where skeletal animation comes in.
</div>
<p>创建动画又快又简单的方法是使用“精灵表”.当你意识到游戏需要大量动画,内存消耗会涨上来,而且需要耗时去加载所有数据.此外,限于大小,你需要为了动画限制自己使用低FPS,这意味着动画不是你想要的那么平滑.这就是骨骼动画的由来.</p>
<!-- ## Introducing Skeletal Animation -->
<h2>骨骼动画简述</h2>
<div style='display:none;'>
Skeletal animation is a technique in cocos2d-x animation in which a character is represented in two parts: a surface representation used to draw the character (called skin or mesh) and a hierarchical set of interconnected bones (called the skeleton or rig) used to animate (pose and keyframe) the mesh.
</div>
<p>骨骼动画是cocos2d-x动画在人物渲染方面的技术,分二个部分:用于绘制人物的外观呈现(被称为蒙皮或者mesh)和用于mesh进行动画(造型和关键帧) 的一组分层的相互连接的骨骼.</p>
<p><img src="http://www.cocos2d-x.org/attachments/1606/Skeletal-Animation.jpg" alt="" /></p>
<div style='display:none;'>
Cocos2d-x provides a way to have 2d skeletal animations in your applications. The process of skeletal animation may be a bit complicated to setup, but using them afterwards is easy, and there are some tools to simplify the process.
</div>
<p>在你的应用中,Cocos2d-x提供了拥有2d骨骼动画的方式.构建骨骼动画过程开始可能有点复杂,但随后用起来却非常简单,而且有一些工具可以简化此过程.</p>
<div style='display:none;'>
When using skeletal animation, the animation is composed of several bones which are connected to one another. Affecting a bone also affects all of its children. By composing different transformations on each bone, you obtain different poses for the skeleton.
</div>
<p>当使用骨骼动画时,动画由一些相互连接的骨骼组成。影响一个骨骼将会影响其所有的子对象。通过每根骨头上不同的变换组合,你会得到骨骼的各种造型。</p>
<div style='display:none;'>
Now, if you define keyframes with certain transformations for a point in time for each of the bones in the skeleton, you can interpolate between the keyframes to obtain a smooth transition and thus animate the skeleton.
</div>
<p>现在,如果你定义了关键帧,即某个时间点骨骼中每根骨头特定的变换,你就能在关键帧之间插入平滑的过渡,从而使骨骼运动。</p>
<div style='display:none;'>
In the attached code, I used a class named Transformation, which contains data about 2D transformations, like translation, rotation and scale. Then, a Keyframe is defined by a frame number and one such Transformation. A collection of Keyframes defines a KeyframeAnimation. Finally, a SkeletonAnimation is a collection of KeyframeAnimations, one for each bone in the skeleton.
</div>
<p>在附加的代码中,我使用一个名叫Transformation的类,它含有2D变换的数据,如translation(平移)、rotation(旋转)和scale(缩放)。通过帧的编号和一个Transformation能定义一个关键帧。关键帧的集合定义了一个KeyFrameAnimation.最后,骨骼动画就是一个KeyFrameAnimation的集合,每个KeyFrameAnimation应用于骨骼中的每根骨头。</p>
<div style='display:none;'>
Separately, you use a Skeleton, which keeps a list of Joints that define the hierarchy of bones in the skeleton. Different from “sprite sheets”,each bone is then assigned a certain texture, like the ones below:
</div>
<p>另外,你使用骨骼,它保存了关节列表,关节定义了骨骼中骨头的层级。不同于“精灵表”,每根骨头指定了特定的texture,如下所示:</p>
<p><img src="http://www.cocos2d-x.org/attachments/1607/animated-grossini.png" alt="" /></p>
<!-- ## Tool for skeleton animation -->
<h2>骨骼动画工具</h2>
<div style='display:none;'>
So far as we know, [CocosBuilder](http://cocosbuilder.com/) is a great, free (MIT license) tool for creating skeleton animations.
CocosBuilder is built for Cocos2d’s Javascript bindings, which means that your code, animations, and interfaces will run unmodified in Cocos2d-x.
A tutorial for cocos2d-iphone can be found at the [Zynga Engineering blog](http://code.zynga.com/2012/10/creating-a-game-with-cocosbuilder/)
</div>
<p>据我们所知,在创建骨骼动画方面<a href="http://cocosbuilder.com/">CocosBuilder</a>是一个不错的、免费(MIT协议)的工具。 <br/>
CocosBuilder为Cocos2d的Javascript绑定而创建的。这意味着你的代码、动画和接口会无修改地在Cocos2d-x中运行。 <br/>
cocos2d-iphone的教程可以在<a href="http://code.zynga.com/2012/10/creating-a-game-with-cocosbuilder/">Zynga Engineering blog</a>找到。</p>
<!-- ## Working with cocosbuilder Animations -->
<h2>与cocosbuilder动画协作</h2>
<div style='display:none;'>
You can use CocosBuilder for creating character animations, animating complete scenes or just about any animation you can imagine. The animation editor has full support for multiple resolutions, easing between keyframes, boned animations and multiple timelines to name a few of the features.
h3.The Basics
In the bottom of the main window you can find the timeline. You use the timeline to create your animations.
</div>
<p>你可以使用CocosBuilder创建人物动画,全场景动画或者你所想的任何动画。该动画编辑器已完全支持多分辨率、关键帧间的缓冲动画、骨骼动画和多时间轴等特性。</p>
<h3>基础</h3>
<p>在主窗口的下部,你可以找到时间轴。你可以使用时间轴来创建你的动画。
<img src="http://www.cocos2d-x.org/attachments/1610/timeline.png" alt="" /></p>
<div style='display:none;'>