19
19
from cocos import text
20
20
21
21
22
+ def get_color_layer ( idx ):
23
+ if idx % 2 == 0 :
24
+ return cocos .layer .ColorLayer (32 ,32 ,32 ,255 )
25
+ else :
26
+ return cocos .layer .ColorLayer (32 ,64 ,200 ,255 )
27
+
22
28
class HelloWorld (Layer ):
23
29
def __init__ (self ):
24
30
@@ -147,14 +153,15 @@ def next_scene(self):
147
153
if self .scene_p >= len (self .scenes ):
148
154
self .scene_p = len (self .scenes )- 1
149
155
else :
150
- self .transition (self .transitions [self .scene_p % len (self .transitions )])
156
+ self .transition (self .transitions [self .scene_p % len (self .transitions )- 1 ])
151
157
152
158
def prev_scene (self ):
153
159
self .scene_p -= 1
154
160
if self .scene_p < 0 :
155
161
self .scene_p = 0
156
162
else :
157
- self .transition ()
163
+ # self.transition()
164
+ self .transition (self .transitions [self .scene_p % len (self .transitions )])
158
165
159
166
def transition (self , transition = None ):
160
167
if transition :
@@ -279,18 +286,18 @@ def __init__( self ):
279
286
current_transition = 0
280
287
281
288
scenes = [
282
- cocos .scene .Scene (cocos . layer . ColorLayer ( 0 , 0 , 0 , 255 ),
289
+ cocos .scene .Scene (
283
290
TitleSubTitleLayer ("cocos2d" , "a 2d game library" ),
284
291
),
285
- cocos .scene .Scene (cocos . layer . ColorLayer ( 0 , 0 , 0 , 255 ),
292
+ cocos .scene .Scene (
286
293
BulletListLayer ("cocos2d" , [
287
294
"a framework for" ,
288
295
"building 2D games, demos" ,
289
296
"and other graphical interactive applications" ,
290
297
"developed 100% in python" ,
291
298
])
292
299
),
293
- cocos .scene .Scene (cocos . layer . ColorLayer ( 0 , 0 , 0 , 255 ),
300
+ cocos .scene .Scene (
294
301
BulletListLayer ("Games-Python" , [
295
302
"Games in an interpreted language?" ,
296
303
"Depends on the game" ,
@@ -299,15 +306,15 @@ def __init__( self ):
299
306
),
300
307
301
308
302
- cocos .scene .Scene (cocos . layer . ColorLayer ( 0 , 0 , 0 , 255 ),
309
+ cocos .scene .Scene (
303
310
BulletListLayer ("Inspiration" , [
304
311
"2000 : pygame" ,
305
312
"2005 : pyweek" ,
306
313
"2006 : pyglet" ,
307
314
"2008 : cocos2d"
308
315
])
309
316
),
310
- cocos .scene .Scene (cocos . layer . ColorLayer ( 0 , 0 , 0 , 255 ),
317
+ cocos .scene .Scene (
311
318
BulletListLayer ("Features" , [
312
319
"Flow Control" ,
313
320
"Sprites" ,
@@ -317,7 +324,7 @@ def __init__( self ):
317
324
"Menus" ,
318
325
])
319
326
),
320
- cocos .scene .Scene (cocos . layer . ColorLayer ( 0 , 0 , 0 , 255 ),
327
+ cocos .scene .Scene (
321
328
BulletListLayer ("Features (2)" , [
322
329
"Text / HTML" ,
323
330
"Tiles"
@@ -328,11 +335,11 @@ def __init__( self ):
328
335
"OpenGL" ,
329
336
]),
330
337
),
331
- cocos .scene .Scene ( cocos . layer . ColorLayer ( 0 , 0 , 0 , 255 ),
338
+ cocos .scene .Scene (
332
339
BulletListLayer ("Concepts" , []).add (
333
340
Sprite ("scene_en.png" , (x / 2 , 100 ))),
334
341
),
335
- cocos .scene .Scene (cocos . layer . ColorLayer ( 0 , 0 , 0 , 255 ),
342
+ cocos .scene .Scene (
336
343
BulletListLayer ("Documentation" , [
337
344
"Video Tutorial" ,
338
345
"Programming guide" ,
@@ -344,22 +351,22 @@ def __init__( self ):
344
351
]),
345
352
),
346
353
347
- cocos .scene .Scene (cocos . layer . ColorLayer ( 0 , 0 , 0 , 255 ),
354
+ cocos .scene .Scene (
348
355
BulletListLayer ("Community" , [
349
356
"5 finished games" ,
350
357
"Several projects in development" ,
351
358
"Contributors from around the world" ,
352
359
"Working mailing list" ,
353
360
]),
354
361
),
355
- cocos .scene .Scene ( cocos . layer . ColorLayer ( 0 , 0 , 0 , 255 ),
362
+ cocos .scene .Scene (
356
363
BulletListLayer ("Flow Control" , [
357
364
"director.run()" ,
358
365
"director.push() / pop()" ,
359
366
"director.replace" ,
360
367
]),
361
368
),
362
- cocos .scene .Scene (cocos . layer . ColorLayer ( 0 , 0 , 0 , 255 ),
369
+ cocos .scene .Scene (
363
370
BulletListLayer ("Sprites" , [
364
371
"position" ,
365
372
"scale" ,
@@ -368,7 +375,7 @@ def __init__( self ):
368
375
"opacity" ,
369
376
]),
370
377
),
371
- cocos .scene .Scene ( cocos . layer . ColorLayer ( 0 , 0 , 0 , 255 ),
378
+ cocos .scene .Scene (
372
379
BulletListLayer ("Basic Actions" , [
373
380
"MoveBy/To" ,
374
381
"ScaleBy/To" ,
@@ -377,7 +384,7 @@ def __init__( self ):
377
384
"FadeIn/FadeOut" ,
378
385
]),
379
386
),
380
- cocos .scene .Scene ( cocos . layer . ColorLayer ( 0 , 0 , 0 , 255 ),
387
+ cocos .scene .Scene (
381
388
BulletListLayer ("More Actions" , [
382
389
"Reverse" ,
383
390
"Sequence" ,
@@ -388,7 +395,7 @@ def __init__( self ):
388
395
"CallFunc" ,
389
396
]),
390
397
),
391
- cocos .scene .Scene (cocos . layer . ColorLayer ( 0 , 0 , 0 , 255 ),
398
+ cocos .scene .Scene (
392
399
BulletListLayer ("Effects: Theory" , [
393
400
"FrameBuffer Object" ,
394
401
"PixelBuffer Object" ,
@@ -398,7 +405,7 @@ def __init__( self ):
398
405
#"PONER SCREENSHOTS / SLIDES PARA EXPLICAR TEORIA",
399
406
]),
400
407
),
401
- cocos .scene .Scene (cocos . layer . ColorLayer ( 0 , 0 , 0 , 255 ),
408
+ cocos .scene .Scene (
402
409
BulletListLayer ("More Effects" , [
403
410
"Ripple3D" ,
404
411
"Lens" ,
@@ -407,27 +414,35 @@ def __init__( self ):
407
414
"OrbitCamera" ,
408
415
]),
409
416
),
410
- cocos .scene .Scene (cocos . layer . ColorLayer ( 0 , 0 , 0 , 255 ),
417
+ cocos .scene .Scene (
411
418
BulletListLayer ("More Effects II" , [
412
419
"Actions" ,
413
420
"Lens + Jump" ,
414
421
"Reuse Grid" ,
415
422
]),
416
423
),
417
- cocos .scene .Scene (cocos . layer . ColorLayer ( 0 , 0 , 0 , 255 ),
424
+ cocos .scene .Scene (
418
425
BulletListLayer ("Coming soon" , [
419
426
"Particle system" ,
420
427
"Pymunk integration" ,
421
428
"Drawing primitives" ,
422
429
]),
423
430
),
424
431
425
- cocos .scene .Scene (cocos . layer . ColorLayer ( 0 , 0 , 0 , 255 ),
432
+ cocos .scene .Scene (
426
433
TitleSubTitleLayer ("cocos2d" , "http://www.cocos2d.org" ),
427
434
),
428
435
]
436
+
437
+ i = 0 ;
438
+ for s in scenes :
439
+ s .add ( get_color_layer (i ), z = - 1 )
440
+ i = i + 1
441
+
429
442
transitions = [None ]* (len (scenes )- 1 )
430
- all_t = ['RotoZoomTransition' ,'JumpZoomTransition' ,
443
+ all_t = [
444
+ 'ZoomTransition' ,
445
+ 'RotoZoomTransition' ,'JumpZoomTransition' ,
431
446
432
447
'SlideInLTransition' ,'SlideInRTransition' ,
433
448
'SlideInBTransition' ,'SlideInTTransition' ,
@@ -462,9 +477,9 @@ def color_name_scene(name, color):
462
477
)
463
478
)
464
479
)
465
- director .interpreter_locals ["uno " ] = color_name_scene ("uno " , (255 ,0 ,0 ,255 ))
466
- director .interpreter_locals ["dos " ] = color_name_scene ("dos " , (0 ,255 ,0 ,255 ))
467
- director .interpreter_locals ["tres " ] = color_name_scene ("tres " , (0 ,0 ,255 ,255 ))
480
+ director .interpreter_locals ["one " ] = color_name_scene ("one " , (255 ,0 ,0 ,255 ))
481
+ director .interpreter_locals ["two " ] = color_name_scene ("two " , (0 ,255 ,0 ,255 ))
482
+ director .interpreter_locals ["three " ] = color_name_scene ("three " , (0 ,0 ,255 ,255 ))
468
483
469
484
470
485
director .run (scenes [0 ])
0 commit comments