源战役客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.9 KiB

  1. CheatAccelerationView = CheatAccelerationView or BaseClass(BaseView)
  2. local CheatAccelerationView = CheatAccelerationView
  3. function CheatAccelerationView:__init()
  4. self.base_file = "cheat"
  5. self.layout_file = "CheatAccelerationView"
  6. self.layer_name = "Top"
  7. self.destroy_imm = true
  8. self.use_background = true
  9. self.change_scene_close = false
  10. self.input = UnityEngine.Input
  11. self.load_callback = function ()
  12. self:LoadSuccess()
  13. self:AddEvent()
  14. end
  15. self.open_callback = function ( )
  16. self:OpenSuccess()
  17. end
  18. self.destroy_callback = function ( )
  19. self:DestroySuccess()
  20. end
  21. end
  22. function CheatAccelerationView:Open( )
  23. --self.data = data
  24. BaseView.Open(self)
  25. end
  26. function CheatAccelerationView:LoadSuccess()
  27. self.pos = self:GetChild("pos"):GetComponent("Text")
  28. self.win_bg = self:GetChild("windowBg")
  29. self.win_bg_img = self:GetChild("windowBg"):GetComponent("RawImage")
  30. self.win_close_btn = self:GetChild("di_head/windowCloseBtn").gameObject
  31. -- UnityEngine.Input.gyro.enabled = true
  32. lua_resM:setOutsideRawImage(self, self.win_bg_img, GameResPath.GetViewBigBg("default_bg_3"), false)
  33. end
  34. function CheatAccelerationView:AddEvent()
  35. local function onCloseBtnHandler(target)
  36. self:Close()
  37. end
  38. AddClickEvent(self.win_close_btn,onCloseBtnHandler,1)
  39. end
  40. function CheatAccelerationView:OpenSuccess()
  41. -- local is_enable = UnityEngine.Input.gyro.enabled
  42. Runner:getInstance():AddLateRunObj(self, 2)
  43. end
  44. function CheatAccelerationView:DestroySuccess( )
  45. self.input = false
  46. Runner:getInstance():RemoveLateRunObj(self)
  47. end
  48. function CheatAccelerationView:LateUpdate( now_time, elapse_time )
  49. local x = self.input.acceleration.x
  50. local y = self.input.acceleration.y
  51. local offset_x, offset_y = Mathf.Round(x*100) , Mathf.Round(y*100)
  52. self.pos.text = " x = "..x.."\n y = "..y.." \n offset_x = "..offset_x.."\n offset_y = "..offset_y
  53. SetLocalPosition(self.win_bg, offset_x, offset_y, 0)
  54. end