digitsensitive Posted April 27, 2018 Share Posted April 27, 2018 Hello there! I am not sure if there is already a function to center a text (f.e. BitmapText)? If not, this might be helpful. The function could be quite simple I guess (not tested): getCenterX: function () { return sys.canvas.width / 2 - this._bounds.global.width / 2 } EDIT (28.04.2018): Just saw that there is a getCenter() function in the GetBounds component. Maybe BitmapText could extend GetBounds too? Link to comment Share on other sites More sharing options...
b10b Posted April 28, 2018 Share Posted April 28, 2018 Slight optimization in case you're doing a LOT of them: getCenterX: function () { return ( sys.canvas.width - this._bounds.global.width ) * .5 } digitsensitive 1 Link to comment Share on other sites More sharing options...
digitsensitive Posted April 28, 2018 Author Share Posted April 28, 2018 @b10b Absolutely, thank you. Link to comment Share on other sites More sharing options...
Recommended Posts