Durden Posted August 22, 2016 Share Posted August 22, 2016 Hey, I've been learning my way around Phaser for a week for a personal project, I resolved almost every bug I had until now with older posts from this forum (thanks A LOT to all of you), but I'm stuck with one I found no solution for. I have 8 "information signs" I want to add to the background in different places, all looking alike but with slight changes to each (basically, the text on each sign is different). I made a spritesheet with all 8 signs, preloaded it, and then I added some of the signs like this : var skillsSign = this.game.add.sprite(80, 20, 'guidance'), experienceSign = this.game.add.sprite(this.game.width - 64 - 90 - 16, 20, 'guidance'), contactSign = this.game.add.sprite(this.game.width - 90, this.game.height - 128 - 40, 'guidance'), formationSign = this.game.add.sprite(0, this.game.height - 128 - 40, 'guidance'); skillsSign.frame = 1; experienceSign.frame = 5; contactSign.frame = 6; formationSign.frame = 7; //problem is with this one The first three work as intended, but the last one, which is the last of the sprites in the spritesheet, appears as the first. I can put 0 instead of 7 in the last statement and get the same result. I checked, every single sign is working as intended, except this 8th sprite appearing as the 1st. Any idea what causes this ? Also, if that's not at all the best way to go for what I want to do, I'm open to any advices Link to comment Share on other sites More sharing options...
rich Posted August 22, 2016 Share Posted August 22, 2016 Is it definitely a sprite sheet, or is it a texture atlas? Link to comment Share on other sites More sharing options...
Durden Posted August 22, 2016 Author Share Posted August 22, 2016 I think it's a sprite sheet, here's the .png file. Link to comment Share on other sites More sharing options...
rich Posted August 22, 2016 Share Posted August 22, 2016 Looks like a sprite sheet, an atlas is loaded with 'load.atlas' - how are you loading the above? Link to comment Share on other sites More sharing options...
Durden Posted August 22, 2016 Author Share Posted August 22, 2016 This way : this.load.spritesheet('guidance', 'assets/img/tilesheet-guidance.png', 90, 26, -1, 0, 4); (by the way, the .png file's height is 30px, but for some reason if I try to put any number >= 27 instead of 26 in my statement, the sprite sheet freaks out and the page displays the full sprite sheet, I have no clue why it behaves like that) Link to comment Share on other sites More sharing options...
rich Posted August 22, 2016 Share Posted August 22, 2016 Those dimensions (90x26 with 4px spacing) don't match the PNG you posted above, because the final frame in it is only 90px wide (needs to be 94) - if you just add 4px to the png it should be fine. Personally I'd recommend you use texture atlases (avoids issues like this and packs more in!) Link to comment Share on other sites More sharing options...
Durden Posted August 22, 2016 Author Share Posted August 22, 2016 Nice, that solved it. Thanks a lot, I'll also check the texture atlas tutorial Edit: the height problem I spoke about in my last post is still there though, any clue ? Link to comment Share on other sites More sharing options...
Recommended Posts