class 'p04_l01_m01_move' (Script)

function p04_l01_m01_move:__init()super()
 self.object={}
 self.tweener={}
 self.shiftY=900
self.speed=200

 self.load=false

 self.position={}
end

function p04_l01_m01_move:on_attach()
  local scene=self:scene()

 self.object[1]={}
 self.tweener[1]={}
 for l=1,3 do
   self.object[1][l]=scene:object('z01_button_up0'..l)
   self.tweener[1][l]=tweener()
 end


 self.object[2]={}
 self.tweener[2]={}
 for s=1,3 do
  self.object[2][s]=scene:object('z01_button_down0'..s)
  self.tweener[2][s]=tweener()
 end

 self.object[3]={}
 self.tweener[3]={}
 for j=1,3 do
   for k=1,10 do
     self.object[3][(j-1)*10+k]=scene:object('z01_number0'..(k-1)..'-'..j)
     self.tweener[3][(j-1)*10+k]=tweener()
  end
 end

  self.object[4]={}
  self.object[4][1]=scene:object('z01_button_onup01')
  self.object[4][2]=scene:object('z01_button_ondown01')
  self.object[4][3]=scene:object('z01_button_mouseclick_up')
  self.object[4][4]=scene:object('z01_button_mouseclick_down')
  self.object[4][5]=scene:object('z01_win')
  self.object[4][6]=scene:object('z01_background01')
  self.object[4][7]=scene:object('z01_effect')
  self.object[4][8]=scene:object('z01_effect02')
  self.object[4][9]=scene:object('z01_background05')
  self.tweener[4]={}
  for t=1,#self.object[4] do
      --fx_win
   self.tweener[4][t]=tweener()
  end


 if self.load then
   for a=1,#self.object do
   for b=1,#self.object[a] do
    self.object[a][b]:set_position(Position(self.position[a][b]:x(),self.position[a][b]:y()+self.shiftY),true)
   end
  end
 else
  for a=1,#self.object do
   self.position[a]={}
   for b=1,#self.object[a] do
    self.position[a][b]=self.object[a][b]:position()
   end
  end
  self:moveS()
 end
 self.load=false
end

function p04_l01_m01_move:on_update(dt)
 for i=1,#self.tweener do
  for j=1,#self.tweener[i] do
     self.tweener[i][j]:update(dt)
  end
 end
end

function p04_l01_m01_move:moveS()
 for i=1,#self.tweener do
  for j=1,#self.tweener[i] do
     self.tweener[i][j]:getsParmsMove(self.object[i][j],self.speed,self.object[i][j]:position(),Position(self.object[i][j]:position():x(),self.object[i][j]:position():y()+self.shiftY))
  end
 end
end

function p04_l01_m01_move:save(os)
  os:save(0) -- version
  os:save(true)
  os:save(#self.object)
  for a=1,#self.object do
   os:save(#self.object[a])
   for b=1,#self.object[a] do
    os:save(self.position[a][b])
   end
  end
end

function p04_l01_m01_move:load(is)
  local ver = is:load()
  self.load = is:load()
  local size = is:load()
  for a=1,size do
   local size2=is:load()
   self.position[a]={}
   for b=1,size2 do
    self.position[a][b]=is:load()
   end
  end
end