1platformspawner = class:new() 2 3function platformspawner:init(x, y, direction, size) 4 self.x = x 5 self.y = y 6 self.direction = direction 7 self.timer = 0 8 9 self.size = size 10end 11 12function platformspawner:update(dt) 13 self.timer = self.timer + dt 14 if self.timer > platformspawndelay then 15 if self.direction == "up" then 16 table.insert(objects["platform"], platform:new(self.x, self.y+1, "justup", self.size)) 17 else 18 table.insert(objects["platform"], platform:new(self.x, self.y-0.5, "justdown", self.size)) 19 end 20 21 self.timer = self.timer - platformspawndelay 22 end 23 24 if self.x < xscroll - .5 then 25 return true 26 end 27end