class 'DropDrop3' (Script)

function DropDrop3:__init() super()
end

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

	 self.start_x =1030
	 self.start_y =200
	 self.finish_x =1040
	 self.finish_y =377
	 self.time_animation = 1.2
	 self.count = 0

	self.object = scene:object('drop3')
	self.point_start=Position(self.start_x,self.start_y)
	self.point_finish = Position(self.finish_x,self.finish_y)

	self.chench_x = math.abs(self.start_x-self.finish_x)
	self.chench_y = math.abs(self.start_y-self.finish_y)
	self.cooficient = self.chench_x/self.chench_y

	self.current_x =self.start_x
	self.current_y =self.start_y

	if self.start_x-self.finish_x>0 then
		self.direction_x = -1
	else
		self.direction_x = 1
	end

	if self.start_y-self.finish_y>0 then
		self.direction_y = -1
	else
		self.direction_y = 1
	end


end

function DropDrop3:on_update(dt)
local number_itiration = self.time_animation/dt

	if self.count<number_itiration then
		self.current_x=self.current_x+self.direction_x*self.chench_x/number_itiration
        self.current_y=self.current_y+self.direction_y*self.chench_y/number_itiration
        self.object:set_position(Position(self.current_x,self.current_y), true)
        self.count=self.count+1
    else
    --print('ok')
        self.count=0
        self.current_x =self.start_x
		self.current_y =self.start_y
		--self:scene():execute_action('st')
	end

end