LoginSignup
4
3

More than 5 years have passed since last update.

PIXI.jsでテキストの折り返しを行う

Posted at

PIXI.jsは他のフレームワークに比べてテキストの設定が比較的充実しているが、オプションが多い為にわかりずらい。

テキストの折り返しを行うには以下の3つのプロパティを設定する必要がある

  • wordWrap
    単語の折り返しを行うかどうか、これがtrueになっていないと以下の2つのオプションは動作しない

  • wordWrapWidth
    折り返しをする際のwidth(幅)を設定する。但し、単語の折り返しである為、単語がもの凄く長かったとした場合は折り返しされない。

  • breakWords = true;
    単語が長かったとしても折り返すオプション

var style = {
  font:'12pt Arial',
  fill:'white',
  wordWrap:true,
  wordWrapWidth:100,
  breakWords: true
};
  var t  = new PIXI.Text('', style);
  t.wordWrap = true;
  t.wordWrapWidth = 100;
  t.breakWords = true;
4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3