Bastien Sevajol hace 6 años
padre
commit
4b4836a28c

+ 7 - 2
sandbox/tiledstrategy/gui/actor.py Ver fichero

@@ -1,9 +1,8 @@
1 1
 # coding: utf-8
2
-import typing
3
-
4 2
 import pyglet
5 3
 
6 4
 from sandbox.tiledstrategy.gui.animation import ANIMATION_WALK
5
+from sandbox.tiledstrategy.gui.animation import ANIMATION_CRAWL
7 6
 from synergine2_cocos2d.actor import Actor
8 7
 
9 8
 
@@ -21,6 +20,12 @@ class Man(Actor):
21 20
             'actors/man_w8.png',
22 21
             'actors/man_w9.png',
23 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 Ver fichero

@@ -2,3 +2,4 @@
2 2
 
3 3
 
4 4
 ANIMATION_WALK = 'WALK'
5
+ANIMATION_CRAWL = 'CRAWL'

+ 6 - 1
sandbox/tiledstrategy/gui/base.py Ver fichero

@@ -2,6 +2,7 @@
2 2
 import random
3 3
 
4 4
 from sandbox.tiledstrategy.gui.animation import ANIMATION_WALK
5
+from sandbox.tiledstrategy.gui.animation import ANIMATION_CRAWL
5 6
 from synergine2_cocos2d.animation import Animate
6 7
 from synergine2_cocos2d.gui import TMXGui
7 8
 
@@ -21,4 +22,8 @@ class Game(TMXGui):
21 22
             self.layer_manager.set_selectable(man)
22 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 Ver fichero


BIN
sandbox/tiledstrategy/maps/003/actors/man_c2.png Ver fichero


BIN
sandbox/tiledstrategy/maps/003/actors/man_c3.png Ver fichero


BIN
sandbox/tiledstrategy/maps/003/actors/man_c4.png Ver fichero


+ 1 - 0
synergine2_cocos2d/actor.py Ver fichero

@@ -64,3 +64,4 @@ class Actor(AnimatedInterface, cocos.sprite.Sprite):
64 64
 
65 65
     def update_image(self, new_image: pyglet.image.TextureRegion):
66 66
         self.image = new_image
67
+        self.image_anchor = new_image.width // 2, new_image.height // 2

+ 1 - 0
synergine2_cocos2d/animation.py Ver fichero

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