diff options
| author | Eltrac <hi@guhub.cn> | 2025-03-12 17:55:00 +0800 |
|---|---|---|
| committer | Eltrac <hi@guhub.cn> | 2025-03-12 17:55:00 +0800 |
| commit | 6b48551d59818b385200221f0a42afea0a3545d5 (patch) | |
| tree | a3403b639567693f25462a5aaf74ffba8a42ccf3 /main.lua | |
| parent | 4bfe8d7679bfce861c03cff728d1aa9f44efeff9 (diff) | |
fix: game crash when creating new body during world update
use a body lifecycle manager to create after world update is done
Diffstat (limited to 'main.lua')
| -rw-r--r-- | main.lua | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -1,10 +1,9 @@ require "config" require "utils.utils" - require "render.sprite" require "render.speaker" - local map = require "logic.map" +local bodyLifeCycleManager = require "utils.bodyLifecycleManager" local controller = require "logic.controller" local translator = require "i18n.translator" @@ -21,6 +20,8 @@ function love.load() -- initialize game state initGame() + -- body life cycle manager + G.BodyLifeCycleManager = bodyLifeCycleManager.new() -- set world callbacks G.world:setCallbacks(onContact) @@ -33,7 +34,7 @@ end function love.update(dt) -- game state updates - local gameStates = { G.world, G.currentRoom, G.player } + local gameStates = { G.world, G.currentRoom, G.player, G.BodyLifeCycleManager } for _, state in ipairs(gameStates) do state:update(dt) end |
