Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Text width a length
#6
Ja mam dokładnie takie coś, co chcesz uzyskać zrobione:
Code:
local name_string = "tekst, który chcesz skrócić";
local max_width = b_size.w - 10;
local width = 0;
local chars_nr = name_string.len();
        
for(local j = 0; j < name_string.len(); j++)
{    
    width += textWidthPx(name_string.slice(j, j + 1));
    if (width > max_width)
    {
        chars_nr = j;
        j = name_string.len();
    }    
}
button_drw[id].text = name_string.slice(0, chars_nr);

b_size.w - 10 to szerokość tekstury minus margines
chars_nr to wynik w postaci ilości znaków, które się zmieszczą
Wilk Morski Klanu Espadre
Reply


Messages In This Thread
Text width a length - by Son Goku - 20.04.2017, 15:46
RE: Text width a length - by KimiorV - 20.04.2017, 16:13
RE: Text width a length - by Son Goku - 20.04.2017, 16:22
RE: Text width a length - by KimiorV - 20.04.2017, 16:36
RE: Text width a length - by Bimbol - 20.04.2017, 16:59
RE: Text width a length - by Zmorra - 20.04.2017, 22:45
RE: Text width a length - by Son Goku - 21.04.2017, 11:22
RE: Text width a length - by Son Goku - 07.05.2017, 21:03
RE: Text width a length - by Bimbol - 07.05.2017, 21:09
RE: Text width a length - by Son Goku - 08.05.2017, 21:17
RE: Text width a length - by Marcel - 09.05.2017, 00:26
RE: Text width a length - by Bimbol - 09.05.2017, 01:06
RE: Text width a length - by Son Goku - 09.05.2017, 05:33
RE: Text width a length - by Marcel - 09.05.2017, 07:44
RE: Text width a length - by Son Goku - 09.05.2017, 17:49

Forum Jump:


Users browsing this thread: 1 Guest(s)