Jump to content

texture packer problems


Sfora
 Share

Recommended Posts

Hi there i have problems with animations, im using texture packer and exporting to JSON hash, then when im adding animations everything seems to work fine but as soon as i add second animation everything stops working, game is running but animations are not playing, additionally starting frame for my sprite is changing to completely other one. Im using phaser 2,2,2. Here is a minimal code which produce problem.

var game = new Phaser.Game(1024, 768, Phaser.AUTO, '',{ preload: preload, create: create, update: update } );var cursors;var piesbieg;    function preload() {     this.load.image('Sky', 'rzeczy/Sky.png');    game.load.atlasJSONHash('piesrun', 'rzeczy/piesdrobne/dogplis.png', 'rzeczy/piesdrobne/dogplis.json');        }  function create() {game.add.sprite(0, 0, 'Sky');piesbieg = game.add.sprite(500, 430, 'piesrun','pp4.png');    piesbieg.animations.add('walkp',['pp1.png','pp2.png','pp3.png','pp4.png','pp5.png','pp6.png','pp7.png','pp8.png','pp9.png','pp10.png','pp11.png','pp12.png'],30,true,false);piesbieg.animations.add('lewobieg',['pl1.png','pl2.png','pl3.png','pl4.png','pl5.png','pl6.png','pl7.png','pl8.png','pl9.png','pl10.png','pl11.png','pl12.png'],30, true, false);cursors = game.input.keyboard.createCursorKeys(); }         function update() {   if(cursors.right.isDown)   {piesbieg.animations.play('walkp');    }//            if(cursors.right.isUp)   {piesbieg.animations.stop('walkp',true);   }                 if(cursors.left.isDown)   {piesbieg.animations.play('lewobieg');   }             if(cursors.left.isUp)   {piesbieg.animations.stop('lewobieg',true);   }                   if(cursors.up.isDown)   {//piesbieg.animations.stop('lewobieg',true);   console.log('jestudalosie');   }                           }

Any help  ? Thanks in advance :)

Link to comment
Share on other sites

So, its kinda weird to answer to my own post, but while waiting to pass moderation :P i  discovered that problem lies in stoping animation. When i comment lines which stops aniamations then everything works just fine. So maybe there is something wrong with way im starting or stopping my animations?

Link to comment
Share on other sites

So, it seems that i solved that problem. Now im stopping animation on "onUp" key event. But i think that there is still some problem with animation manager or im making some logical error. I think that if i press "right" button animation which is fired here:

if(cursors.right.isDown)        {      piesek.animations.play('walkp');        piesek.x=piesek.x+2;}

should play, but nothing is happening, it looks like stoping other animations somehow blocks playing this animation.

Link to comment
Share on other sites

I dont think it is a problem with Json. Animations play normally. It seems that stopping animations in update function when checking isUp on one key prevent playing other animation for the same sprite.. I think that it is probably Phaser bug. When i stop animation firing function by "onUp" signal everything work ok.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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