demojoel Posted November 28, 2012 Share Posted November 28, 2012 Hello, today I have been having a problem with the dxDrawText & dxDrawRectangle. I assign a button to trigger a function which looks similar to this: local screenX, screenY = guiGetScreenSize() function example () dxDrawText(getElementData(resourceRoot, "server:1") or "", screenX / 2 + 220, screenY / 2 - 220, 20, 120, tocolor(255, 255, 255, 255), 1, "default-bold", "center", "top", true, false) dxDrawText(getElementData(resourceRoot, "server:2") or "", screenX / 2 + 220, screenY / 2 - 200, 20, 120, tocolor(255, 255, 255, 255), 0.9, "default-bold", "center", "top", true, false) dxDrawText(getElementData(resourceRoot, "server:3") or "", screenX / 2 + 220, screenY / 2 - 180, 20, 120, tocolor(255, 255, 255, 255), 0.9, "default-bold", "left", "top", true, true) end Once pressed, the text appears for about 0.01 milliseconds then disappears. I have never encounted this problem before, If anyone has a solution to this, it will be much appreciated. Link to comment
Guest Guest4401 Posted November 28, 2012 Share Posted November 28, 2012 Its because: dxDrawText draws a string of text on the screen for one frame. In order for the text to stay visible continuously, you need to call this function with the same parameters on each frame update (see onClientRender). local screenX, screenY = guiGetScreenSize() function example2() dxDrawText(getElementData(resourceRoot, "server:1") or "", screenX / 2 + 220, screenY / 2 - 220, 20, 120, tocolor(255, 255, 255, 255), 1, "default-bold", "center", "top", true, false) dxDrawText(getElementData(resourceRoot, "server:2") or "", screenX / 2 + 220, screenY / 2 - 200, 20, 120, tocolor(255, 255, 255, 255), 0.9, "default-bold", "center", "top", true, false) dxDrawText(getElementData(resourceRoot, "server:3") or "", screenX / 2 + 220, screenY / 2 - 180, 20, 120, tocolor(255, 255, 255, 255), 0.9, "default-bold", "left", "top", true, true) end function example () addEventHandler("onClientRender",root,example2) end Link to comment
demojoel Posted November 28, 2012 Author Share Posted November 28, 2012 Ahh, now i see... i will try this out. Thanks for the help! Link to comment
Guest Guest4401 Posted November 28, 2012 Share Posted November 28, 2012 You're welcome Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now