Hello.
I need some informations.
I am currently working on the Title Screen of my project, but instead of taking place on a menu, it takes place on a game map.
The Title screen's startup is created when the engine has read main.lua in another file (to avoid bothering the "real" savegames on the File Selection menu)
But, as I access the File Selection screen, the map is still loaded (should be normal because the menu is displayed above the map)
My question is, is the map (and it's objects) that got loaded by the title screen file still loaded when the other savegame got started or are they destroyed and immediately replaced by the new game (for example : the surface) ?
Objects are attached to the map itself
-- Title Screen Map, Work in Progress
-- Todo : Movement
-- Display : It works better then I though
local map = ...
local savegame_menu = require("scripts/menus/savegames")
local draw_title_name = false
local surface = sol.surface.create(320, 240)
surface:fill_color({0, 0, 0})
surface:fade_out(80, function() sol.audio.play_music("menu_title_screen") end)
map.title_screen_logo_img = sol.surface.create("menus/title_screen/title_logo.png")
map.website_img = sol.text_surface.create{
font = "lttp",
font_size = 14,
text_key = "title_screen.website",
horizontal_alignment = "center"
}
map.press_space_img = sol.text_surface.create{
font = "lttp",
font_size = 14,
text_key = "title_screen.press_space",
horizontal_alignment = "center"
}
local function switch_press_space()
map.press_space_img:fade_in(40, function()
map.press_space_img:fade_out(40, function()
switch_press_space()
end)
end)
end
function map:on_key_pressed(key)
if key == "space" or key == "enter" then
if not draw_title_name then
switch_press_space()
draw_title_name = true
else
surface:fade_in(40, function()
sol.menu.start(sol.main, savegame_menu)
end)
end
--
end
return true
end
function map:on_draw(dst_surface)
if draw_title_name then
self.website_img:draw(dst_surface, 160, 220)
self.title_screen_logo_img:draw(dst_surface, 88, 30)
self.press_space_img:draw(dst_surface, 160, 200)
end
surface:draw(dst_surface, 0, 0)
end
File Generated when the engine starts
if not sol.game.exists("solarus_boot.dat") then
local savegame = sol.game.load("solarus_boot.dat")
savegame:set_starting_location("cutscene/scene_TitleScreen/0", "default")
savegame:save()
end
And how it is started in main.lua
-- Then the Title Screen (after "blabla presents").
title_screen.on_finished = function()
if sol.game.exists("solarus_boot.dat") then
self.game = sol.game.load("solarus_boot.dat")
sol.menu.stop_all(self)
self:start_savegame(self.game)
end
end
This is how it looks actually
(http://i.imgur.com/o3nvkj7.png)
Any help will be appreciated
Thanks
Oh well, the API about maps enlighten my thoughts, objects attached to the map are destroyed when loading a new game (because only 1 can exist at runtime)
http://www.solarus-games.org/doc/latest/lua_api_map.html#lua_api_map_overview_lifetime
And so on with the game, according to the on_finished function in the API, the previous game is destroyed to be replaced by the newer one
http://www.solarus-games.org/doc/latest/lua_api_game.html#lua_api_game_on_finished
And so with this, I did have succeed to implement Title Screen with working movements, etc, on Map within the project
https://www.youtube.com/watch?v=UQzOMs7Dv9A