class MenuButton : Button { override fun onClicked( event : MouseEvent ) { // If we are play one of the scene in a "MORE" menu, then // return to that menu. // Otherwise, return to the main menu. val sceneName = Game.instance.sceneName if ( sceneName.contains("/") ) { val slash = sceneName.indexOf("/") val dir = sceneName.substring(0,slash) val menuName = "$dir/$dir" if (Game.instance.resources.sceneExists( menuName ) ) { Game.instance.startScene("$dir/$dir") return } } Game.instance.startScene("menu") } }