Почему у меня stage.height / width равен 0 при использовании Pisi JS? - PullRequest
0 голосов
/ 01 мая 2020

В настройке функции значение app.stage.height равно 0. Почему? Есть текст для валидатора (zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz)

       let Application = PIXI.Application,
            Container = PIXI.Container,
            loader = PIXI.loader,
            resources = PIXI.loader.resources,
            TextureCache = PIXI.utils.TextureCache,
            Sprite = PIXI.Sprite,
            Rectangle = PIXI.Rectangle;

        let app = new Application({ 
            width: 512, 
            height: 512,                       
            antialias: true, 
            transparent: false, 
            resolution: 1
          }
        );

        document.body.appendChild(app.view);

        loader
          .add("/img/treasureHunter.json")
          .load(setup);

        function setup() {
          console.log(app.stage.height)

          let id = PIXI.loader.resources["/img/treasureHunter.json"].textures;
          let dungeon = new Sprite(id["dungeon.png"])
          let treasure = new Sprite(id["treasure.png"]);
          let explorer = new Sprite(id["explorer.png"]);
          explorer.y = app.stage.height / 2 - explorer.height / 2;
          console.log(app.stage.height)
          explorer.x = 68;


          app.stage.addChild(dungeon);
          app.stage.addChild(explorer);
          app.stage.addChild(treasure);
        }
...