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?
Label: corona android iphone ipad building error inmobi problem display screen View image tableView failed object physics touch button game lua config event listener |
Setting a Width to zero
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...
send message and call to a person
Forum: Report Spam + PM
[INSTALL_PARSE_FAILED_NO_CERTIFICATES]
[SOLVED] Director ERROR: Failed to execute new( params ) function on 'screen1'
Too many (200) local variables
Corona SVG Level Builder released. Drag and drop physics level editor with Inkscape and SVG.
Small bug in Collectible Items example
Pivot Joints and apparent elasticity
Can't make removeSelf() delayed
Any Irish programmers here ?
onComplete - can I pass variables / arguments to the function?
Table syntax
Corona Game Jam -- Win a Free Corona License This Weekend :)
Mapview example
new subscription support
Where is the multitasking announcement?
PucksAway! - AirHockey meets puzzle!
Director needs to call cancelTimer if an effect is already in progress (patch)