How would you handle a loading screen? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How would you handle a loading screen?

When switching between levels or when starting my game, it takes a few seconds of loading. Right now the window just freezes and the curser becomes a loading icon - just as if the application was not responding. And if eventually the game start the enemies start misbehaving. How would I handle this the best way? Can I add a loading animation to the screen or do I just write "loading..."?

7th Apr 2020, 10:12 AM
Ransome
Ransome - avatar
2 Answers
+ 3
If you're getting freeze, you should have difficulty to handle a load screen (at least animated, because if you are running intesive task, the display itself may drop frames update) and you should ensure that you start computation only after a screen refresh (to be sure that the display of your load screen doesn't occurs only after your computations) ^^ Some basic preload examples: https://code.sololearn.com/WQFY6mw16wjK/?ref=app https://code.sololearn.com/W39ioBVR1eJn/?ref=app https://code.sololearn.com/W2ltc47fRCj9/?ref=app https://code.sololearn.com/WFVLBeztLI51/?ref=app
7th Apr 2020, 10:40 AM
visph
visph - avatar
+ 1
When switching between levels, if you are trying to load all the elements in the next level in one frame that may cause freeze. You should be building your game to handle that. For example you can think to create a base GameObject class to derive all the elements from. And then create an array of GameObjects. Then put all the elements in your next level to that array. Then load them 5 by 5 or 10 by 10. You will try and find the best one. For example (pseudo code) #update is called per frame update() iteration_amount = 5 GameObject level2 = [] temp = 0 for (int i=temp; i<temp + iteration_amount; i++) Load.object (level2 [i] ) temp += iteration_amount print ( "Loading...") Something like this should work. edit: typing mistakes are fixed.
7th Apr 2020, 10:27 AM
Mustafa K.
Mustafa K. - avatar