The message string is prepended and appended with a blank string the length of the message window so the scrolling text cleanly enters and exits the message window while looping. The final score of the previous game is inserted into the message string by replacing the placeholder score with the value of the built-in score variable.
. Description A text input field that allows scrolling text, selecting text both with keyboard (holding shift and moving the cursor) and by using the mouse.
Allows commads like Shift+Home to select everything from the current cursor position to the first position etc. Changes in 1.1.1. Fixed bug where inputing # would cause a line break. # is now correctly escaped. Fixed bug where the selection box sometimes were wider than the selected text. Added code to free the surface upon removing the textbox to avoid memory leaks.
Version 1.1.1. Published August 24, 2016 Created with GameMaker: Studio v1.4.1757 Age Rating: 4+. Kevin F 27 February 2017 Works well, but a few bugs. Commented very well. I downloaded this extension this morning and had a fun time tweaking the code, and adding my own features.
A bug that I found was that switching to full screen destroys the surface the textbox is being drawn to, but thankfully it was an easy fix, just had to recreate the surface if it no longer existed. I added the ability to support different fonts, double clicking selects the entire text in the text box, and deleting text (when the text is offset to the left) will set the offset to zero if the string width is less than the width of the text box. I had such a smooth time modifying the code because it was really well commented, and written nice and clean.
Very well done, it saved me a lot of time!
Creating a textbox engine for a role playing game can be a daunting task. Textboxes seem simple at first, but soon become a nightmare of string functions. In this tutorial series, I will explain how to create an advanced textbox engine for Game Maker Studio. Features include:. Display text in a textbox.
Automatic word wrapping. Type-writer effect for displaying text. Textbox can expand onto multiple pages NOTE: I will be creating my textbox engine in a room with the size of 320×240.
The size of my textbox will be 288×80. Feel free to use different dimensions! Step 1: Create a new object.
Name it objtextbox. Add a new Create Event. Step 2: In the Create Event of objtextbox add the following code. This is a list of variables you can edit to customize the textbox engine. Feel free to change any of these variables to suit your needs. /////////// Edit these values ////////////// // continue sprite – Will be displayed when the textbox is full of text continueSprite = sprcontinue; // Speed of continuesprite imagespeed = 0.4; // X position of the continue sprite spriteX = viewwport 0 / 2; // Y position of the continue sprite spriteY = viewhport 0 – 21; // The background image of the textbox background = bkgtextbox; // Confirm Key confirmKey = ord( ‘X’); // Speed Up Key speedUpKey = ord( ‘Z’); // Determines how many characters will be drawn per iteration.
5 = 5 characters per step characterSpeed = 1; // Determines the number of characters that will drawn when pressing the speed up key maxCharacterSpeed = 1000; // The max Length of the current line text in pixels maxLineLength = 270; // The max amount of lines that can be displayed in the textbox maxNumberOfLines = 3; This textbox engine offers many options for customization! Some examples // To change the continue sprite continueSprite = “ mysprite“; spriteX = 20; spriteY = 40; // To change the textbox image background = “mybackground”; // To increase the default speed for the textbox characterSpeed = 5; // To change where the word wrapping will occur maxLineLength = 150; // To the number lines to be displayed in the textbox maxNumberOfLines = 2; Step 3: Add the following code to the Create Event for the objtextbox. //////// No need to edit these! //////////// // The full text being displayed.
This is default text. Text = “This is some default text for the textbox”; // Text for type writer effect typeText = “”; // Location of the current character in the string. Text2 = ‘a’ textPosition = 0; // The current line number of the text lineNumber = 1; // The current line Text. No need to change this lineText = “”; No need to edit any of these variables!
Step 4: Create a new script called textbox. This script will drawn the textbox on screen. Feel free to edit these values as needed!