How would i round off to 2 decimal places?
my sprite.timeScale is not working, and im assuming this is the reason
Label: corona android iphone ipad building error inmobi problem display screen View image tableView failed object physics touch button game lua config event listener |
Rounding off
roundedNumber = math.floor(sourceNumber * 100 + 0.5) / 100
or
roundedNumber = math.round(sourceNumber * 100)/100
edited because I forgot there was a .round() function. The multiply by 100 then divide by 100 shifts your decimal place by 2 spots temporarily since .round, .floor etc make intergers, then the divide by 100 puts it back to 2 decimal places.
it doesnt help having it if its not documented anywhere....
Thank you anyway, it didnt help though, the timeScale function itself is very broken
Hello wiredknight,
The timeScale value is already rounded at the 2 decimal place internally when calculating animation speed, even though the property value may not reveal it. Meaning, if you set timeScale to 0.009, then internally it will be calculated as 0.01 but in Lua it will remain as 0.009. This was the intent so that developers can easily increment the timeScale in Lua in a nice linear fashion without Corona unexpectedly rounding it up/down.
So, what problems are you having with the sprite's timeScale property?
Based on my testing, it seems to be working perfectly as documented.
Hi Joshua
I solved my problem another way, however i really could not get the timescale thing to work, and i was not the only user, i seen others complain.
Maybe its nitty gritty things that were not specified, like for example it HAS to be before you play, or after.... etc
But what i ended up have happening is that it made no effect, or it would work up until 2.0, and down as far as need be
Hello wiredknight,
You can indeed change the timeScale property while it is playing. Trust me, it works. Also, if you're trying to set timeScale to a very high value, then you're going to need to bump up the frame rate of your app to 60 FPS or else it will be capped at the default 30 FPS.
So far, you haven't told me what the problem is. What isn't working for you? And can you provide some example code?
Currently, there are no bugs reported for the timeScale property. So we don't know what complaints you are referring to. If you think there is a bug then please report it via the "Report a Bug" link at the top of this page. Thanks!
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
Publishing/Subscriptions
Assigning myName to an element in an array causes an error?
Built for XCode Simulator Fails to Launch
Dynamic Content Scaling and Dynamic Image Resolution
How to avoid images appear when the touch is over a image and not over the background?
How to open Lime?
Scrolling Background
Restart a scene?
Corona says "Missing Component: pbxcp" -huh??