UI Loading


SUBMITTED BY: Guest

DATE: April 24, 2013, 11:24 p.m.

FORMAT: Lua

SIZE: 1.2 kB

HITS: 1207

  1. --[[
  2. //
  3. // Okzoniom::RPG
  4. // Copyright (C) 2010 - 2013
  5. //
  6. // - Louis SCHNELLBACH
  7. //
  8. --]]
  9. -- Create a Text2D which will be used to display FPS
  10. --[[
  11. _FPS is special: if it's loaded,
  12. then it'll be used in the Scene to display
  13. the current FPS
  14. --]]
  15. function setup()
  16. size = Graphics:get():getWindowSize();
  17. widget = Widget:new("fps_widget");
  18. label = Text2D:new("fps_label", widget, "FPS: ", 22);
  19. label:setOffset(Vertex(5,2));
  20. -- Place the FPS text next the label
  21. fps = Text2D:new("_FPS", widget, "00 ", 22);
  22. fps:setOffset(Vertex(label:getSize().x+5, 2));
  23. -- Set the size of the widget so that it matches all children :p
  24. widget:setSize(Vertex(fps:getSize().x+fps:getOffset().x+10, fps:getSize().y+8));
  25. -- And then, stick it in the right corner
  26. pos = Vertex:new();
  27. pos.x = size.x - widget:getSize().x;
  28. widget:setPosition(pos);
  29. widget:focusable(false);
  30. --]]
  31. -- Faint: use this to refresh widget position, including children
  32. widget:setPosition(widget:getPosition());
  33. end

comments powered by Disqus