|
CheatAccelerationView = CheatAccelerationView or BaseClass(BaseView)
|
|
local CheatAccelerationView = CheatAccelerationView
|
|
|
|
function CheatAccelerationView:__init()
|
|
self.base_file = "cheat"
|
|
self.layout_file = "CheatAccelerationView"
|
|
self.layer_name = "Top"
|
|
self.destroy_imm = true
|
|
self.use_background = true
|
|
self.change_scene_close = false
|
|
|
|
self.input = UnityEngine.Input
|
|
|
|
self.load_callback = function ()
|
|
self:LoadSuccess()
|
|
self:AddEvent()
|
|
end
|
|
self.open_callback = function ( )
|
|
self:OpenSuccess()
|
|
end
|
|
self.destroy_callback = function ( )
|
|
self:DestroySuccess()
|
|
end
|
|
end
|
|
|
|
function CheatAccelerationView:Open( )
|
|
--self.data = data
|
|
BaseView.Open(self)
|
|
end
|
|
|
|
function CheatAccelerationView:LoadSuccess()
|
|
self.pos = self:GetChild("pos"):GetComponent("Text")
|
|
self.win_bg = self:GetChild("windowBg")
|
|
self.win_bg_img = self:GetChild("windowBg"):GetComponent("RawImage")
|
|
self.win_close_btn = self:GetChild("di_head/windowCloseBtn").gameObject
|
|
-- UnityEngine.Input.gyro.enabled = true
|
|
lua_resM:setOutsideRawImage(self, self.win_bg_img, GameResPath.GetViewBigBg("default_bg_3"), false)
|
|
end
|
|
|
|
function CheatAccelerationView:AddEvent()
|
|
local function onCloseBtnHandler(target)
|
|
self:Close()
|
|
end
|
|
AddClickEvent(self.win_close_btn,onCloseBtnHandler,1)
|
|
end
|
|
|
|
function CheatAccelerationView:OpenSuccess()
|
|
-- local is_enable = UnityEngine.Input.gyro.enabled
|
|
|
|
Runner:getInstance():AddLateRunObj(self, 2)
|
|
end
|
|
|
|
function CheatAccelerationView:DestroySuccess( )
|
|
self.input = false
|
|
Runner:getInstance():RemoveLateRunObj(self)
|
|
end
|
|
|
|
function CheatAccelerationView:LateUpdate( now_time, elapse_time )
|
|
local x = self.input.acceleration.x
|
|
local y = self.input.acceleration.y
|
|
|
|
local offset_x, offset_y = Mathf.Round(x*100) , Mathf.Round(y*100)
|
|
self.pos.text = " x = "..x.."\n y = "..y.." \n offset_x = "..offset_x.."\n offset_y = "..offset_y
|
|
SetLocalPosition(self.win_bg, offset_x, offset_y, 0)
|
|
end
|