Jump to content

Pause, delay, sleep .. Splash Screen?


Andy Gilbert
 Share

Recommended Posts

HI, im trying to find a way to impliment a splash screen?

 

Just simply show a 2D image for n seconds at the start of the app?

 

With lua not having any build in commands its not a great styart. Ive tryed using Leadwerks timing functons but cant find a way to do it?

 

Anyone had any luck with doing this?

 

Thanks

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

You don't even need timers, because loading the whole scene and setting up things takes longer than you would display the splash screen. So just show a splash screen with DrawImage(); before you load the scene, and then hide it when before the main loop starts.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

HI Metatron, doesnt in my case?

 

The whole game is ready pretty much instantly... I dont get any "black screen" or anything, it just immidiatly puts me in otthe game. I want to show a splash either before or "over" the game for at least 2 - 3 seconds.

 

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

Then you can make a simple wait command after you draw the image on screen and flip.

--- Delay for a number of seconds.
-- @param delay Number of seconds
function delay_s(delay)
delay = delay or 1
local time_to = os.time() + delay
while os.time() < time_to do end
end

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

Ok, i guess that will do for now, the loading time is around 2 seconds, which is fine enough. Would still know how to do it for n seconds though?

 

Thanks

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

ok, but its the "wait" or the "delay" command i cant seem to find for LUA?

 

A wait or pause is exactly what i want, but i cant find a way in lua to do this?

 

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

You would have to actually measure the time after the drawimage and before the wait loop, so that the delay doesn't get bigger than n seconds if the scene loading takes already n seconds or more.

I just posted an example of a delay command, read up.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

The complete sequence is then pretty simple:

DrawImage()
Flip(0)
local time_to = os.time() + 5 -- 5 secs wished delay
LoadScene()
while os.time() < time_to do end

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

ok ill give this a go. I dont understand why ive been searching for time functions for lua and read everywhere that lua doesnt have any time functions built in to it, yet it obv has?

 

Thanks

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

I dont understand why ive been searching for time functions for lua and read everywhere that lua doesnt have any time functions built in to it, yet it obv has?

 

 

Really? yet its in the Lua 5.1 Reference Manual, and mentioned in posts on this forum?

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

Well i certainly wouldnt make up posts for no reason Marley?

 

I assume its because i was searching for terms like, sleep, delay, pause. Which wernt findng much in regards to lua.

 

I did search the forum and found one particlar post that refered the method above but ended on saying you shouldnt use the method as it pauses everything, including loading of assets? So i ignored it...

 

http://www.leadwerks...h__1#entry21594

 

Andy

The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do.

 

Leadwerks Game-Ready 3D Models:https://sellfy.com/gib3d

Link to comment
Share on other sites

Well i certainly wouldnt make up posts for no reason Marley?

 

I never said you did make up a post for no reason Andy. Just found it odd you could not find any reference to time functions.....

AMD Bulldozer FX-4 Quad Core 4100 Black Edition

2 x 4GB DDR3 1333Mhz Memory

Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5

Windows 7 Home 64 bit

 

BlitzMax 1.50 • Lua 5.1 MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro

3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET

 

LE 2.5/3.4 • Skyline UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0

 

Marleys Ghost's YouTube Channel Marleys Ghost's Blog

 

"I used to be alive like you .... then I took an arrow to the head"

Link to comment
Share on other sites

  • 2 years later...

This is what I did in LUA to display a splash screen and pause for 10 seconds.

 

I am trying to implement this in C++ but it is not doing it for some reason.

 

 

Under the App:start Function

 

--Load a spash screen texture
self.splash = Texture:Load("Materials/splash.tex")

--Set a flag so it does not run the splash screen everytime it loops
StartUp = 1

 

 

Under the function App:Loop()

 

--load a splash screen before starting the game
-- If the startUp flag is grater or equal to 1 then load the splash screen
-- It did not like it if it was just equal to 1 and it bugged out until I put the greater than in

if startUp >= 1 then

self.context:SetColor(0,0,0)
self.context:Clear() -- Clear the context
self.context:SetColor(1,1,1)
self.context:DrawImage(self.splash,0,0) --Draw the splash screen
self.context:Sync(true) -- Sync so it loads the screen

Time:Delay(10000) -- Time delay of 10 sec's while the splash is displayed
startUp = 0 -- set the startUp flag to 0 so the splash screen does not
-- display on the next pass in the loop.

end -- end the if statement

  • Upvote 1
Link to comment
Share on other sites

  • 1 month later...

Thank you for the script, liam. I would like to point out that by adding the two further parameters (width, height) to the DrawImage() function you can resize it (as per documentation). It works just fine out of the box.

 

However, I am having an interesting issues in which my two splash screens (LE logo and my own logo) are repeating infinitely, despite the flag being set to 0. Any reason that might happen, or is it just the result of having no other code to follow?

 

More specifically, it will load self.splash1, then wait (Time:Delay(5000)), then it draws self.splash2, and then waits another 5 seconds. After that, it loops back to splash1, despite my flag.

 

I'll keep working on this to find a way, but if you have any input it'd be most welcome!

 

EDIT: Apologies if I am considered to be also "necro'ing" this thread, but it is simply too useful to leave dormant.

EDIT #2: I tossed in return false and that made it stop. Hehe. A rather heavy-handed work around however.

 

Also, do you think there is a way to "fade" the screens from one to the other?

Link to comment
Share on other sites

Thank you for the script, liam. I would like to point out that by adding the two further parameters (width, height) to the DrawImage() function you can resize it (as per documentation). It works just fine out of the box.

 

However, I am having an interesting issues in which my two splash screens (LE logo and my own logo) are repeating infinitely, despite the flag being set to 0. Any reason that might happen, or is it just the result of having no other code to follow?

 

More specifically, it will load self.splash1, then wait (Time:Delay(5000)), then it draws self.splash2, and then waits another 5 seconds. After that, it loops back to splash1, despite my flag.

 

I'll keep working on this to find a way, but if you have any input it'd be most welcome!

 

EDIT: Apologies if I am considered to be also "necro'ing" this thread, but it is simply too useful to leave dormant.

EDIT #2: I tossed in return false and that made it stop. Hehe. A rather heavy-handed work around however.

 

Also, do you think there is a way to "fade" the screens from one to the other?

the blood overlay in the fps script does fading which is a good example to start from.

  • Upvote 1

OS: Windows 10 Pro

CPU:  i3-10100 CPU @ 3.60GHz
GPU: NVIDIA 2060 Super - 8 GB

RAM: 32 GB

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...