Jump to content

dxDrawText Relative problem


Karuzo

Recommended Posts

Hey Guys,

so i have again a question about my scoreboard.

I have this code :

dxDrawImage((x- 720)/2, (y-460) /2, 720, 460, "images/back.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) 
dxDrawText("Name", (x - 110) / 2.3, (y - 29) / 3.7, 110,29, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) 
dxDrawText(getPlayersOnline().."/50" ,(x - 101) / 1.25, (y - 27) / 4.3, ((x - 101) / 1.25) + 101, ( (y - 27) / 4.3) + 27, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, false, false, false) 
dxDrawText("Germain Kaff Reillife by Blackpotato", (x - 168) / 1.7, (y - 23) / 4.2, ((x - 168) / 1.7) + 168, ( (y - 23) / 3.-- s8) --> + 23, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) 
dxDrawText("Ping", (x - 110) / 1.25, (y - 29) / 3.7, ((x - 110) / 1.25) + 10, ( (y - 29) / 3.7) + 29, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) 
dxDrawText("Money", (x - 110) / 1.78, (y - 29) / 3.7, ((x - 110) / 1.78) + 110, ( (y - 29) / 3.7) + 29, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "top", false, false, true, false, false) 

Ok. so whats my question ? The dxText's aren't in that place where they should be .

So i searched a little bit in the forum, i've found out that i need to do them in relative.

But wiki says:

left: the absolute X coordinate of the top left corner of the text

I should give the coordinates in absolute.

So what's right now ?

Link to comment

Relative:

Left hand side of your screen is 0 and the right hand side of your screen is 1. So 0.5 is the centre.

Absolute:

As far as I know, it is counted in pixels, so, '20, 20' is going to be at the 20th pixel of your screen, if you get me.

How to get the relative:

Simple maths. Lets say, you want to draw a dxRectangle, starting at 0, 0 and you want the size to be half of the screen. Just do:

local sX, sY = guiGetScreenSize() 
local rX, rY = sX * 0.5, sY * 0.5 -- 50% 
dxDrawRectangle(0, 0, rX, rY)  

Link to comment

So i searched a little bit in the forum, i've found out that i need to do them in relative.

But wiki says:

left: the absolute X coordinate of the top left corner of the text

I've been searching a long time and didn't understand it. So i opened a thread that people may help me.

B2T:

pa3ck thank you ,

i think i ve now understood it.

If ive got more questions ill post them here.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...