Bastien Sevajol 7 years ago
parent
commit
4b4836a28c

+ 7 - 2
sandbox/tiledstrategy/gui/actor.py View File

1
 # coding: utf-8
1
 # coding: utf-8
2
-import typing
3
-
4
 import pyglet
2
 import pyglet
5
 
3
 
6
 from sandbox.tiledstrategy.gui.animation import ANIMATION_WALK
4
 from sandbox.tiledstrategy.gui.animation import ANIMATION_WALK
5
+from sandbox.tiledstrategy.gui.animation import ANIMATION_CRAWL
7
 from synergine2_cocos2d.actor import Actor
6
 from synergine2_cocos2d.actor import Actor
8
 
7
 
9
 
8
 
21
             'actors/man_w8.png',
20
             'actors/man_w8.png',
22
             'actors/man_w9.png',
21
             'actors/man_w9.png',
23
             'actors/man_w10.png',
22
             'actors/man_w10.png',
23
+        ],
24
+        ANIMATION_CRAWL: [
25
+            'actors/man_c1.png',
26
+            'actors/man_c2.png',
27
+            'actors/man_c3.png',
28
+            'actors/man_c4.png',
24
         ]
29
         ]
25
     }
30
     }
26
 
31
 

+ 1 - 0
sandbox/tiledstrategy/gui/animation.py View File

2
 
2
 
3
 
3
 
4
 ANIMATION_WALK = 'WALK'
4
 ANIMATION_WALK = 'WALK'
5
+ANIMATION_CRAWL = 'CRAWL'

+ 6 - 1
sandbox/tiledstrategy/gui/base.py View File

2
 import random
2
 import random
3
 
3
 
4
 from sandbox.tiledstrategy.gui.animation import ANIMATION_WALK
4
 from sandbox.tiledstrategy.gui.animation import ANIMATION_WALK
5
+from sandbox.tiledstrategy.gui.animation import ANIMATION_CRAWL
5
 from synergine2_cocos2d.animation import Animate
6
 from synergine2_cocos2d.animation import Animate
6
 from synergine2_cocos2d.gui import TMXGui
7
 from synergine2_cocos2d.gui import TMXGui
7
 
8
 
21
             self.layer_manager.set_selectable(man)
22
             self.layer_manager.set_selectable(man)
22
             man.scale = 1
23
             man.scale = 1
23
 
24
 
24
-            man.do(Animate(ANIMATION_WALK, 10, 4))
25
+            if x % 2:
26
+                man.do(Animate(ANIMATION_WALK, 10, 4))
27
+            else:
28
+                # TODO: Problème de zone selectable, elle reste a la taille de image debout.
29
+                man.do(Animate(ANIMATION_CRAWL, 20, 4))

BIN
sandbox/tiledstrategy/maps/003/actors/man_c1.png View File


BIN
sandbox/tiledstrategy/maps/003/actors/man_c2.png View File


BIN
sandbox/tiledstrategy/maps/003/actors/man_c3.png View File


BIN
sandbox/tiledstrategy/maps/003/actors/man_c4.png View File


+ 1 - 0
synergine2_cocos2d/actor.py View File

64
 
64
 
65
     def update_image(self, new_image: pyglet.image.TextureRegion):
65
     def update_image(self, new_image: pyglet.image.TextureRegion):
66
         self.image = new_image
66
         self.image = new_image
67
+        self.image_anchor = new_image.width // 2, new_image.height // 2

+ 1 - 0
synergine2_cocos2d/animation.py View File

20
         raise NotImplementedError()
20
         raise NotImplementedError()
21
 
21
 
22
 
22
 
23
+# TODO: regarder pyglet.image.Animation
23
 class Animate(cocos.actions.IntervalAction):
24
 class Animate(cocos.actions.IntervalAction):
24
     def __init__(
25
     def __init__(
25
         self,
26
         self,