Jump to content

Some sprite/texture problems with atlasJSONArray and animations.add()


Recommended Posts

Well i'm updating old Phaser code to 1.0


Well some renaming and function moved to new objects and so on I'm a bit stuck here:

function preload() {    myGame.world.setSize(320, 416);    myGame.load.image('logo', 'assets/images/logo.png');    myGame.load.image('bg', 'assets/images/bg_prerendered.png');    myGame.load.atlasJSONArray('tiles', 'assets/textureAtlas/breakout.png', 'assets/textureAtlas/breakout.json');}function create() {    myGame.add.sprite(0, 0, 'bg');    paddle = myGame.add.sprite(myGame.world.width / 2, myGame.world.height - 48, 'tiles');    paddle.animations.add('paddle_big', ['paddle_big.png'], 10, false, false);    paddle.animations.add('paddle_small', ['paddle_small.png'], 10, false, false);}

And the error that hit's me is :


  1. Uncaught TypeError: Cannot read property 'uuid' of null phaser.js:20495
    1. Phaser.AnimationManager.addphaser.js:20495
    2. Phaser.StateManager.loadCompletephaser.js:7851
    3. Phaser.Game.loadCompletephaser.js:10273
    4. Phaser.SignalBinding.executephaser.js:8426
    5. Phaser.Signal.dispatchphaser.js:8312
    6. Phaser.Loader.nextFilephaser.js:23026
    7. Phaser.Loader.jsonLoadCompletephaser.js:22920
    8. _xhr.onload



What i checked is that: 


paddle.animations.add('paddle_big'); - works, but there isn't a frame name specified


paddle.animations.add('paddle_big', [1], 10, false, false); - agian works but is hard to tell what frame is 1,2,3, etc.


So I suppose that there is new way of doing this but I'm stuck on this from one hour and decided to share my frustration.


I checked old examples TS, and all news examples which are so little compared with TS examples so I'm offering to convert some of the old ones

to 1.0 because I'll gain some more knowledge too but first I must pass the atlas texture problem. :)

Link to comment
Share on other sites

Hi Rich,


First to say i checked the other topic but as i said:


paddle.animations.add('paddle_big',[0,1,2,3,4,5], 10, true, false);


This doesn't look as good solution to me, when once it worked with frame names. :P


I've attached the files (the json is a .txt cause) :)

  • breakout.json

    You aren't permitted to upload this kind of file

It's 100% valid json file, cause i checked it: http://jsonlint.com/ and also it works with the older phaser version.


Also I tried:


myGame.load.atlasJSONHash('tiles', 'assets/textureAtlas/breakout.png', 'assets/textureAtlas/breakout.json');


Cause the name implies something... still the same result...


And tnx for the game.world.centerX TIPS i saw them in the examples but didn't bother to change since this part was the working one... :P 


Also I'm still digging this myself if I found something I'll sure post it here 



Link to comment
Share on other sites

I wanted to see the json to find out if it was a hash or array, as array is the default type assumed, but you've got a hash file there so it wouldn't have found any frames when it was being parsed. You can still pass an array of filenames for an animation, that hasn't changed. I'll test it shortly.

Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...