change_resolution.script 646 B

1234567891011121314151617181920212223
  1. local init_width, init_height = 0, 0
  2. function init(self)
  3. msg.post(".", "acquire_input_focus")
  4. init_width, init_height = window.get_size()
  5. self.curr_width, self.curr_height = init_width, init_height
  6. timer.delay(1, true, function()
  7. msg.post("/go#layoutsui", "update_score", {score = math.random(1, 3)})
  8. end)
  9. end
  10. function on_input(self, action_id, action)
  11. if action_id == hash("touch") and action.released then
  12. if self.curr_width == init_width then
  13. self.curr_width = self.curr_width + 20
  14. else
  15. self.curr_width = init_width
  16. end
  17. msg.post("@render:", "resize", { width = self.curr_width, height = self.curr_height } )
  18. end
  19. end