Go to most recent revision |
Compare with Previous |
Blame |
View Log
Marquee = class(Turbine.UI.Control);
function Marquee:Constructor()
self.antsOffset = 0;
self.maxAntsOffset = 7;
self.antsMoveDelay = 0.1; -- 0.1-second delay = 10 updates per second
Turbine.UI.Control.Constructor(self);
self.leftBorder = Turbine.UI.Control();
self.leftBorder:SetParent(self);
self.leftBorder:SetBackground(ThurallorFilePath .. "/UI/Marquee/ants_vertical.tga");
self.topBorder = Turbine.UI.Control();
self.topBorder:SetParent(self);
self.topBorder:SetBackground(ThurallorFilePath .. "/UI/Marquee/ants_horizontal.tga");
self.rightBorder = Turbine.UI.Control();
self.rightBorder:SetParent(self);
self.rightBorder:SetBackground(ThurallorFilePath .. "/UI/Marquee/ants_vertical.tga");
self.bottomBorder = Turbine.UI.Control();
self.bottomBorder:SetParent(self);
self.bottomBorder:SetBackground(ThurallorFilePath .. "/UI/Marquee/ants_horizontal.tga");
self.lastAntsMoveTime = Turbine.Engine.GetGameTime();
end
function Marquee:Update()
-- Make sure enough time has elapsed since the ants moved last.
local currentTime = Turbine.Engine.GetGameTime();
if (currentTime - self.lastAntsMoveTime < self.antsMoveDelay) then
return;
end
self.lastAntsMoveTime = currentTime;
-- Move the ants by one pixel.
self.antsOffset = self.antsOffset + 1;
if (self.antsOffset > self.maxAntsOffset) then
self.antsOffset = 0;
end
-- Move ants to new position.
self.leftBorder:SetTop(self.antsOffset - self.maxAntsOffset);
self.topBorder:SetLeft(-self.antsOffset);
self.rightBorder:SetTop(-self.antsOffset);
self.bottomBorder:SetLeft(self.antsOffset - self.maxAntsOffset);
end
function Marquee:SetSize(width, height)
self:SetWidth(width);
self:SetHeight(height);
end
function Marquee:SetWidth(width)
Turbine.UI.Control.SetWidth(self, width);
self.topBorder:SetSize(width + self.maxAntsOffset, 1);
self.bottomBorder:SetSize(width + self.maxAntsOffset, 1);
self.rightBorder:SetLeft(width - 1);
end
function Marquee:SetHeight(height)
Turbine.UI.Control.SetHeight(self, height);
self.leftBorder:SetSize(1, height + self.maxAntsOffset);
self.rightBorder:SetSize(1, height + self.maxAntsOffset);
self.bottomBorder:SetTop(height - 1);
end
function Marquee:SetParent(parent)
if (parent) then
self:SetWantsUpdates(true);
else
self:SetWantsUpdates(false);
end
Turbine.UI.Control.SetParent(self, parent);
end
Go to most recent revision |
Compare with Previous |
Blame
All times are GMT -5. The time now is 03:25 AM.