Jump to content

how does one link a sprite sheet with a sprite map?


Le Twitch
 Share

Recommended Posts

The term you're looking for is 'texture atlas', as demonstrated here: http://examples.phaser.io/_site/view_full.html?d=animation&f=starling+atlas.js&t=starling%20atlas

 

A sprite sheet in Phaser is specifically an image without a data representation; the frames are laid out in order and of a fixed size so they can be parsed programmatically instead, as a 'strip' of frames for instance.

Link to comment
Share on other sites

The term you're looking for is 'texture atlas', as demonstrated here: http://examples.phaser.io/_site/view_full.html?d=animation&f=starling+atlas.js&t=starling%20atlas

 

A sprite sheet in Phaser is specifically an image without a data representation; the frames are laid out in order and of a fixed size so they can be parsed programmatically instead (i.e. a 'strip' of frames for instance)

 

that's a really nice example. thanks!

Link to comment
Share on other sites

The term you're looking for is 'texture atlas', as demonstrated here: http://examples.phaser.io/_site/view_full.html?d=animation&f=starling+atlas.js&t=starling%20atlas

 

A sprite sheet in Phaser is specifically an image without a data representation; the frames are laid out in order and of a fixed size so they can be parsed programmatically instead, as a 'strip' of frames for instance.

 

would this be correct?

 

this.load.atlasJSON('colourSquare', 'images/colourSquares.png', 'images/colourSquares.json');var squareA = this.add.sprite(0, 409, 'colourSquare');squareA.frame = 5;var squareB = this.add.sprite(730, 409, 'colourSquare');squareB.frame = 0;
Link to comment
Share on other sites

 

The atlas will have names for each frame, so you can use these - for instance, if one of the items in the atlas is called 'red' then you'd do it like this:

var squareA = this.add.sprite(0, 409, 'colourSquare', 'red');

 

ahhh okay. thanks =]

Link to comment
Share on other sites

 

The atlas will have names for each frame, so you can use these - for instance, if one of the items in the atlas is called 'red' then you'd do it like this:

var squareA = this.add.sprite(0, 409, 'colourSquare', 'red');

 

this is exactly what i've done and it still doesn't work

preload: function() {  this.load.atlasJSON('colourSquare', 'images/colourSquares/colourSquares.png', 'images/colourSquares/colourSquares.json');}create: function() {  var squareA = this.add.sprite(0, 409, 'colourSquare', 'red');  var squareB = this.add.sprite(730, 409, 'colourSquare', 'blue');}
Link to comment
Share on other sites

Can you paste the contents of colourSquares.json in please?

 

i made this with http://www.leshylabs.com/apps/sstool/

[{"name":"red","x":0,"y":0,"width":230,"height":230},{"name":"blue","x":231,"y":0,"width":230,"height":230},{"name":"yellow","x":0,"y":231,"width":230,"height":230},{"name":"green","x":231,"y":231,"width":230,"height":230},{"name":"orange","x":0,"y":462,"width":230,"height":230},{"name":"purple","x":231,"y":462,"width":230,"height":230}]
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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