Yue Posted July 21, 2017 Share Posted July 21, 2017 Hi, I was wondering if it is possible to display an animated image while loading a stage using the Lua secript. Is it possible to do that? Quote Link to comment Share on other sites More sharing options...
Phodex Games Posted July 22, 2017 Share Posted July 22, 2017 Hi, I thought about how to realise this aswell. I never actually did it yet, but as far as I know you need to use the thread functions and then run your code/call your animated picture in there. Correct me if I am wrong. But dont ask me how to put a animated Image into Leadwerks... Quote Link to comment Share on other sites More sharing options...
Yue Posted July 22, 2017 Author Share Posted July 22, 2017 Quote This class is not available in Lua. Quote Link to comment Share on other sites More sharing options...
Einlander Posted July 22, 2017 Share Posted July 22, 2017 You would need to use the hook parameter in the map load function. Point it to a function that will handle your screen drawing. Quote Link to comment Share on other sites More sharing options...
Yue Posted July 22, 2017 Author Share Posted July 22, 2017 12 minutes ago, Einlander said: Necesitará utilizar el parámetro hook en la función de carga del mapa. Apuntar a una función que se encargará de su dibujo de pantalla. Sample Please. Quote Link to comment Share on other sites More sharing options...
Phodex Games Posted July 23, 2017 Share Posted July 23, 2017 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. 1 Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted July 24, 2017 Share Posted July 24, 2017 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 Check if 'loadingScreenActive' bool is true in the game loop. By default it is false, so we continue with the game loop Lets say you then press F to load a new scene You set a bool 'startLoading' to true. At the end of the current frame you check for this startLoading variable. If true, draw image and set the loadingScreenActive to true. 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. After the loading of the map is done, set the loadingScreenActive variable to false again. 2 Quote Link to comment Share on other sites More sharing options...
Yue Posted July 26, 2017 Author Share Posted July 26, 2017 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 Quote Link to comment Share on other sites More sharing options...
Yue Posted July 26, 2017 Author Share Posted July 26, 2017 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 Quote Link to comment Share on other sites More sharing options...
Yue Posted July 26, 2017 Author Share Posted July 26, 2017 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.