1
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Pixi.js v4で複数画像のロードを待つ

Last updated at Posted at 2018-01-04

まあ画像以外もいけるんだけど、画像でしか今の所使ったことがない

const loader = PIXI.loader;

// key名と対象画像を設定していく
loader
      .add("img1" , "images/img1.jpg")
      .add("img2" , "images/img2.png")
      .add("img3" , "images/img3.gif");

loader.load((loader, resources) => {
    // ここが呼ばれたときはすでにロード完了なので取り出してつかう
    let img1 = new PIXI.extras.TilingSprite(resources.img1.texture);
    let img2 = new PIXI.extras.TilingSprite(resources.img2.texture);
    let img3 = new PIXI.extras.TilingSprite(resources.img3.texture);
});

よく使う。

ちなみにTilingSpriteスプライトが移動してて警告くらった

// old code
let img1 = new PIXI.TilingSprite(resources.img1.texture);

// new code
let img1 = new PIXI.extras.TilingSprite(resources.img1.texture);

公式のリファレンスも治ってないところがあるみたいね。
2018年1月5日現在は。

1
7
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
1
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?