How to Add a Splash Screen - Senscape/Dagon GitHub Wiki
HOW TO ADD YOUR OWN SPLASH SCREEN
(Dagon version 1.0.0.1013)
All images for the introduction should be prefaced by "intro_", so name your splash screen image "intro_Splash.png" and put it in the Resources/images folder.
Next you'll need to alter the intro.lua module in the Modules folder. Open it in a text editor. I use Notepad++.
The Splash screen should play right after the Dagon intro screen and just before the Title screen. In the intro module, the Title screen is referred to as the Logo.
-
In the Intro.create function, after the line -
ovrIntro,
Add -
imgSplash,
-
To specify the image to be used for your splash screen and to set the visibility of the image, directly after the line -
setmetatable(self, Intro)
Add -
self.imgSplash = Image("intro_Splash.png")
-
You'll need to disable the logo's visibility, so that your splash screen shows up first. To do this, add the line [code]self.imgLogo:disable()[/code] after the logo's image info so that it looks like this -
self.imgLogo = Image("intro_logo.png")
self.imgLogo:scale(0.5) self.imgLogo:disable()
-
A little further down in the file, after all of the images for the intro have been established, add your splash screen between the intro overlay and the logo like this -
self.ovrIntro = Overlay("Intro") self.ovrIntro:addImage(self.imgSplash) -- your splash screen self.ovrIntro:addImage(self.imgLogo)``
-
In the Intro:start function, add your splash screen after the intro overlay is enabled -
self.ovrIntro:enable() self.imgSplash:enable() -- play your splash screen play("my_splash_screen_sound.ogg") -- play a sound with the splash screen``
-
Directly after that, you need to add your splash screen into the timer in front of the logo screen, like this -
self.timerID = startTimer(4, true, function() if (self.timerLoop == 1) then self.imgSplash:fadeOut() node:fadeIn() musicLayer1:play() elseif (self.timerLoop == 2) then self.imgLogo:fadeIn() cursor.fadeIn() journal:enable() elseif (self.timerLoop == 4) then self.imgLogo:fadeOut() self.imgCredit1:fadeIn()
...and so on until all of your intro credit screens are entered into the timer.
-
In the Intro:resize function, add your splash screen and center it -
function Intro:resize() local w, h = 0 w, h = self.imgSplash:size() self.imgSplash:setPosition((config.displayWidth / 2) - (w / 2), (config.displayHeight / 2) - (h / 2))
That's it. Save your Intro module and run your Dagon.exe file. You should see your splash screen play directly after the Dagon intro screen and it should fade away as your game's title appears.
Imari, 8-11-2012