Jump to content

Need help atlasxml


newtohtml5
 Share

Recommended Posts

var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update });
  

    function preload() {        
    this.game.load.atlasXML('mysprite', 'sprites.png', 'sprites.xml');
        
     }   
    function create() {    

this.sprite = me.game.add.sprite(20, 20, 'mysprite');
this.sprite.animations.add('Left',["Left0000","Left0001"], 5, true);
this.sprite.animations.play('Left');

     } 

    function update() {

    
      
             }

So this is my code,and it doesn't work,black screen only,what am i doing wrong?(mozilla newest browser in-use)

Link to comment
Share on other sites

1 hour ago, Tom Atom said:

In this short example, what is "me" in:


me.game.add.sprite(20, 20, 'mysprite');

typo?

Thank you for your answer,now i can see the atlas map on the mozilla,but no animations being played this time,ah also,when i refresh i can't see anything,it wants me to drag the index.html to mozilla to be able to see,why is that?

Link to comment
Share on other sites

There is really nasty issue with Firefox. I spent lot of time in past while investigating it. Here is detailed description:

 It was not agreed as bug and in fact, it is not Phaser bug. It is bad behavior of Firefox, but it lasts already for long time. Since time I found it, I am patching all Phaser releases to avoid this. Go to file Loader.js and locate method loadImageTag() (https://github.com/photonstorm/phaser/blob/master/src/loader/Loader.js#L2175) In the end of method comment out this piece of code:

        // Image is immediately-available/cached
        if (file.data.complete && file.data.width && file.data.height)
        {
            file.data.onload = null;
            file.data.onerror = null;
            this.fileComplete(file);
        }

 This is what causes problem in Firefox.

 

Link to comment
Share on other sites

6 hours ago, Tom Atom said:

There is really nasty issue with Firefox. I spent lot of time in past while investigating it. Here is detailed description:

 It was not agreed as bug and in fact, it is not Phaser bug. It is bad behavior of Firefox, but it lasts already for long time. Since time I found it, I am patching all Phaser releases to avoid this. Go to file Loader.js and locate method loadImageTag() (https://github.com/photonstorm/phaser/blob/master/src/loader/Loader.js#L2175) In the end of method comment out this piece of code:


        // Image is immediately-available/cached
        if (file.data.complete && file.data.width && file.data.height)
        {
            file.data.onload = null;
            file.data.onerror = null;
            this.fileComplete(file);
        }

 This is what causes problem in Firefox.

 

And what about not playing the animation?what do you think causing that problem?

Link to comment
Share on other sites

Quote

And what about not playing the animation?what do you think causing that problem?

It is hard to say. But it is almost sure, it is something on your side (depsite that browser problem). Check console output for errors, make sure that your frame names has the same letter cases, ... If you can put your project as .zip package on dropbox (or smoewhere), I can help.

Link to comment
Share on other sites

Console says "TypeError: this.currentFrame is undefined"
Current code:
 

var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update });
  


    function preload() {   

      
    game.load.atlasXML('mysprite', 'sprites.png', 'sprites.xml');
        
     }   



    function create() {    

   var sprite = game.add.sprite(20, 20, 'mysprite');
  sprite.animations.add('Left',Phaser.Animation.generateFrameNames('Left000', 0,1),false,false);
   sprite.animations.play('Left',15,true);

     } 

    function update() {

  
      
         
     }

 

sprites.png

sprites.xml

Link to comment
Share on other sites

 There is something rotten in your atlas XML. What program it was created in? Problem is that Phaser expects "SubTexture" in code instead of "subtexture" tag, otherwise it reads 0 frames. Try to change lettercasing in your xml to SubTexture for first openning and closing tag and it reads one frame. Then add this line to your code (instead of your current create method):

var sprite = game.add.sprite(20, 20, 'mysprite','Right0001');

 It will show first frame.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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