psychoanima Posted July 4, 2017 Share Posted July 4, 2017 I would like to know how to make on screen text messages, like in RPG games. Can someone help me out? Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted July 4, 2017 Share Posted July 4, 2017 Sounds like a label. https://www.leadwerks.com/docs?page=API-Reference_Object_Widget_Label Quote Link to comment Share on other sites More sharing options...
psychoanima Posted July 4, 2017 Author Share Posted July 4, 2017 23 minutes ago, AggrorJorn said: Sounds like a label. https://www.leadwerks.com/docs?page=API-Reference_Object_Widget_Label Yeah, that seems to work nicely. I don't see any way of resizing the text and changing fonts btw... Quote Link to comment Share on other sites More sharing options...
brndx Posted July 4, 2017 Share Posted July 4, 2017 You can change the font and size by calling the correct methods. For example: myfont = Font:Load("Fonts/arial.ttf",14) context:SetFont(myfont) Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted July 4, 2017 Share Posted July 4, 2017 (edited) Since there aren't specific API calls for that I would assume it takes over from the active font that is set. *post above beat me to it. Edited July 4, 2017 by AggrorJorn Quote Link to comment Share on other sites More sharing options...
psychoanima Posted July 4, 2017 Author Share Posted July 4, 2017 6 hours ago, brndx said: You can change the font and size by calling the correct methods. For example: myfont = Font:Load("Fonts/arial.ttf",14) context:SetFont(myfont) It works, but it scales/changing all fonts in the game, including menus. Quote Link to comment Share on other sites More sharing options...
Ma-Shell Posted July 4, 2017 Share Posted July 4, 2017 1 hour ago, psychoanima said: It works, but it scales/changing all fonts in the game, including menus. Then save the old font: oldfont = context:GetFont() context:SetFont(myfont) [write...] context:SetFont(oldfont) Quote Link to comment Share on other sites More sharing options...
psychoanima Posted July 4, 2017 Author Share Posted July 4, 2017 1 hour ago, Ma-Shell said: Then save the old font: oldfont = context:GetFont() context:SetFont(myfont) [write...] context:SetFont(oldfont) Yes, but that still doesn't let me to use two different font size at the same time? Quote Link to comment Share on other sites More sharing options...
macklebee Posted July 4, 2017 Share Posted July 4, 2017 You have to manage your fonts just like any asset. window = Window:Create("font example",0,0,400,300) context = Context:Create(window) world = World:Create() camera = Camera:Create() light = DirectionalLight:Create() light:SetRotation(45,45,0) box = Model:Box() box:SetPosition(0,0,3) box:SetColor(1,0,0,1) lilfont = context:GetFont() medfont = Font:Load("Fonts/arial.ttf", 24, Font.Smooth) bigfont = Font:Load("Fonts/arial.ttf", 48, Font.Smooth) 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:SetBlendMode(Blend.Alpha) context:DrawText(string.format("FPS: %.2f",Time:UPS()),0,10) context:SetFont(bigfont) context:DrawText("BIG FONT",0,30) context:SetFont(medfont) context:DrawText("MEDIUM FONT",0,80) context:SetFont(lilfont) context:SetBlendMode(Blend.Solid) context:Sync(true) end 1 Quote 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 More sharing options...
psychoanima Posted July 4, 2017 Author Share Posted July 4, 2017 Awesome! Thank you @macklebee! 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.