StartGame vs Start

cud_s02_print_to_console_with_debuglog

#1

Why would you use the StartGame function as opposed to just calling the Start function?


#2

Hey Thomas,

Typically you’d be creating a method for a specific action/behaviour, you could of course just throw all of your code into one huge method and it would most likely run, but when it comes to debugging it and trying to finds problems it will be much more challenging.

In the case of Number Wizard, consider also that you may want to restart the game, the Start method is only called once when the scene loads, after that, it’s not call again until the scene is perhaps completely reloaded (imagine stopping and restarting your game, or pressing F5 on the keyboard for a web page etc). By placing your start game code in a separate method you can then call StartGame from any other place in your code.

Hope this helps :slight_smile:


#3

Thanks Rob that was exactly what I was looking for.


#4

You’re very welcome Thomas :slight_smile:


#5

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.