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:1697 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
相关文章
How to make train on railroad tracks?
HELP - PONG PADDLE - Follow Ball
iOS Development Question
Touch events bleed through
Call web service with parameters
Think Radical
How do I save/add sprites into a table ( save game settings)?
Does purchased SDK allow you to run on multiple computers?
"Dramatic Music App" = new & noteworthy in iPhone and iPad store, US!
How to make a complex body with circles?
HELP - PONG PADDLE - Follow Ball
iOS Development Question
Touch events bleed through
Call web service with parameters
Think Radical
How do I save/add sprites into a table ( save game settings)?
Does purchased SDK allow you to run on multiple computers?
"Dramatic Music App" = new & noteworthy in iPhone and iPad store, US!
How to make a complex body with circles?
corona forums © 2003-2011