Setting a Width to zero

Why is it that in Corona setting the width of a rectangle (or any other object) to zero causes it to fill the entire width instead of disappearing? In every other graphics API I have used, setting something to a width of zero properly causes it to disappear. Is this a bug in Corona or just another "weirdness" that I need to deal with?

because "width=0" doesn't make any sense?

It makes perfect sense. And it works in most every other graphics API that I've used for the past 20+ years.

I'll give you a simple example: a progress bar. Right now I've ended up with the following code just to set the width of a progress bar in Corona:

1
2
3
4
5
6
function setWidth( bar, value)
        bar.isVisible = value > 0;
        if (value > 0) then bar.width = value; end;
        obj:setReferencePoint( display.TopLeftReferencePoint);
        obj.x = 0;
end

And just a followup:

My intent with my many forum posts is to try and help Corona improve. Please try to take these posts in that spirit. I want to see Corona be successful as much as anyone. I really done want to use Objective C for iPhone programming.

But coming from the Android world, I am still finding Corona to be very lacking as an API in many ways. As a long-time developer I know that once an API is written, it becomes very hard to ever change it because of backwards compatibility issues. I'm hoping that Corona can still improve it's API and that it isn't too late for improvements. Otherwise somebody else will just come along and do it better.

i'm not sure you can set something to width=0 in either html or actionscript, so doesn't seem unusual to me.

but yes just add a feature request to make it auto-invisible.

I have exactly the same problem.

For those who ask why would with=0 be necessary, there is a very common and simple example, health bars!

An health bar is suppose to decrease till 0hp, and when at 0hp you shouldn't be seeing any "green" bar.

I noticed though that you can set the width to 0 if you set it at instantiation time, but not dynamically...

views:1623 update:2011/10/1 9:04:19
corona forums © 2003-2011