OnUpdate()-rate and OnRender()-rate are different
Monkey Targets Forums/Android/OnUpdate()-rate and OnRender()-rate are different
| ||
I have a problem with my android-app. When i use SetUpdateRate(), andoid don't do like i want. On windows, the OnUpdate() and OnRender() method will be call up like i set the SetUpdateRate(). On android, the rates are different. Two examples on android: SetUpdateRate(60) -> Real OnUpdate() rate: 60 -> Real OnRender() rate: 26-29 (never goes more then 30) SetUpdateRate(25) -> Real OnUpdate() rate: 25 -> Real OnRender() rate: 23-25 I wrote a very simple test app where you can see a moving circle. The circle is lagging, because in OnUpdate() the position will be updated, but not always drawn in OnRender(). Strict Import mojo Class TestGame Extends App Field x:Int Field y:Int = 200 Method OnCreate:Int() SetUpdateRate(60) Return 0 End Method OnUpdate:Int() x += 5 Return 0 End Method OnRender:Int() Cls(200,200,200) DrawCircle(x,y,20) Return 0 End End Function Main:Int() New TestGame Return 0 End Hope you can help me... Thanks! |
| ||
It may be that your device is limited to a refresh rate of 30Hz? |
| ||
Thank you for answer! Yes, it seems so, but where i can check this?. Is it normal, that some devices limited the refresh rate? Do that many devices? My test device is a Samsung Galaxy Note N7000 with Android 4.1.2. How i can react to this problem? I simply want to move something smooth over the display. Is there a way to adjust the OnRender() refresh rate in monkey? Should I ignore this, because there are just a few devices with this reaction? |
| ||
Use a delta timing solution to move your sprites. James Boyd's delta timing code (used within Diddy): Example: |
| ||
Thank you therevills! But your example is on my device jerking, too. But maybe its still a good technique. I seems there is no satisfactory solution. I'm very interessting in how many devices reacts like mine! In higher frame rates the difference between OnRender and OnUpdate rates should be negligible. But an OnUpdate rate of 60 and an OnRender rate of 27-29 is annoying. Maybe someone can add here some more thoughts... |
| ||
Are you running latest monkey? |
| ||
Almost. I use v77f. |
| ||
Are you compiling in debug mode? If so try release mode. On my old LG phone, debug mode runs at <20fps when in release mode I get >40fps. |
| ||
I have tried release mode. It's the same frame rate as debug mode. :-( |
| ||
You could move your actual updating code from OnUpdate() to OnRender(). At least then there can be no disagreement, |
| ||
Uh, very interesting approach, Gerry Quiunn! I will try it soon! |
| ||
If you set the update rate to a value, mojo will make sure that your OnUpdate method is called that many times. To achieve this, it will skip some OnRender calls so it has enough time update at the give rate. If you want to make sure that OnRender is called as many times like OnUpdate is, update Monkey to the latest version and use SetUpdateRate(0). This will make sure that you app called OnUpdate and OnRender as much as possible. But always in sync. |
| ||
But always in sync. That's it! Now it works fine! Thank to all, especially to MikeHart and therevills! Yeah! |