Pārlūkot izejas kodu

actor: texture for mode

Bastien Sevajol 6 gadus atpakaļ
vecāks
revīzija
b1660820eb
1 mainītis faili ar 20 papildinājumiem un 1 dzēšanām
  1. 20 1
      synergine2_cocos2d/actor.py

+ 20 - 1
synergine2_cocos2d/actor.py Parādīt failu

@@ -189,7 +189,26 @@ class Actor(AnimatedInterface, cocos.sprite.Sprite):
189 189
         return self.animation_textures_cache[animation_name]
190 190
 
191 191
     def get_inanimate_image(self) -> pyglet.image.TextureRegion:
192
-        return self.default_texture
192
+        return self.get_current_mode_texture()
193
+
194
+    def get_current_mode_texture(self) -> pyglet.image.TextureRegion:
195
+        try:
196
+            return self.mode_texture_cache[self.mode]
197
+        except KeyError:
198
+            self.logger.debug(
199
+                'No texture for mode "{}" for actor "{}", available: ({})'.format(
200
+                    self.mode,
201
+                    self.__class__.__name__,
202
+                    ', '.join(self.mode_texture_cache.keys()),
203
+                ),
204
+            )
205
+            return self.mode_texture_cache[self.get_default_mode()]
206
+
207
+    def reset_default_texture(self) -> None:
208
+        if self._freeze:
209
+            return
210
+
211
+        self.image = self.get_current_mode_texture()
193 212
 
194 213
     def update_image(self, new_image: pyglet.image.TextureRegion):
195 214
         if self._freeze: