class 'start_video2' (Script)

function start_video2:__init() super()

self.arData={}
self.countDataElement=1
self.real_time=0
self.one_show=true
self.one_pause=true
end

function start_video2:on_attach()
  local scene           = self:scene()
  self.skip             =scene:object('scip')
  self.change_scene     =scene:object('change_scene')
  self.startVideo       =scene:object('start')
  self.arrText={scene:object('text1'),scene:object('text2'),scene:object('text3'),scene:object('text4'),
                scene:object('text5'),scene:object('text6'),scene:object('text7'),scene:object('text8') }
  self.arData={{text=self.arrText[1],start_time=0,start_pause=3.2,current_time=12,time_pause=4 },
               {text=self.arrText[2],start_time=8,start_pause=2.7,current_time=12,time_pause=4 },
               {text=self.arrText[3],start_time=16,start_pause=4,current_time=7,time_pause=0 },
               {text=self.arrText[4],start_time=20,start_pause=0,current_time=2,time_pause=0 },
               {text=self.arrText[5],start_time=24,start_pause=1.8,current_time=4,time_pause=0 },
               {text=self.arrText[6],start_time=28,start_pause=1.9,current_time=6,time_pause=0 },
               {text=self.arrText[7],start_time=32,start_pause=3.1,current_time=10,time_pause=0 },
               {text=self.arrText[8],start_time=36,start_pause=2.9,current_time=7,time_pause=0 } }

end

function start_video2:on_lb_down()
  local scene           = self:scene()
  local selection =scene:overed_object()
  if selection then
    if self.skip :name()==selection:name() then
      if self.countDataElement>7 then
        self:scene():execute_action('end_video')
      end
      self.arData[self.countDataElement].text:hide(0)
      self.startVideo:pause_animation(false)
      self.startVideo:set_animation_time(self:changr_animation(self.countDataElement))

      self.countDataElement=self.countDataElement+1
      self.one_show=true
      self.one_pause=true
       self.real_time=0
    end
    if self.change_scene:name()==selection:name() then
      self:scene():execute_action('end_video')
    end
  end
end

function start_video2:changr_animation(number)
 local curr=0
 local summ =0
  for i=1,number do
   if self.arData[i].start_pause~=0 then
     curr=self.arData[i].start_pause
   else
     curr=self.arData[i].current_time
   end
     summ=summ+curr
  end
  return summ
end

function start_video2:on_update(dt)
  self.real_time=self.real_time+dt


  if self.arData[self.countDataElement]~=nil then
    if self.real_time<self.arData[self.countDataElement].current_time then

       if self.real_time>self.arData[self.countDataElement].start_pause and self.arData[self.countDataElement].start_pause~=0 then
         if self.one_pause then
           self.one_pause=false
           self.startVideo:pause_animation(true)
         end
       end

       if self.one_show then
         self.arData[self.countDataElement].text:show()
         self.one_show=false
       end
    else

      if self.arData[self.countDataElement].text:name()~='' then

        self.arData[self.countDataElement].text:hide(0)
       self.startVideo:pause_animation(false)
      end

      self.one_show=true
      self.one_pause=true

      self.real_time=0
      self.countDataElement= self.countDataElement+1

    end
     if self.countDataElement>8 then
        self:scene():execute_action('end_video')
      end
  end
end