I have a mathematical function that changes the rotation of an object. Unfortunately, this function sometimes produces indefinite numbers: the console outputs "-1.#IND". How can you check for an indefinite number? Also I have been trying to use a ternary operator according to Lua's wiki website, yet I can't get it to work.
It is a simple as:
object.rotation = ( angle > 0 ) ? angle : object.rotation
Yet I get the error "unexpected symbol near '?'".
So how do I check for -1.#IND and use it in a ternary operator?
Label: corona android iphone ipad building error inmobi problem display screen View image tableView failed object physics touch button game lua config event listener |
How to deal with indefinite numbers?
There is no ternary operator in Lua. There is an ugly hack with the use of "and" and "or" but it is complex and there are some issues so my advice: stay away from it.
As for your other problem, just check that your angle is between the limits:
1 2 3 | if angle >= 0 and angle < 360 then object.rotation = angle end |
@ir8primate,
your handle sounds like a cool new game title after Angry Birds. Let us have evolution and move ahead.
OK, back to your question...
you can use the ternary operator as
object.rotation = angle>0 and angle or object.rotation
hope that helps,
cheers,
?:)
views:1694 update:2011/10/5 21:23:48
热门文章
GameCenter LeaderBoards and Achievements Enabled Through OpenFeint
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
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
相关文章
ipad compatibility?
GlowTunes reinvents the Christmas tree for iPhone and iPad!
PolyLine Width
Text Field Input?
displayGroup gets insane X value 2147483648 for no reason!
Asteroids style wrapping with a dynamic character
Who's in the UK?
Building for Android
How to detect collision with no physics ?
Greebly finally launched for iOS and Android
GlowTunes reinvents the Christmas tree for iPhone and iPad!
PolyLine Width
Text Field Input?
displayGroup gets insane X value 2147483648 for no reason!
Asteroids style wrapping with a dynamic character
Who's in the UK?
Building for Android
How to detect collision with no physics ?
Greebly finally launched for iOS and Android
corona forums © 2003-2011