سؤال

I have array of 10 sprites and map from

 for (var i = 0; i < 35; i++) {
            this.Map.push([]);
            for (var j = 0; j < 30; j++)
                this.Map[i][j] = (Math.random() * 9) | 0;
        }
هل كانت مفيدة؟

المحلول 2

Ok, I found something. The only good way to do that is putting desired board to canvas with drawImage and then:

var pixiTexture = PIXI.Texture.fromCanvas(canvas);

If size of board is too big, take it into chunks.

نصائح أخرى

assuming you want to create a rectangular map, you could try this:

for(var y = 0; y < this.Map.length; y++) {
  for(var x = 0; x < this.Map[y].length; x++) {
    var sprite = new PIXI.Sprite.fromImage('assets/image.png');
    sprite.position.x = x* tileWidth;
    sprite.position.y = y* tileHeight;

    yourDisplayObjectContainer.addChild(sprite);
  }
}

and then of course, you have to start the renderer. it should display your map then.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top