Jump to content

Splash Screen


Slimwaffle
 Share

Recommended Posts

Was wondering if anyone could help me figure out why my Splash Screen is not printing to screen. The system output is telling me the texture file is loading but nothing displays. But yet my line of code that reads Time:Delay is executing fine. There is just no splash screen displaying.

Here is my code below;

import("Scripts/Menu.lua")
--Initialize Steamworks (optional)
Steamworks:Initialize()

--Initialize analytics (optional).  Create an account at www.gameamalytics.com to get your game keys
--[[if DEBUG==false then
    Analytics:SetKeys("GAME_KEY_xxxxxxxxx", "SECRET_KEY_xxxxxxxxx")
    Analytics:Enable()
end]]

--Set the application title
title="Outback Survival"

--Create a window
local windowstyle = 0
local winwidth
local winheight
local gfxmode = System:GetGraphicsMode(System:CountGraphicsModes()-1)
if System:GetProperty("devmode")=="1" then
    gfxmode.x = math.min(1280,gfxmode.x)
    gfxmode.y = Math:Round(gfxmode.x * 9 / 16)
    windowstyle = Window.Titlebar
else
    gfxmode.x = System:GetProperty("screenwidth",gfxmode.x)
    gfxmode.y = System:GetProperty("screenheight",gfxmode.y)
    windowstyle = Window.Fullscreen
end
window=Window:Create(title,0,0,gfxmode.x,gfxmode.y,windowstyle)

--Create the graphics context
context=Context:Create(window,0)
if context==nil then return end

-- Code For Splash Screen
Splash = {}
Splash[1] = Texture:Load("Splash Screen/Leadwerks Splash.tex")
trigger = 1
if trigger > 0 then 

context:SetBlendMode(Blend.Alpha)
context:DrawImage(Splash[1], 20, (context:GetHeight() - 60), 30, 30)
Time:Delay(5000)
trigger = 0
end

--Create a world
world=World:Create()
local gamemenu = BuildMenu(context)


--Load a map
    
    gamemenu:Show()


    

while window:Closed()==false do
    
    if gamemenu:Update()==false then return end
    --Handle map change
    if changemapname~=nil then
        
        --Pause the clock
        Time:Pause()
        
        --Pause garbage collection
        System:GCSuspend()        
        
        --Clear all entities
        world:Clear()
        
        --Send analytics event
        Analytics:SendProgressEvent("Complete",prevmapname)
        
        --Load the next map
        if Map:Load("Maps/"..changemapname..".map")==false then return end
        prevmapname = changemapname
        
        --Send analytics event
        Analytics:SendProgressEvent("Start",prevmapname)
        
        --Resume garbage collection
        System:GCResume()
        
        --Resume the clock
        Time:Resume()
        
        changemapname = nil
    end    
    
    if gamemenu:Hidden() then
        
        --Update the app timing
        Time:Update()
        
        --Update the world
        world:Update()
        
    end

    --Render the world
    world:Render()
        
    --Render statistics
    
    context:SetBlendMode(Blend.Alpha)
    if DEBUG then
        context:SetColor(1,0,0,1)
        context:DrawText("Debug Mode",2,2)
        context:SetColor(1,1,1,1)
        context:DrawStats(2,22)
        context:SetBlendMode(Blend.Solid)
    else
        --Toggle statistics on and off
        if (window:KeyHit(Key.F11)) then showstats = not showstats end
        if showstats then
            context:SetColor(1,1,1,1)
            context:DrawText("FPS: "..Math:Round(Time:UPS()),2,2)
            
        end
    end
    
    --Refresh the screen
    if VSyncMode==nil then VSyncMode=true end
    context:Sync(VSyncMode)
    
end

Link to comment
Share on other sites

Use context:Sync() to "flip" the image drawn on a buffer over to the context... or it used to be something like that in the old days when you had gbuffers... but it still appears to work.

example:

window = Window:Create("Splash",0,0,800,600,Window.Center+Window.Titlebar)
context = Context:Create(window)
world = World:Create()
camera = Camera:Create()
camera:SetPosition(0,0,-3)
light = DirectionalLight:Create()
light:SetRotation(35,35,0)
box = Model:Box()

splash = Texture:Load("Materials/Developer/leadwerks.tex")
context:SetBlendMode(Blend.Alpha)
context:DrawImage(splash,0,0,context:GetWidth(),context:GetHeight())
context:Sync(true)
Time:Delay(2000)

camera:SetClearColor(1,0.5,0)

while window:KeyDown(Key.Escape)==false do
	if window:Closed() then break end

	box:Turn(Time:GetSpeed()*0.5,Time:GetSpeed()*0.5,0)
	
	Time:Update()
	world:Update()
	world:Render()
	context:Sync(true)
end

splash.thumb.jpg.a8149683e007547aaa07dafbf9b64a5f.jpg

  • Like 1

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

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...