I found the arithmetic calculation on diaplayObject.alpha field is very strange. Look the following very simple code
local img = display.newImage(‘moon.png’)
local da = -1/600
local a = 1
for k = 1, 600 do
img.alpha = img.alpha + da
a = a + da
print(string.format(’%d,a:%.6f, alpha:%.6f’, k, a, img.alpha))
end
As a matter of course, I thought that the ‘a’ and ‘img.alpha’ must be the same at each steps.
But, the result is as follows:
…
…
14:29:40.092 k=249, a:0.585000, alpha:0.023529
14:29:40.092 k=250, a:0.583333, alpha:0.019608
14:29:40.092 k=251, a:0.581667, alpha:0.015686
14:29:40.092 k=252, a:0.580000, alpha:0.011765
14:29:40.092 k=253, a:0.578333, alpha:0.007843
14:29:40.092 k=254, a:0.576667, alpha:0.003922
14:29:40.092 k=255, a:0.575000, alpha:0.000000
14:29:40.092 k=256, a:0.573333, alpha:0.000000
14:29:40.092 k=257, a:0.571667, alpha:0.000000
14:29:40.092 k=258, a:0.570000, alpha:0.000000
14:29:40.092 k=259, a:0.568333, alpha:0.000000
…
…
The variable ‘a’ becomes zero at k=600. However, img.alpha becomes 0 at k=255.
There is a huge gap is there.
The alpha property of display object is not an ordinary Lua number ?
Am I missing something ?