Rivaldo Realino K
Rivaldo Realino K

Reputation: 1

game maker studio text box writing error

Help, i am new in using game-maker studio and i follow hearth beast tutorial text box, but my text box doesn't write the text even though the code is the same and the box appear, no error message either. Here is the code

// draw the box
draw_set_alpha( .5 );
draw_roundrect_color( x, y, x+width, y+height, c_black, c_black, false );
draw_set_alpha( 1 );

// set the color to white
draw_set_color( c_white );

// line break
if ( string_width( str ) > width-padding-padding ) {
    // remove the space and replace with line break
    message = string_delete ( message, last_space, 1 );
    message = string_insert ( "#", message, last_space );
    ds_list_add( start, last_space+1 );
}

// make sure we didnt reach the end of the message
if ( count < string_length( message ) )
{
    // are we at space, set last_space variable
    if ( string_char_at( message, count ) == " " ) {
        last_space = count;
    } 
    // increment count
    count ++;
}

// did we go past the bottom? move up a line
if ( string_height( str ) > height-padding ) {
    line ++;
}

// grab the string
str = string_copy( message, ds_list_find_value( start, line ), count-ds_list_find_value( start, line ) );

Upvotes: 0

Views: 197

Answers (1)

user7003504
user7003504

Reputation:

From what i see, first 4 lines draw rectangle, and rest manipulates string str to fit the rectangle. But i dont see something like draw_text(x, y, str); which seems like the case as i managed to initialize your code with some made up values, and then managed to draw str (text) on rectangle. If it is not the case, then i think it would be better to also send whole table of variables for your object, or any other draw event code for this object which contains how you actually draw the string.

Upvotes: 0

Related Questions