UI.js 995 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. 'atomic component';
  2. var fd = new Atomic.UIFontDescription();
  3. fd.id = "Vera";
  4. fd.size = 22;
  5. function createButton(self, text, event, layout) {
  6. var button = new Atomic.UIButton();
  7. button.text = text;
  8. button.fontDescription = fd;
  9. button.gravity = Atomic.UI_GRAVITY_RIGHT;
  10. button.onClick = function() {
  11. self.sendEvent(event);
  12. }
  13. layout.addChild(button);
  14. }
  15. exports.component = function(self) {
  16. // root view
  17. self.uiView = new Atomic.UIView();
  18. var layout = new Atomic.UILayout();
  19. layout.rect = self.uiView.rect;
  20. layout.axis = Atomic.UI_AXIS_Y;
  21. layout.layoutPosition = Atomic.UI_LAYOUT_POSITION_GRAVITY;
  22. self.uiView.addChild(layout);
  23. createButton(self, "Play Idle", "PlayIdle", layout);
  24. createButton(self, "Play Run", "PlayRun", layout);
  25. createButton(self, "Play Attack", "PlayAttack", layout);
  26. createButton(self, "Play Hit", "PlayHit", layout);
  27. createButton(self, "Play Dead", "PlayDead", layout);
  28. }