나는 atlas에서 5 개의 이미지 중 1 개를 무작위로 추가하려고하는데, 모두 하나를 다른 것 위에 표시합니다.이 문제를 해결할 수있는 방법이 있습니까? 기본적으로 표시 할 스프라이트 중 1 개는 레벨을 실행할 때마다 5 개가 될 수 있지만 원하는 것은 모두 5 개입니다.Atlas Phaser에서 임의의 스프라이트 표시
///Declaration
this.load.atlas('Monsters', 'images/monsters.png', 'images/monsters.json');
////Where I call sprite
this.figuritaspega = this.game.add.sprite(0, 0, 'Monsters');
this.figuritaspega.frame = this.rnd.integerInRange(0,4);
this.figuritaspega = this.game.add.group;
this.figuraarriba = this.add.sprite(1015, 140, this.figuritaspega);
this.figuraarriba.scale.set(0.9 , 0.9);
////.json below
{"frames": [
{
\t "filename": "amarillo.png",
\t "frame": {"x":0,"y":0,"w":188,"h":200},
\t "rotated": false,
\t "trimmed": false,
\t "spriteSourceSize": {"x":0,"y":0,"w":188,"h":200},
\t "sourceSize": {"w":188,"h":200}
},
{
\t "filename": "azul.png",
\t "frame": {"x":188,"y":0,"w":240,"h":200},
\t "rotated": false,
\t "trimmed": false,
\t "spriteSourceSize": {"x":0,"y":0,"w":240,"h":200},
\t "sourceSize": {"w":240,"h":200}
},
{
\t "filename": "naranja.png",
\t "frame": {"x":428,"y":0,"w":162,"h":200},
\t "rotated": false,
\t "trimmed": false,
\t "spriteSourceSize": {"x":0,"y":0,"w":162,"h":200},
\t "sourceSize": {"w":162,"h":200}
},
{
\t "filename": "rojo.png",
\t "frame": {"x":590,"y":0,"w":190,"h":200},
\t "rotated": false,
\t "trimmed": false,
\t "spriteSourceSize": {"x":0,"y":0,"w":190,"h":200},
\t "sourceSize": {"w":190,"h":200}
},
{
\t "filename": "rosa.png",
\t "frame": {"x":780,"y":0,"w":231,"h":200},
\t "rotated": false,
\t "trimmed": false,
\t "spriteSourceSize": {"x":0,"y":0,"w":231,"h":200},
\t "sourceSize": {"w":231,"h":200}
}],
"meta": {
\t "app": "http://www.codeandweb.com/texturepacker",
\t "version": "1.0",
\t "image": "monsters.png",
\t "format": "RGBA8888",
\t "size": {"w":1011,"h":200},
\t "scale": "1",
\t "smartupdate": "$TexturePacker:SmartUpdate:41785e106df91b6daf42364753f15c41:5fca3c08999ac8d93eabfac98fafaf65:8fc4d3ec51ba7bc700054b5f64cf62b1$"
}
}
덕분에 많이 :)이 (this.rnd.integerInRange (0.4) 를) 도움이 내 오류가 속임수를 썼는지 고정. – Rafahc