alpha range warning

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?

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.

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

Tom,
Sean has my app build due to the other issue. It happens in there. When the character appears and disappears.

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:
transition.to(instructions, {time=2000, alpha = 0} )
or
gameOverImage.alpha = 0
or

1
2
enemyList[enemyID].isVisible = false
enemyList[enemyID].alpha = 1

Was going to say its usually with transitions...

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.

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.

-Tom

Hey Tom

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

Matthew,

I know about the warnings if you manually set the alpha value out of range but was curious if it was happening if you manually set it to 0 or 1.

Thanks,
-Tom

Manually setting 0 or 1 directly doesn't generate the warning message

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?

-Tom

Also tried and cant now get the message.

If I see it again will post the code

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 -_-

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.

Its just C rounding errors, language based and Corona takes care of it.

The warning is annoying but nothing to worry about.

If this warning is fired on the device too, then it will have an effect on teh framerate, the more warnings, the more messages.

I find that the warning messages show up if I use an easing function that goes in and out of the normal bounds.

See this for the easing that go out of the bounds, and can make alpha be > 1 and < 0.

http://developer.anscamobile.com/code/more-easing

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:

1
2
3
4
5
6
7
8
9
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...

I don't use timer.performWithDelay and still get the messages once in a while.

I've found this happens when you set the alpha and then perform a transition right after it... eg::

object.alpha = 0.6
transition.to (object, {time=1000, alpha = 1})

You can usually avoid it by adding minimal delay...

object.alpha = 0.6
transition.to (object, {delay=1, time=999, alpha = 1})

I've made a habit of doing this for all alpha transitions. It seems like the initial alpha setting statement 'object.alpha = 0.6' doesn't take effect right away. The transition starts and sets its steps with the original value (for example 0), and some time in the transition the object.alpha = 0.6 takes effect. Once all steps in the transition have been applied the end alpha value ends up > 1

So the transition calculates on alpha 0 -> 1, but before the transition is complete the alpha gets set to 0.6 which potenitally leaves the alpha anywhere up to 1.6. Because the warning generates at the first 'step' above 1, it stops at 1 + one transition step

@Tom, didn't this ever get fixed? I noticed it just now on an alpha transition when using a performWithDelay (as you describe above).

@thegwill, I'm sorry to say it haven't been fixed yet. It's still on our bug list.

Is there a way to disable WARNING output? TextCandy seems to be outputting this clamping alpha warning, and for the time being it would be nice to disable this.

thought it was fixed on daily build...

grrrrrrrrrrrrrrr

c.

The Alpha warning bug was generated when changing the alpha property of an object in a transition.to call. This was resolved in build 484. I just verified that Daily Build 521 does not have the bug.

The Alpha warning will still come up if the alpha property is set to a value less than 0.0 or greater than 1.0.

If there is another test case (a few lines of code, please) that causes this warning, please file a bug report.

views:2073 update:2011/9/30 9:15:39
corona forums © 2003-2011