Jump to content

Loading Asets Scene Lua SCripts


Yue
 Share

Recommended Posts

Maybe this helps? debug.sethook should work, but in the offical API you just find this and that. Just tried that, debug.sethook, what you find in the offical LUA API also works in Leadwerks. But I dont know how to use the "AddHook" function. You seem to need any kind of keyword in addition. However Leadwerks does not seem to recognice "AddHook" as a keyword. But I think debug.sethook should do the job.

  • Upvote 1
Link to comment
Share on other sites

Drawing a static image before a new scene is loaded is fairly easy. An animation or sprite is a little harder to do.

For a static image

  1. Check if 'loadingScreenActive' bool is true in the game loop. By default it is false, so we continue with the game loop
  2. Lets say you then press F to load a new scene
  3. You set a bool  'startLoading' to true.
  4. At the end of the current frame you check for this startLoading variable. If true, draw image and set the loadingScreenActive to true.
  5. Then in the next frame update, when we check the value of loadingScreenActive again. This time it is true and you call loadmap. Because the engine is drawing an image on screen and loading the new scene halts the process of updating. 
  6. After the loading of the map is done, set the loadingScreenActive variable to false again.
  • Upvote 2
Link to comment
Share on other sites

Test My Solution. :) Bar Progress Animating.  No work.
'loadingScreenActive'  Where?

ventana = Window:Create()
lienzo  = Context:Create(ventana)

mundo = World:Create()

local x = 0



local mapa = nil

while mapa == nil  do 

	
	
	mapa = Map:Load("Maps/start.map")

	x = x + 1

	lienzo:DrawRect(0,0, x, 50, 0 )


	if x >= 100 then 

		x = 100
	end 

	lienzo:Sync()

end 



while true do


	if ventana:Closed()  or ventana:KeyDown( Key.Escape )then return false end



	mundo:Update()
	mundo:Render()
	lienzo:Sync()




end 

 

Mars.jpg.89ab63a64eebc1f5ada0ab82b66a1f8c.jpg

 

 

Link to comment
Share on other sites

Ok, 

This is the most real thing I can do. :)
 

ventana = Window:Create()
lienzo  = Context:Create(ventana)

mundo = World:Create()

 x = 0



 mapa = 0

function Loading()

	lienzo:DrawText("Loading Map...",lienzo:GetWidth()/2,lienzo:GetHeight()/2+75)
	lienzo:Sync()

end 


while x  <= 200  do 

	


	x = x + 1
		if x == 100 then 

			cargar = true 
		end 


	lienzo:DrawRect(lienzo:GetWidth()/2-50,lienzo:GetHeight()/2-25.5, x, 25, 0 )
	lienzo:DrawRect(lienzo:GetWidth()/2-50,lienzo:GetHeight()/2-25, 200, 26, 1 )

	lienzo:SetBlendMode(Blend.Alpha)
       
        lienzo:DrawText("Loading",lienzo:GetWidth()/2,lienzo:GetHeight()/2+25)

		lienzo:Sync()


		if cargar == true then
			
			
			mapa = Map:Load("Maps/07-AI and Events.map","Loading")
			
			cargar = false
		end 



end 




-- Level 1 Render.

while true do


	if ventana:Closed()  or ventana:KeyDown( Key.Escape )then return false end



	mundo:Update()
	mundo:Render()

lienzo:SetBlendMode(Blend.Alpha)
        lienzo:SetColor(1,0,0)
        lienzo:DrawText("HOLA",0,0)
	
	lienzo:Sync()




end 

 

Mars.jpg.89ab63a64eebc1f5ada0ab82b66a1f8c.jpg

 

 

Link to comment
Share on other sites

Ok, run perfect. :) Test 2 on Lua.


 

-- Loading Barr Progress Map.
-- Yue Rexie
-- Engine LeadWerks


ventana = Window:Create("Test",0,0, 800,600, Window.Titlebar + Window.Center )
lienzo  = Context:Create( ventana ) 

mundo = World:Create()

local x = 0


co = coroutine.create(function () Map:Load("Maps/07-AI and Events.map") end)


while x <= 200 do

	-- Salir.
	if ventana:Closed() then return false end 
	if ventana:KeyHit(Key.Escape ) then return false end 

	x = x + 1

	if x == 100 then 
		
		coroutine.resume(co)

	end 
	
	 lienzo:DrawRect(lienzo:GetWidth()/2-100, lienzo:GetHeight()-50, x, 25)
	 lienzo:DrawRect(lienzo:GetWidth()/2-100, lienzo:GetHeight()-50,200, 25, 1 )
	 lienzo:Sync()


end 



while true do

	if ventana:Closed() then return false end 
	if ventana:KeyHit(Key.Escape ) then return false end 
	

	mundo:Update()
	mundo:Render()
	lienzo:Sync()

end 



 

Loading.png

Mars.jpg.89ab63a64eebc1f5ada0ab82b66a1f8c.jpg

 

 

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