C2G
March 4, 2024, 5:55pm
1
Hello!
The display.colorSample() function does not work correctly.
More details:
JSON = require('json')
CX, CY = display.contentCenterX, display.contentCenterY
local rect = display.newRect(CX, CY, 100, 100)
timer.performWithDelay(1000, function()
display.colorSample(CX, CY,
function(event)
local r, g, b = event.r, event.g, event.b
r, g, b = tonumber(r)*255, tonumber(g)*255, tonumber(b)*255
print(r, g, b, JSON.encode(event))
end)
end, 1)
Output: 0 0 0 {“y”:512,“x”:384,“name”:“colorSample”,“r”:0,“a”:0,“g”:0,“b”:0}
But I assumed that there would be 1 1 1 {“y”:512,“x”:384,“name”:“colorSample”,“r”:1,“a”:1,“g”:1"b":1}, since the rect object is still white color
Siu
March 4, 2024, 11:24pm
2
Your code, in isolation as posted, is working for me as expected.
Have you test it on an empty project?
@C2G
Your code is working for me as expected.
I tested with Solar2D Simulator 2024.3704
C2G
March 5, 2024, 12:43pm
4
No, project not empty. But I don’t understand what this could be related to…
C2G
March 5, 2024, 12:45pm
5
I have already tested the code in an empty project, but the problem remains the same
C2G
March 5, 2024, 12:58pm
6
I have updated Solar 2D to the latest version and everything works, but when building in .apk it gives an error. Well, that’s a completely different story…
system
Closed
September 1, 2024, 12:59pm
7
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.