PEACE UNTO YOU ALL! THANKS FOR ALL YOUR HELP IN ASSISTING ME WITH MY QUESTIONS IN MAKING THIS GAME!
Right now I am in closed testing for my game for Android devices. I got it to where the game doesn’t crash, so the app doesn’t force close and crash per se. But what does happen is every blue moon, and it’s very random. So in that perspective it’s good that it doesn’t happen consistently, because it’s very random. But randomly when the main game is being played and the player dies, inside the main game a game over screen appears over top of the main game. And a countdown happens. And when the countdown reaches 0 from 5 seconds, it goes 5, 4, 3, 2, 1, 0. Once the countdown reaches 0, then the loader script is supposed to receive a message that says, Load the main menu. I already have the script preloaded in the background. So, specifically, may you please explain how it’s possible for the game to freeze when trying to load the main menu again after the game over screen reaches 0 and the message is being sent? I have the checks that preload the main menu. So, how could it freeze? It isn’t a crash, it just freezes. And since it happens randomly, I want to try to figure out if I can figure it out before the game releases. But even if the game releases, because it happens so far and few and randomly, it’s kind of hard to still not put out the game, because the game is in a good state. Everything just works perfectly. It’s literally just sometimes when the game over screen reaches 0 it’s supposed to load the main menu screen, for whatever reason, the game just freezes and doesn’t do it. What is every possible reason that it could be so that a freeze happens? What could be the reason? Because normally it just works. It works perfectly fine every other time. So that lets me know that it’s working. So, what could have happened?
If I had to put a ratio to it I would say 1 every 10 times so it’s very rare but I’m still new to development as this is my first game so please assist me. Here is my loader script. What could I do to ensure everything works like it usually works cause the overwhelming amount of time it works fine. Also if you wanna be a tester for the game let me know!
Thank you! We are very grateful!
Loader Script:
local function load_menu(self)
print("Loading Menu...")
msg.post("go#menu", "load")
msg.post("go#menu", "enable")
end
local function unload_menu(self)
print("Unloading Menu...")
msg.post("go#menu", "disable")
msg.post("go#menu", "unload")
end
local function preload_main(self)
print("Preloading Main Game...")
msg.post("go#main_game", "async_load") -- Preload the main game in the background
end
local function preload_menu(self)
print("Preloading Menu...")
msg.post("go#menu", "async_load") -- Preload the menu in the background
end
local function load_main(self)
print("Loading Main Game...")
timer.delay(0.01, false, function()
msg.post("go#main_game", "load")
msg.post("go#main_game", "enable")
end)
end
function init(self)
print("Initializing Loader Script...")
msg.post(".", "acquire_input_focus")
-- Load the menu initially
load_menu(self)
-- Preload the main game and menu in the background
preload_main(self)
preload_menu(self)
end
function on_message(self, message_id, message, sender)
if message_id == hash("start_game") then
print("Starting Game...")
unload_menu(self) -- Unload the menu before starting the game
load_main(self) -- Load the main game collection
admob.hide_banner()
elseif message_id == hash("load_menu") then
print("Returning to Menu...")
-- Properly unload the main game before loading the menu
msg.post("go#main_game", "disable")
msg.post("go#main_game", "unload")
load_menu(self)
elseif message_id == hash("proxy_loaded") then
-- Log which proxy has been loaded
if sender == hash("go#main_game") then
print("Main Game Proxy Loaded.")
elseif sender == hash("go#menu") then
print("Menu Proxy Loaded.")
end
elseif message_id == hash("proxy_unloaded") then
-- Log which proxy has been unloaded
if sender == hash("go#main_game") then
print("Main Game Proxy Unloaded.")
elseif sender == hash("go#menu") then
print("Menu Proxy Unloaded.")
end
end
end