Phaser API Documentation

setWordWrapCallback(callback, [scope])


Set a custom callback for wrapping lines.

Pass in null to remove wrapping by callback.


name type arguments Default description
callback TextStyleWordWrapCallback

A custom function that will be responsible for wrapping the text. It will receive two arguments: text (the string to wrap), textObject (this Text instance). It should return the wrapped lines either as an array of lines or as a string with newline characters in place to indicate where breaks should happen.

scope object <optional> null

The scope that will be applied when the callback is invoked.


The parent Text object.

Since: 3.0.0