Commit 63bb1e3d authored by marykatefain's avatar marykatefain

refactor intro to separate files

parent 2e30ea53
......@@ -3,7 +3,8 @@
-- See the Lua API! http://www.solarus-games.org/doc/latest
require("scripts/features")
local solarus_logo = require("scripts/menus/intro")
local solarus_logo = require("scripts/menus/solarus_logo")
local intro = require("scripts/menus/intro")
local title_screen = require("scripts/menus/title_screen")
local inventory = require("scripts/menus/inventory.lua")
......@@ -30,8 +31,13 @@ function sol.main:on_started()
-- Show the Solarus logo initially.
sol.menu.start(game, solarus_logo)
-- Title screen after Solarus logo
-- Intro plays after Solarus logo
function solarus_logo:on_finished()
sol.menu.start(game, intro)
end
-- Title screen after intro
function intro:on_finished()
sol.menu.start(game, title_screen)
end
......
-- Intro animation at the start of the game
local scene1 = require("scripts/menus/intro_scenes/scene1")
local intro = {} -- menu object
local intro = {}
-- Called when the intro is started with sol.menu.start(intro)
function intro:on_started()
log("Intro started")
-- Load graphics
self.envelope_closed_gfx = sol.sprite.create("menus/intro/envelope_closed")
self.envelope_open_gfx = sol.sprite.create("menus/intro/envelope_open")
self.envelope_open_gfx:hide()
-- Animation to shake envelope back and forth
function self.envelope_closed_gfx:shiver()
local m = sol.movement.create("pixel")
m:set_loop(true)
m:set_trajectory({
{2, 0},
{-2, 0}
})
m:set_delay(100)
m:start(self)
function scene1:on_finished()
sol.menu.stop(intro)
end
-- Move envelope up screen and call shiver animation
local m = sol.movement.create("target")
m:set_target(0,-91) -- relative to self
m:set_speed(20)
m:start(self.envelope_closed_gfx, function()
self.envelope_closed_gfx:shiver()
sol.timer.start(1000, function()
-- shiver animation finished and removed
self.envelope_closed_gfx:stop_movement()
self.envelope_closed_gfx:hide()
self.envelope_open_gfx:show()
end)
end)
-- sol.menu.stop(intro)
end
-- Called every frame
function intro:on_draw(dst_surface)
dst_surface:fill_color({160,240,240})
self.envelope_closed_gfx:draw(dst_surface, 43, 150)
self.envelope_open_gfx:draw(dst_surface, 43, 3)
sol.menu.start(sol.main, scene1)
end
return intro
-- scene1 animation at the start of the game
local scene1 = {} -- menu object
-- Called when the scene1 is started with sol.menu.start(scene1)
function scene1:on_started()
log("scene1 started")
-- Load graphics
self.envelope_closed_gfx = sol.sprite.create("menus/intro/envelope_closed")
self.envelope_open_gfx = sol.sprite.create("menus/intro/envelope_open")
self.envelope_open_gfx:hide()
-- Animation to shake envelope back and forth
function self.envelope_closed_gfx:shiver()
local m = sol.movement.create("pixel")
m:set_loop(true)
m:set_trajectory({
{2, 0},
{-2, 0}
})
m:set_delay(100)
m:start(self)
end
-- Move envelope up screen and call shiver animation
local m = sol.movement.create("target")
m:set_target(0,-91) -- relative to self
m:set_speed(20)
m:start(self.envelope_closed_gfx, function()
self.envelope_closed_gfx:shiver()
sol.timer.start(1000, function()
-- shiver animation finished and removed
self.envelope_closed_gfx:stop_movement()
self.envelope_closed_gfx:hide()
self.envelope_open_gfx:show()
sol.timer.start(1000, function()
sol.menu.stop(scene1)
end)
end)
end)
end
-- Called every frame
function scene1:on_draw(dst_surface)
dst_surface:fill_color({160,240,240})
self.envelope_closed_gfx:draw(dst_surface, 43, 150)
self.envelope_open_gfx:draw(dst_surface, 43, 3)
end
return scene1
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment