【发布时间】:2016-08-11 04:01:45
【问题描述】:
我正在尝试在 atlas 中随机添加 5 个图像中的 1 个,但它们都显示为一个在另一个之上,有没有办法解决这个问题?基本上我希望每次运行我的关卡时显示的精灵中的 1 个可以是 5 个中的任何一个,但我得到的只是同时显示的全部 5 个。
///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": [
{
"filename": "amarillo.png",
"frame": {"x":0,"y":0,"w":188,"h":200},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":188,"h":200},
"sourceSize": {"w":188,"h":200}
},
{
"filename": "azul.png",
"frame": {"x":188,"y":0,"w":240,"h":200},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":240,"h":200},
"sourceSize": {"w":240,"h":200}
},
{
"filename": "naranja.png",
"frame": {"x":428,"y":0,"w":162,"h":200},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":162,"h":200},
"sourceSize": {"w":162,"h":200}
},
{
"filename": "rojo.png",
"frame": {"x":590,"y":0,"w":190,"h":200},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":190,"h":200},
"sourceSize": {"w":190,"h":200}
},
{
"filename": "rosa.png",
"frame": {"x":780,"y":0,"w":231,"h":200},
"rotated": false,
"trimmed": false,
"spriteSourceSize": {"x":0,"y":0,"w":231,"h":200},
"sourceSize": {"w":231,"h":200}
}],
"meta": {
"app": "http://www.codeandweb.com/texturepacker",
"version": "1.0",
"image": "monsters.png",
"format": "RGBA8888",
"size": {"w":1011,"h":200},
"scale": "1",
"smartupdate": "$TexturePacker:SmartUpdate:41785e106df91b6daf42364753f15c41:5fca3c08999ac8d93eabfac98fafaf65:8fc4d3ec51ba7bc700054b5f64cf62b1$"
}
}
【问题讨论】:
标签: phaser-framework