require("game.common.BarrageView") require("game.common.BarrageItem") BarrageManager = BarrageManager or BaseClass(BaseController) function BarrageManager:__init() BarrageManager.Instance = self self.max_count_limit = 20 self.width = ScreenWidth self.height = ScreenHeight - 300 end function BarrageManager:getInstance() if not BarrageManager.Instance then BarrageManager.Instance = BarrageManager.New() end return BarrageManager.Instance end --[[ data = { str = "弹幕内容", fontSize = 文本字号, duration = 停留屏幕时间, } ]] function BarrageManager:AppendItem(data) if not self.barrageView then self.barrageView = BarrageView.New() end if not self.barrageView:HasOpen() then self.barrageView:Open() end self.barrageView:AppendNewItem(data) end function BarrageManager:GetRandomFirePosY() local curTime = os.time() if self.last_random_time ~= curTime then self.last_random_time = curTime --math.randomseed(curTime) math.random(-self.height/2, self.height/2) end return math.random(-self.height/2, self.height/2) end