Jump to content

How to determine the coordinates of the textures in the Atlas?


Ivasik
 Share

Recommended Posts

How to determine the coordinates of the textures in the Atlas,  to easily make an animation of 10 and more images ?

My code:

{"frames": [

{
	"filename": "gems.swf/0000",
	"frame": {"x":19, "y":12, "w":129, "h":129},
	"rotated": false,
	"trimmed": true,
	"spriteSourceSize": {"x":0, "y":0, "w":129, "h":129},
	"sourceSize": {"w":129, "h":129}
},

{
    "filename": "gems.swf/0019",
    "frame": {"x":0, "y":1355, "w":447, "h":412},
    "rotated": false,
	"trimmed": true,
	"spriteSourceSize": {"x":-14, "y":-2, "w":447, "h":412},
	"sourceSize": {"w":447, "h":412}
}],
"meta": {
	"version": "1.0",
	"image": "textures.png",
	"format": "RGBA8888",
	"size": {"w":1072,"h":1756},
	"scale": "1",
	"smartupdate": "$TexturePacker:SmartUpdate:c510ff2f709e8d175b059cd1cbe64773$"
}
}

 

Link to comment
Share on other sites

5 minutes ago, rich said:

I don't understand the question. The point of a texture atlas is that each frame is its own entry in the atlas, and has its own unique filename, so you can reference that from your code.

 Explain easier, I have a picture(attached). How to find the coordinates of the red, blue, green rectangles?

Screenshot_3.png

Link to comment
Share on other sites

Give them images correct file names before you pack them in atlas (blue.png, red.png, green.png) then you can reference them with that names. 

// (x, y, atlas_key, name_of_image_in_atlas)
this.mySprite = this.game.add.sprite(0, 0, 'atlas_key', 'name_of_image_in_atlas');

 

Link to comment
Share on other sites

3 minutes ago, lukaMis said:

Give them images correct file names before you pack them in atlas (blue.png, red.png, green.png) then you can reference them with that names. 

So if I call a separate file "blue.png", "green.png", throw them in satin and after specifying their name, I don't have to enter the coordinates of their location? I understood you correctly?

Link to comment
Share on other sites

Lastly I wanted to ask, there is a code:

        musics = new Array ('Main_Theme', 'Main_Theme1', 'Main_Theme2', 'Main_Theme3', 'Main_Theme4', 'Main_Theme5');
        random = Math.floor(Math.random() * musics.length);
        music = this.game.add.audio(musics[random]);
        music.play();

As at the end of the music again to make a mixed music and playing?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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