Jump to content

dx stuff


Alex24

Recommended Posts

Hello!

First time posting here I think, I'm kinda new to Lua.

So I started doing stuff with dxDrawImage and DrawText, and I am a little bit confused right now.

Not sure if it should work or not, but the images are centered and working alright on every resolution, but the text and the "button" is not behaving how it supposed to.

dxDrawText("Text here", sWidth/2.199, sHeight/1.29, 177, 14, ... )

I tried doing the positioning in 2 ways. The texts left upper corner should be at 873x837 on 1920x1080 resolution. It works well on that, but not with the others, it goes further away the lower I go. The same with the box, which I'm not gonna include that here, I don't think it's neccessery. 

So the way I calculated it was like this: 1920/873 which is 2.199. I tried to do it the otherway around, and multiply it by 0,45xxx but it's the same. Here are 2 pictures of how it should look, and how it looks like:

1920x1080: https://puu.sh/w9bmU/b759ec873f.jpg

1152x864: https://puu.sh/w9bkN/3dc163c128.jpg

Here is the working picture:

dxDrawImage(sWidth/2-204,sHeight/2-404,409,809,...)

It is centered on every resolution. I also tried doing sWidth/2.199-88 and sHeight/1.29-7 but didn't help it. It's probably something really obvious but I just can't see it. Or is it the counting thats not right? I saw it in a video a long time ago which I can't find anymore, might have misunderstood something or I can't remember it that well.

Link to comment
local startX, startY = sWidth/2-204, sHeight/2-404
local width, height = 409, 809
dxDrawImage(startX, startY, width, height,...)

-- Then when you want to draw text inside the image, use startX and startY as starting point so it works on all screen resolution
-- This is example
dxDrawText("Text here", startX, startY, startX+width, startY+height, tocolor(255,255,255,255), 1, "default", "center", "center" )

dxDrawText("Text here 2", startX, startY+400, startX+width, startY+height, tocolor(255,255,255,255), 1, "default", "center", "center")

 

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...