tdm_ui.lua

--팀데스매치 예제(ui)

-- 서버에서 동기화 될 점수 변수들
ScoreCT = UI.SyncValue.Create("ScoreCT")
ScoreTR = UI.SyncValue.Create("ScoreTR")
MaxKill = UI.SyncValue.Create("MaxKill")

-- 점수판 생성
screen = UI.ScreenSize()
center = {x = screen.width / 2, y = screen.height / 2}

scoreBG = UI.Box.Create()
scoreBG:Set({x = center.x - 100, y = 0, width = 200, height = 50, r = 255, g = 255, b = 255, a = 150})

goalBG = UI.Box.Create()
goalBG:Set({x = center.x - 50, y = 0, width = 100, height = 50, r = 40, g = 40, b = 40, a = 150})

goalLabel = UI.Text.Create()
goalLabel:Set({text='00', font='large', align='center', x = center.x - 50, y = 10, width = 100, height = 50, r = 80, g = 255, b = 80})

ctLabel = UI.Text.Create()
ctLabel:Set({text='00', font='medium', align='left', x = center.x - 95, y = 20, width = 50, height = 50, r = 80, g = 80, b = 255})

trLabel = UI.Text.Create()
trLabel:Set({text='00', font='medium', align='right', x = center.x + 45, y = 20, width = 50, height = 50, r = 255, g = 80, b = 80})

-- 변수 동기화 될 때마다 스코어보드 업데이트 해준다
function ScoreCT:OnSync()
    local str = string.format("%02d", self.value)
    ctLabel:Set({text = str})
end

function ScoreTR:OnSync()
    local str = string.format("%02d", self.value)
    trLabel:Set({text = str})
end

function MaxKill:OnSync()
    local str = string.format("%02d", self.value)
    goalLabel:Set({text = str})
end
generated by LDoc 1.4.6 Last updated 2019-11-08 21:27:50