I
isador555
Guest
Hello ladies and gentlemen. I'm busy trying to make my first game with Gamemaker, and I could use a bit of help. I've created an object where my intent is to have that object be clickable, which will spawn a text box. When the text box gets clicked, it will cycle through several pages of dialogue, until it runs out of dialogue, at which point another click on the text box will make it disappear. When the player then clicks on the object again, it should spawn the text box again, starting on page 1.
Now, I'm not an experienced coder by any means, I'm mainly doing this with the help of a friend who knows how to do it, plus online tutorials, but those only go so far, and I've reached the point where I feel I've exhausted the resources I know about and can't move further without help.
This is the code i'm working with.
In the "create: event of this object, i put all of my text in an array:
alpha = true;
beta = true;
textbox1[0] = "text";
textbox1[1] = "text2";
textbox1[2] = "text3"
click_tracker = 0;
The alpha/beta variables are mainly there for the future, when I'd like to use those variables to make the same object pick one of several different arrays of text, but first, I need to get this to work properly.
Under a "left button" mouse event for this object, this is the code that spawns the text boxes.
if (alpha == true)
{
scr_text (textbox1[click_tracker], 0.5,64,64);
click_tracker++;
if (click_tracker > array_length_1d(textbox1)-1)
{
click_tracker=0;
}
}
Unfortunately, there's a few things wrong with it. First off, when I start my game and click the object, it spawns all the text boxes on top of each other in one go, instead of having one text box pop up per click. The text boxes are all removed at once if I click on them.
The second issue is that it doesn't scroll through new pages of text when I click on the text box. Instead, this code will (or rather, should, if it worked properly) create the first text box, which gets removed if the player clicks it, and if the player clicks the object again, it spawns text box two. Once it reaches the last text box, it resets and spawns the first text box again if the object is clicked.
So, would anyone be able to help me out with these two issues? To summarize, I need my text boxes to not all spawn on top of each other when my object is clicked, and if possible, I also want my text box to "scroll" through all available pages when clicked, rather than have to spawn a new text box every time I want to open the next page.
Now, I'm not an experienced coder by any means, I'm mainly doing this with the help of a friend who knows how to do it, plus online tutorials, but those only go so far, and I've reached the point where I feel I've exhausted the resources I know about and can't move further without help.
This is the code i'm working with.
In the "create: event of this object, i put all of my text in an array:
alpha = true;
beta = true;
textbox1[0] = "text";
textbox1[1] = "text2";
textbox1[2] = "text3"
click_tracker = 0;
The alpha/beta variables are mainly there for the future, when I'd like to use those variables to make the same object pick one of several different arrays of text, but first, I need to get this to work properly.
Under a "left button" mouse event for this object, this is the code that spawns the text boxes.
if (alpha == true)
{
scr_text (textbox1[click_tracker], 0.5,64,64);
click_tracker++;
if (click_tracker > array_length_1d(textbox1)-1)
{
click_tracker=0;
}
}
Unfortunately, there's a few things wrong with it. First off, when I start my game and click the object, it spawns all the text boxes on top of each other in one go, instead of having one text box pop up per click. The text boxes are all removed at once if I click on them.
The second issue is that it doesn't scroll through new pages of text when I click on the text box. Instead, this code will (or rather, should, if it worked properly) create the first text box, which gets removed if the player clicks it, and if the player clicks the object again, it spawns text box two. Once it reaches the last text box, it resets and spawns the first text box again if the object is clicked.
So, would anyone be able to help me out with these two issues? To summarize, I need my text boxes to not all spawn on top of each other when my object is clicked, and if possible, I also want my text box to "scroll" through all available pages when clicked, rather than have to spawn a new text box every time I want to open the next page.