I see this message a lot for a project I’m working on:
WARNING: Attempt to set object.alpha to -0.000500125 which is outside valid range. It will be clamped to the range [0,1]
The code I’m using only referes to object.alpha = 1 or object.alpha = 0 so I’m not sure where the fraction is coming from. Any ideas? [import]uid: 1560 topic_id: 1885 reply_id: 301885[/import]
Its an old problem that I mentioned and discussed via email with ANSCA months ago. They say its not a problem, at least for them.
Personally I find it anoying as it fills the console window. [import]uid: 5712 topic_id: 1885 reply_id: 5560[/import]
I get the same with different values. Sometimes it happens sometimes it doesn’t. Doesn’t seem to mess anything else up. I hope it doesn’t affect performance too much.
Can you provide an example where you are getting the waring using the Beta 8 build?
Setting obj.alpha = 0 or obj.alpha = 1 doesn’t generate any warnings for me. If you are using math to calculate the alpha values you may be getting rounding errors that is >1 or <0.
Tom,
Sean has my app build due to the other issue. It happens in there. When the character appears and disappears. [import]uid: 8192 topic_id: 1885 reply_id: 5732[/import]
I’m not sure where it’s happening in my code as I have several alpha calls but I am seeing this in the current game edition beta:
WARNING: Attempt to set object.alpha to 1.001 which is outside valid range. It will be clamped to the range [0,1]
It’s either:
[lua]transition.to(instructions, {time=2000, alpha = 0} )[/lua]
or
[lua]gameOverImage.alpha = 0[/lua]
or
[lua]enemyList[enemyID].isVisible = false
enemyList[enemyID].alpha = 1[/lua] [import]uid: 1560 topic_id: 1885 reply_id: 5737[/import]
I believe its rounding errors in C that produce the extra 0.001 and there is not much that can be done. The error is unnecessary I believe as Corona will automatically reset the value to 1. [import]uid: 5354 topic_id: 1885 reply_id: 5745[/import]
Are all the warning messages coming from transition.to statements? I can see where math rounding errors could produce the warning messages. If that’s the source of all the warnings I think the values should be capped internally without the warning message.
I discussed this with Carlos / Eric or someone months back. I believe you can generate the warning error if you manually set alpha to out of the range ( used to be able to, not tried lately )
But yeah its usually the transitions causing the warning message. I think they are capped at 0 and 1 but the message appears to inform you of the capping. Its not an issues as such, I dont mind it, but yeah it can fill up a terminal window if you have lots of transitions firing at once.
Rounding errors are nothing new though and not a direct Corona bug so I left it there.
math.floor or checking newAlpha > 1 works as well for manual functions [import]uid: 5354 topic_id: 1885 reply_id: 5778[/import]
I was playing with some transitions and couldn’t generate the alpha warning message. I tried going from alpha 0 to 1 and 1 to 0 with some odd times (e.g. 333 msec). Anyone have a case that shows the message?
I have to agree that this warning message is quite annyoing since it fills the entire console window -is there a way to disable it? I don’t want to slow down my code with unneccessary if…then statements just to avoid this warning
EDIT: *sigh* same with xScale and yScale -_- [import]uid: 9644 topic_id: 1885 reply_id: 8131[/import]
It is definate the transition.to function. The funny thing is that it isn’t cosistantly reproduceable. Sometimes it shows up, sometimes not. At first I thought it is the image but then it doesn’t happen all the time. Weird bug. [import]uid: 5712 topic_id: 1885 reply_id: 8140[/import]
If this warning is fired on the device too, then it will have an effect on teh framerate, the more warnings, the more messages. [import]uid: 5712 topic_id: 1885 reply_id: 8148[/import]
The problem can be reproduced if you change the alpha property in a transition.to that is called by a performWithDelay. Doing the transition.to without the performWithDelay does not cause the warning. It’s on our to-do list to be fixed.
Here is the code that shows the problem:
local function test()
t = display.newText( "Testing Alpha in Transition.to", 0, 0, nil, 20 )
t.alpha = 1
t:setTextColor( 255, 255, 255 )
transition.to( t, {time = 700, alpha = 0} )
end
timer.performWithDelay( 100, test )
Thanks Tom,
Do you think this will be fixed in the next release? It’s very annoying when trying to debug.
As a side note, perhaps a voting mechanism in the bug tracker that we can all participate in would help Ansca work on bugs that are more important to the community. Just a thought… [import]uid: 8194 topic_id: 1885 reply_id: 8878[/import]