Loading Screen for mobile games
Monkey Forums/Monkey Programming/Loading Screen for mobile games
| ||
Hi all :) I know this has been discussed before, that it would be nice to have a nice way to add a loading screen in the OnCreate Method. From the monkey docs it says that The OnCreate method is called when mojo has been initialized and the application has been successfully created. At this point, applications can start loading resources such as images and sounds, and set the update rate using SetUpdateRate. So, i belive the only significant method to be called in the OnCreate is the SetUpdateRate? Other than that, i don't see some of the solutions proposed as bad ones. I'm doing one myself too. What do you all think? |
| ||
Does the OnLoading() method for the App class work? I haven't tried it yet. |
| ||
I've tried it with the IPad & IPhone simulator and it's not working for me. If you call the OnLoading() it works (in GLFW & Flash at least I've seen it work), but in my opinion, it's not a very useful method since you can Render something but you cannot make an animation to run while the OnCreate is executed. In other words, you have a static "splash-like" screen while you`re loading your stuff, because OnCreate is an atomic method. Something like this would be useful in the trans side(pseudocode): while(OnCreate()!=1){ OnLoading() } It would be responsibility of the user to return 1 when he knows he has finished all the loading stuff, and call OnLoading() each loop if it hasn't. I'm doing something like that in the OnUpdate & OnRender methods as it has been suggested before. |
| ||
If you can do it in monkey, do it in the generated code using xcode and recompile it again. |
| ||
I just load my loading screen in OnCreate and load the other stuff (of course only once) in OnUpdate. Works good on every platform. |
| ||
That's the way then :) |
| ||
@Xaron, or anyone...Dont you have a funny behavior while loading things in the OnUpdate() Method? I'm currently making my own resource manager... and when I load images in the OnUpdate Method i get like 8 Updates for each Render!. I'll run some more tests and post here the results... |
| ||
Ok, here´s a quick code that replicates what i'm experiencing. I'm loading the same image 100 times, each time in a different position in the array. Of course i'm doing this because i'm lazy and i don't want to load 100 different images hehe...But i've tried this in IOS and GLFW. They all behave the same: 7/8 Updates for each Render. If you try this in Flash or HTML you wont see it, because those two cleverly know that i'm loading the same image over and over, so i get the app running very quickly... Funny thing is, if i put the same code in the OnRender method if imageCount < 100 image[imageCount] = LoadImage("exterior.png",64,64,63) imageCount+=1 End I get almost the same calls to update and render! EDIT: muddy_shoes pointed me out that if your update method takes too much time then it will be called repeatedly. This is what's causing the slowdown. Since loading that image in the example takes 108 ms, it makes perfect sense. So, moral of the story: As weird as it sounds, if you´re doing a ResourceManager, load your stuff in the OnRender method.. |