如何在没有舞台的情况下使用pixi.js?

Bet*_*ide 7 javascript pixi.js

我有这个pixi.js代码,它做了它应该做的事情:绘制一个矩形.

   var stage, renderer, graphics;

    (function () {
      // init PIXI
      // create an new instance of a pixi stage
      stage = new PIXI.Stage(0x66FF99);

      // create a renderer instance.
      renderer = PIXI.autoDetectRenderer(400, 300);

      $('#pixi-area').append(renderer.view);

      graphics = new PIXI.Graphics();
      graphics.beginFill(0xFFFFFF);
      graphics.lineStyle(1, 0xFF0000);
      graphics.drawRect(20, 20, 150, 150);
      stage.addChild(graphics);
      renderer.render(stage);
    }());
Run Code Online (Sandbox Code Playgroud)

但是,在控制台中我得到了声明

You do not need to use a PIXI Stage any more, you can simply render any container.
Run Code Online (Sandbox Code Playgroud)

如果不使用我该怎么做PIXI.Stage()呢?

Mat*_*v92 9

我其实刚遇到同样的问题!我最终找到了PIXI的新文档,可以在http://pixijs.github.io/docs/index.html找到.

它们引用的容器是为替换Stage对象而引入的新对象.http://pixijs.github.io/docs/PIXI.Container.html#toc1

stage = new PIXI.Stage(0x66FF99)

现在变成,

var container = new PIXI.Container();

希望这可以帮助!:)