status_bar.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import datetime
  2. import cocos
  3. from app.verkolst import verkolst
  4. class StatusBar(cocos.layer.Layer):
  5. def __init__(self):
  6. super().__init__()
  7. background = cocos.sprite.Sprite('bottom_bar_1920_100_px.png',
  8. position=(0, 0),
  9. anchor=(0, 0))
  10. self.add(background)
  11. gold_icon = cocos.sprite.Sprite('gold_40_40_px.png',
  12. position=(100, 4),
  13. anchor=(0, 0))
  14. gold_count = cocos.text.Label('1238',
  15. position=(140, 12),
  16. font_size=20,
  17. )
  18. self.add(gold_icon)
  19. self.add(gold_count)
  20. self.date_label = cocos.text.Label('-',
  21. position=(1920-5, 12),
  22. font_size=20,
  23. anchor_x="right")
  24. self.add(self.date_label)
  25. def on_turn_start(self):
  26. month = datetime.datetime.strftime(verkolst.date, '%B')
  27. self.date_label.element.text = f'{month} {verkolst.date.day}, {verkolst.date.year}'