Jump to content

dxDrawText - help me with "wordBreak", please


Recommended Posts

How to use wordBreak in dxDrawText?

Wiki:

wordBreak: if set to true, the text will wrap to a new line whenever it reaches the right side of the bounding box. If false, the text will always be completely on one line.

It does not wrap to a new line =(

  
local message = "bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla" 
dxDrawText(message, screenx/2, screeny/2, 300, 300, tocolor(50, 50, 50, 255), 0.5, smallarial, "left", "top", false, true, false) 
  

Link to comment

Let's assume your game resolution is a minimum one, so it's 800x600.

Then

x1 = screenx/2 = 800/2 = 400

y1 = screeny/2 = 600/2 = 300

and

x2 = 300

y2 = 300

where x2 is the "right" argument and y2 is the "bottom" argument.

However, you probably wanted x1+300 and y1+300, so instead you should put

x2 = 400+300 = 700

y2 = 300+300 = 600

These numbers work for 800x600 resolution and just illustrates the issue.

Link to comment
  • Moderators
How to use wordBreak in dxDrawText?

Wiki:

wordBreak: if set to true, the text will wrap to a new line whenever it reaches the right side of the bounding box. If false, the text will always be completely on one line.

It does not wrap to a new line =(

  
local message = "bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla" 
dxDrawText(message, screenx/2, screeny/2, 300, 300, tocolor(50, 50, 50, 255), 0.5, smallarial, "left", "top", false, true, false) 
  

I had the same problem in one of my scripts. It seems it doesn't work afaik.

But anyway the 3th and 4th arguments aren't the size, but the X(end) and Y(end) positions of the bounding box. Which even makes it impossible to let it work. Should be: (screenx/2)+300, (screeny/2)+300

Especially when you are going to change the position of the text in the boundingbox.

Some people say it is the size, but trust me it isn't that.

Link to comment

Yep! :idea:

  
dxDrawText(message, screenx/2-145, screeny-25, screenx/2+135, 0, tocolor(50, 50, 50, 255), 0.5, smallarial, "left", "top", false, true, true, false) 
  

1 arg. - message

2 arg. - position of left board

3 arg. - position of top board

4 arg. - position of end of left board

5 arg. - position of end of top board

Link to comment

is it just me or everyone is speaking about a different topic?

now 1: for word break.

it works perfectly for me, but if you have problems with it, use /n to create a new line.

2: making it suit every resolution:

you can easily do it by doing this:

local x,y = guiGetScreenSize()

local scale = x/(your resolution)

then

dxDrawText(number*scale,number*scale.....etc)

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