You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Change the scene to the specified `sceneFileName`. This function destroys the current scene, including all entities, textboxes, and screen buttons, except for the ones marked as persistent. It then loads the new scene and sets the camera and persistent entities, textboxes, and screen buttons.
255
257
256
258
# Arguments
257
259
- `sceneFileName::String`: The name of the scene file to load.
258
-
- `isEditor::Bool`: Whether the scene is being loaded in the editor. Default is `false`.
259
-
260
260
"""
261
-
function JulGame.change_scene(sceneFileName::String, isEditor::Bool=false)
261
+
function JulGame.change_scene(sceneFileName::String)
262
262
this::Main= MAIN
263
263
# println("Changing scene to: ", sceneFileName)
264
264
this.close =true
@@ -269,24 +269,26 @@ function JulGame.change_scene(sceneFileName::String, isEditor::Bool = false)
269
269
skipcount =0
270
270
persistentEntities = []
271
271
for entity in this.scene.entities
272
-
if entity.persistentBetweenScenes && (!isEditor|| this.isGameModeRunningInEditor)
272
+
if entity.persistentBetweenScenes && (!JulGame.IS_EDITOR|| this.isGameModeRunningInEditor)
273
273
#println("Persistent entity: ", entity.name, " with id: ", entity.id)
274
274
push!(persistentEntities, entity)
275
275
skipcount +=1
276
276
continue
277
277
end
278
278
279
279
destroy_entity_components(this, entity)
280
-
for script in entity.scripts
281
-
try
282
-
#TODO: only call latest if in editor and in game mode
283
-
Base.invokelatest(JulGame.on_shutdown, script)
284
-
catch e
285
-
iftypeof(e) != ErrorException
286
-
println("Error shutting down script")
287
-
@errorstring(e)
288
-
Base.show_backtrace(stdout, catch_backtrace())
289
-
rethrow(e)
280
+
if!JulGame.IS_EDITOR
281
+
for script in entity.scripts
282
+
try
283
+
#TODO: only call latest if in editor and in game mode
284
+
Base.invokelatest(JulGame.on_shutdown, script)
285
+
catch e
286
+
iftypeof(e) != ErrorException
287
+
println("Error shutting down script")
288
+
@errorstring(e)
289
+
Base.show_backtrace(stdout, catch_backtrace())
290
+
rethrow(e)
291
+
end
290
292
end
291
293
end
292
294
end
@@ -319,8 +321,8 @@ function JulGame.change_scene(sceneFileName::String, isEditor::Bool = false)
319
321
this.scene.camera = camera
320
322
this.level.scene = sceneFileName
321
323
322
-
ifisEditor
323
-
initialize_new_scene(this, true)
324
+
ifJulGame.IS_EDITOR
325
+
initialize_new_scene(this)
324
326
end
325
327
end
326
328
@@ -452,21 +454,19 @@ function JulGame.create_entity(entity)
gameInfo = currentSceneMain ===nothing? [] : JulGame.MainLoop.game_loop(currentSceneMain, startTime, lastPhysicsTime, true, Math.Vector2(sceneWindowPos.x +8, sceneWindowPos.y +25), Math.Vector2(sceneWindowSize.x, sceneWindowSize.y)) # Magic numbers for the border of the imgui window. TODO: Make this dynamic if possible
323
+
gameInfo = currentSceneMain ===nothing? [] : JulGame.MainLoop.game_loop(currentSceneMain, startTime, lastPhysicsTime, Math.Vector2(sceneWindowPos.x +8, sceneWindowPos.y +25), Math.Vector2(sceneWindowSize.x, sceneWindowSize.y)) # Magic numbers for the border of the imgui window. TODO: Make this dynamic if possible
0 commit comments