| View previous topic :: View next topic |
| Author |
Message |
Razi Expert Cheater
Reputation: 1
Joined: 17 Jan 2018 Posts: 205
|
Posted: Thu May 28, 2020 11:28 am Post subject: How to make a blinking effect with timer? |
|
|
How to change the font color of the label with one timer? To make a blinking effect between gray and white colors. The following code only changes to gray color.
| Code: |
if UDF1.CELabel1.Font.Color == 0xFFFFFF then
UDF1.CELabel1.Font.Color = 0x716D6C --gray
elseif UDF1.CELabel1.Font.Color == 0x716D6C then
UDF1.CELabel1.Font.Color = 0xFFFFFF --white
end |
Where is the mistake?
Last edited by Razi on Thu May 28, 2020 4:26 pm; edited 1 time in total |
|
| Back to top |
|
 |
AylinCE Grandmaster Cheater Supreme
Reputation: 37
Joined: 16 Feb 2017 Posts: 1532
|
Posted: Thu May 28, 2020 12:23 pm Post subject: |
|
|
| Code: | UDF1.CETimer1.Enabled=false
UDF1.CETimer1.Interval=300
UDF1.CETimer1.OnTimer=function()
if UDF1.CELabel1.Font.Color == 0x716D6C then --grey
UDF1.CELabel1.Font.Color = 0xFFFFFF --white
else
UDF1.CELabel1.Font.Color = 0x716D6C --grey
end
end
UDF1.CELabel1.OnClick=function()
if UDF1.CETimer1.Enabled==false then
UDF1.CETimer1.Enabled=true
else
UDF1.CETimer1.Enabled=false
end
end |
_________________
|
|
| Back to top |
|
 |
Razi Expert Cheater
Reputation: 1
Joined: 17 Jan 2018 Posts: 205
|
Posted: Thu May 28, 2020 4:23 pm Post subject: |
|
|
Thanks for the answer. (Found mistake in the previous code.)
I have 3 labels with character names. When the character is selected, the label should blink in gray and white. The names of other characters must be white. When the character's hp is 0, then the label should be red.
Created the following code and it works, but maybe there is a better solution for this?
| Code: | namebattle = {}
for x = 0, 2 do
namebattle[x] = UDF1["CELabel"..x+591]
end
timer = createTimer(nil,false)
timer.Interval = 1000
timer.OnTimer = function()
local selectedcharacter = readBytes(basaddr + 0x633A7C) -- value can be only 0,1,2
for b = 0, 2 do
local offs = basaddr + 0x5E9748 + b*0x440
local hp = readInteger(offs)
if hp == 0 then
namebattle[b].Font.Color = 0x0209B7 --red
else
if selectedcharacter < 3 and b ~= selectedcharacter then
namebattle[b].Font.Color = 0xFFFFFF --white
end
end
end
if selectedcharacter < 3 then
if namebattle[selectedcharacter].Font.Color == 0xFFFFFF then
namebattle[selectedcharacter].Font.Color = 0x716D6C --gray
elseif namebattle[selectedcharacter].Font.Color == 0x716D6C then
namebattle[selectedcharacter].Font.Color = 0xFFFFFF --white
end
end
end
timer.Enabled = true |
|
|
| Back to top |
|
 |
|