1
1
import cocos
2
+ import os
3
+ import configobj_ext
4
+ import tiled2cocos
5
+
6
+ DEFAULT_PATH = "./config.ini"
7
+ DEFAULT_SPEC = "./config_spec.ini"
8
+
9
+ def app_path (rel_path ):
10
+ application_path = os .path .dirname (__file__ )
11
+ return os .path .join (application_path , rel_path )
12
+
13
+ def load_config ():
14
+ path = app_path (DEFAULT_PATH )
15
+ spec = app_path (DEFAULT_SPEC )
16
+ config = configobj_ext .read_config (path , configspec = spec )
17
+ return config
18
+
19
+ def prepare (config ):
20
+ cocos .director .director .init (width = config .Window .width , height = config .Window .height )
2
21
3
22
class HelloWorld (cocos .layer .Layer ):
4
23
def __init__ (self ):
5
24
super ( HelloWorld , self ).__init__ ()
6
25
7
- label = cocos .text .Label ('Hello, World!' ,
26
+ label = cocos .text .Label ('Gros bisous Even' . upper () ,
8
27
font_name = 'Times New Roman' ,
9
28
font_size = 32 ,
10
29
anchor_x = 'center' , anchor_y = 'center' )
@@ -13,7 +32,17 @@ def __init__(self):
13
32
self .add ( label )
14
33
15
34
if __name__ == "__main__" :
16
- cocos .director .director .init ()
35
+ config = load_config ()
36
+ prepare (config )
37
+ map_layer = tiled2cocos .load_map (config .Ressources .map3 )
38
+ map_layer .set_view (0 , 0 , config .Window .width , config .Window .height )
39
+ #map_layer.x = config.Window.width / 2.0
40
+ #map_layer.y = config.Window.height / 2.0
41
+ for c in map_layer .get_children ():
42
+ print c
43
+ c .do (cocos .actions .RotateBy ( 360 , duration = 2 ))
17
44
hello_layer = HelloWorld ()
18
- main_scene = cocos .scene .Scene (hello_layer )
45
+ main_scene = cocos .scene .Scene (* [map_layer , hello_layer ])
46
+ hello_layer .do ( cocos .actions .RotateBy ( 720 , duration = 5 ))
47
+
19
48
cocos .director .director .run (main_scene )
0 commit comments