Placing text (or any object) on middle of scene

I have text object that I want to display in middle of scene. If it would be static text, there would be no problem as I’d just place it in right place, but text will be dynamic (game status messages) and will vary in length. Also since I’m using text object, it should be applicable to any type of object like sprite or anything else.

If you want you can do it without a text object, only with the text help in “Scene Actions”… but with the text object too.
You know the size and font of your text, so wit the lenght of the text you can have about how many pixels measured as each letter.

So, put an event without conditions or “Always” conditions, and in the actios put “Text object” ==> “Text” ==> “Modify the text”, and set this value with a variable, the variable that you want it shows in the game, for example, the “Life” variable.
In the same event put other action, “All objects” ==> “Position” ==> “Position of an object”, the object is the text object, in “X position” put the special value “Camera” ==> "X position of camera " and “Width of a camera of a layer” put your camera and your layer and divide (/) for 2, minus (-) the width of the text in the “Object propierties” ==> “All objects” ==> “Size” and divide (/) for 2.
In the “Y position”, something like this, summarizing: Set y position: (“Camera.Y()”)+(“Height of camera”)/2-(“Height of your text”)/2

Note that you can use a layer ( let’s call it “Interface” ), put over the base layer, instead of making the position of the objects relative to CameraX/Y.
In this case, you will just have to put your text on the “Interface” layer and set it position to CameraWidth()/2-YourObject.GetWidth()/2 ; CameraHeight()/2-YourObject.GetHeight()/2. :slight_smile: