Pleca Posted December 2, 2024 Share Posted December 2, 2024 Has syntax for CreateSprite function changed? The following line of Lua code produces an error, even though it worked perfectly fine yesterday. local statsSprite = CreateSprite(world, font, "", fontsize) Quote Link to comment Share on other sites More sharing options...
Josh Posted December 2, 2024 Share Posted December 2, 2024 Make sure that font is not NULL. Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Pleca Posted December 2, 2024 Author Share Posted December 2, 2024 Yeah, you're right font isn't loaded, so it's NULL. However, I created a new project and tried running the example from the docs, and I got the same result. -- Get the displays local displays = GetDisplays() -- Create a window local window = CreateWindow("Ultra Engine", 0, 0, 1280, 720, displays[1], WINDOW_TITLEBAR + WINDOW_CENTER) -- Create a framebuffer local framebuffer = CreateFramebuffer(window) -- Create a world local world = CreateWorld() -- Create a camera local camera = CreateCamera(world, PROJECTION_ORTHOGRAPHIC) camera:SetClearColor(0.125) camera:SetPosition(framebuffer.size.x * 0.5, framebuffer.size.y * 0.5, 0) -- Create sprite local fontsize = 36 local font = LoadFont("Fonts/arial.ttf") local sprite = CreateSprite(world, font, "Hello, World!", fontsize) local rect = CreateSprite(world, font:GetTextWidth("Hello, World!", fontsize), font:GetHeight(fontsize), true) --sprite:SetPosition(0,0,0) rect:SetPosition((framebuffer.size.x - rect.size.x) * 0.5, (framebuffer.size.y - rect.size.y) * 0.5, 0) sprite:SetPosition((framebuffer.size.x - rect.size.x) * 0.5, (framebuffer.size.y - rect.size.y) * 0.5, 0) -- Main loop while (not window:Closed()) and (not window:KeyHit(KEY_ESCAPE)) do -- Update world world:Update() -- Render world world:Render(framebuffer, true) end Not sure what I'm doing wrong, but I keep getting these errors: Loading font "Fonts/arial.ttf" Error: Failed to load font. Error: Failed to load font "Fonts/arial.ttf" Deleting font "Fonts/arial.ttf" I'm sure arial.ttf is present in the Fonts directory. Quote Link to comment Share on other sites More sharing options...
Pleca Posted December 2, 2024 Author Share Posted December 2, 2024 Here is a simple font test project using the example from the docs. There's a possibility I'm doing something wrong, but I really don't know what. FontTest.zip Quote Link to comment Share on other sites More sharing options...
Josh Posted December 2, 2024 Share Posted December 2, 2024 Stay tuned, I know the cause of this... Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Solution Josh Posted December 2, 2024 Solution Share Posted December 2, 2024 Okay, it should work with the update I just uploaded. You need to update your project to get the latest binaries. 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Pleca Posted December 3, 2024 Author Share Posted December 3, 2024 Thank you Josh, it's working now. 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.