base.py 844B

1234567891011121314151617181920212223242526272829
  1. # coding: utf-8
  2. import random
  3. from sandbox.tile.gui.animation import ANIMATION_WALK
  4. from sandbox.tile.gui.animation import ANIMATION_CRAWL
  5. from synergine2_cocos2d.animation import Animate
  6. from synergine2_cocos2d.gui import TMXGui
  7. class Game(TMXGui):
  8. def before_run(self) -> None:
  9. # Test
  10. from sandbox.tile.gui.actor import Man
  11. from cocos import euclid
  12. for i in range(10):
  13. x = random.randint(0, 600)
  14. y = random.randint(0, 300)
  15. man = Man()
  16. man.update_position(euclid.Vector2(x, y))
  17. self.layer_manager.add_subject(man)
  18. self.layer_manager.set_selectable(man)
  19. man.scale = 1
  20. if x % 2:
  21. man.do(Animate(ANIMATION_WALK, 10, 4))
  22. else:
  23. man.do(Animate(ANIMATION_CRAWL, 20, 4))