local loadAssets = [[ local thread = jin.thread.getThread() local path = thread:demand(1) local img = jin.graphics.Image(path) thread:send(2, img) while(true) do if(thread:receive(255)) then break; -- quit thread end end ]] local img = nil local loader = nil jin.core.onLoad = function() loader = jin.thread.Thread("load assets", loadAssets) loader:start() loader:send(1, "./icon.png") --img = jin.graphics.Image("./icon.png") end jin.core.onEvent = function(e) if e.type == "quit" then jin.core.stop() end end jin.core.onUpdate = function(dt) if loader:receive(2) and img == nil then img = loader:fetch(2) loader:send(255, 1) loader:remove(2) end end jin.core.onDraw = function() if img ~= nil then jin.graphics.draw(img, 20, 20) end end