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? [import]uid: 12529 topic_id: 5843 reply_id: 305843[/import]
because “width=0” doesn’t make any sense? [import]uid: 6645 topic_id: 5843 reply_id: 20050[/import]
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:
[lua]function setWidth( bar, value)
bar.isVisible = value > 0;
if (value > 0) then bar.width = value; end;
obj:setReferencePoint( display.TopLeftReferencePoint);
obj.x = 0;
end[/lua]
This is stuff I expect a decent API to handle itself. The more I’m doing in Lua vs the API doing in C, the slower my app will be. I find myself spending more time writing my own API on top of the Corona API than I am working on my actual application logic.
Even if “width=0” “doesn’t make sense”, how does it “make sense” to have it cause the rectangle to become full width? I could understand if it just made the rectangle 1-pixel wide. But not the full width. [import]uid: 12529 topic_id: 5843 reply_id: 20191[/import]
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. [import]uid: 12529 topic_id: 5843 reply_id: 20194[/import]
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. [import]uid: 6645 topic_id: 5843 reply_id: 20197[/import]
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… [import]uid: 61899 topic_id: 5843 reply_id: 37772[/import]