--@input float curTime = 0.0{"widget":"slider","min":0,"max":1} local exports = exports or {} local SeekModeScript = SeekModeScript or {} SeekModeScript.__index = SeekModeScript function SeekModeScript.new(construct, ...) local self = setmetatable({}, SeekModeScript) if construct and SeekModeScript.constructor then SeekModeScript.constructor(self, ...) end self.startTime = 0.0 self.endTime = 3.0 self.curTime = 0.0 self.width = 0 self.height = 0 return self end function SeekModeScript:constructor() end function SeekModeScript:onUpdate(comp, detalTime) --ccc --local props = comp.entity:getComponent("ScriptComponent").properties --if props:has("curTime") then --self:seekToTime(comp, props:get("curTime")) --end --ccc self:seekToTime(comp, self.curTime - self.startTime) end function SeekModeScript:onStart(comp) self.EASpeed = 1.0 self.animSeqCom = comp.entity:getComponent("AnimSeqComponent") self.material = comp.entity:getComponent("Sprite2DRenderer").material end function SeekModeScript:seekToTime(comp, time) -- self.animSeqCom:seekToTime(time) local w = Amaz.BuiltinObject:getInputTextureWidth() local h = Amaz.BuiltinObject:getInputTextureHeight() local aspectRatio = w/h local trans_params1 = {1.0,0.5,0.78} --ccc,cccc(cccc,ccccccc) local trans_params2 = {1.2,0.27,0.31} --cccc local trans_params3 = {1.3,0.85,0.25} --cccc if aspectRatio>1.0 then -- ccc trans_params1 = {1.0,0.78,0.5} --ccc trans_params2 = {1.2,0.31-0.06,0.73+0.12} --cccc trans_params3 = {1.3,0.25-0.03,0.15+0.12} --cccc end if aspectRatio > 17/9 then self.animSeqCom:seek(6) self.material:setInt("maskIndex", 6) elseif aspectRatio > 14/9 then self.animSeqCom:seek(5) self.material:setInt("maskIndex", 5) elseif aspectRatio > 7/6 then self.animSeqCom:seek(2) self.material:setInt("maskIndex", 2) elseif aspectRatio > 6/7 then self.animSeqCom:seek(0) self.material:setInt("maskIndex", 0) elseif aspectRatio > 9/14 then self.animSeqCom:seek(1) self.material:setInt("maskIndex", 1) elseif aspectRatio > 9/17 then self.animSeqCom:seek(3) self.material:setInt("maskIndex", 3) elseif aspectRatio > 9/20 then self.animSeqCom:seek(4) self.material:setInt("maskIndex", 4) end self.material:setVec3("trans_params1", Amaz.Vector3f(trans_params1[1],trans_params1[2],1-trans_params1[3])) self.material:setVec3("trans_params2", Amaz.Vector3f(trans_params2[1],trans_params2[2],1-trans_params2[3])) self.material:setVec3("trans_params3", Amaz.Vector3f(trans_params3[1],trans_params3[2],1-trans_params3[3])) end exports.SeekModeScript = SeekModeScript return exports