grumpygamer Posted April 30, 2015 Share Posted April 30, 2015 Hello fellas,I'm back with yet another simple question that I could not find by searching.Or better, I found a partial answer but does not work. I just need to pick one frame frome the atlas (texturepacker). Here's the file:{"frames": {"zing-a.png":{ "frame": {"x":2,"y":2,"w":62,"h":121}, "rotated": false, "trimmed": true, "spriteSourceSize": {"x":2,"y":2,"w":62,"h":121}, "sourceSize": {"w":66,"h":125}, "pivot": {"x":0.5,"y":0.5}},"zing-b.png":{ "frame": {"x":66,"y":2,"w":88,"h":155}, "rotated": true, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":88,"h":155}, "sourceSize": {"w":88,"h":155}, "pivot": {"x":0.5,"y":0.5}}},"meta": { "app": "http://www.codeandweb.com/texturepacker", "version": "1.0", "image": "INPO-715.png", "format": "RGBA8888", "size": {"w":223,"h":125}, "scale": "1", "smartupdate": "$TexturePacker:SmartUpdate:9bc8cab18fe3249eb226e9c50f7f903a:31d3cc6b4bdded10596863d197bbf0d9:ddeafc3980f111a89339029a9958cb76$"}}Here is where I load the atlas:this.game.load.atlasJSONHash(reference, greatBigImagefile, jsonfile);and here is where I add them to the game:this.game.add.sprite(shipPosition, this.game.world.centerY, reference);I need a specific image inside the atlas (zing-a.png)Other solutions say to abandon jsonHash and use json, but the texturepacker tutorial tells me to use HASH.In another topic I found I had to add .framename, but I get an error before I can get to that line. Thanks! Link to comment Share on other sites More sharing options...
rich Posted April 30, 2015 Share Posted April 30, 2015 game.add.sprite(x, y, 'reference', 'zing-b.png')'reference' is a string that should match exactly the string used when loading the atlas into the cache. The frame name parameter comes from the 'file' property in the json and must match exactly. Link to comment Share on other sites More sharing options...
grumpygamer Posted April 30, 2015 Author Share Posted April 30, 2015 Thanks!can I change that identifier 'zing-b.png' to something more intuitive such as 'ship-front-view' inside the JSON file? Edit: tried that, I get the infamous error"Texture Error: frame does not fit inside the base Texture dimensions [object Object]" Link to comment Share on other sites More sharing options...
rich Posted April 30, 2015 Share Posted April 30, 2015 I would never recommend you edit the json file, because if you ever need to re-export your assets all of your changes are lost. What you should really do is edit the filename of the PNGs in the first place, then re-export the atlas. In Texture Packer you can turn off the ".png" file extension being used, so the frame name would just be "zing-b". Link to comment Share on other sites More sharing options...
grumpygamer Posted May 1, 2015 Author Share Posted May 1, 2015 I've tried a blank document with just this: var game = new Phaser.Game(window.innerWidth, window.innerHeight, Phaser.AUTO, '', { preload: preload, create: create, update:update }); function preload() { game.load.atlasJSONHash('poop', 'assets/images/ships/INPO-715.png', 'assets/images/ships/INPO-715.json'); } function create() { game.add.sprite(0, 0, 'poop', 'zing-a.png'); } function update() { } still getting that error. The json file is the same.How can I fix it? Curiously I'm getting this error even without adding the sprite in create Link to comment Share on other sites More sharing options...
grumpygamer Posted May 1, 2015 Author Share Posted May 1, 2015 Apparently this is caused by Texturepacker's layout algorithm.If I set it to Basic instead of MaxRects, it works.Any clue to what the benefits are for MaxRects? Actually it works even if MaxRects is on as long as "allow rotation" is turned off.So it boils down to texturepacker being buggy. Link to comment Share on other sites More sharing options...
rich Posted May 1, 2015 Share Posted May 1, 2015 MaxRects is fine, but Phaser / Pixi has never supported rotated images. Link to comment Share on other sites More sharing options...
qdrj Posted May 1, 2015 Share Posted May 1, 2015 MaxRects is fine, but Phaser / Pixi has never supported rotated images.Btw are you planning to add this feature? Sometimes it helps to squeeze few more images into atlas. Link to comment Share on other sites More sharing options...
rich Posted May 1, 2015 Share Posted May 1, 2015 Unlikely to be added to Phaser 2. Link to comment Share on other sites More sharing options...
grumpygamer Posted May 1, 2015 Author Share Posted May 1, 2015 Ok thanks for clearing that up. Link to comment Share on other sites More sharing options...
Recommended Posts