Jump to content

Sprite dimensions


sergil
 Share

Recommended Posts

When in the preload I use the code:

this.load.image('tank_GREEN' , 'assets/sprites/tank-green.png', 120, 120 ); 

when I create a extended sprite that automatically moves vertical using a sinusoidal waveusing:

this.posX = game.rnd.integerInRange(60 + this.maxwaveSize, game.width - 60 - this.maxwaveSize);this.posY = game.height + 50;Phaser.Sprite.call(this, game, this.posX, this.posY, 'tank_GREEN');this.anchor.setTo(0.5, 0.5); 

how can I know the size of the preloaded image to automate the 60 in this.posX?? 

 

Now, I'm making a game prototype and not knowing the size of the sprite, makes me manually change the code if latter I change the final sprite size

 

Thanks

Link to comment
Share on other sites

ok actually I'm working with multiple images but in final development I was thinking on moving all of this to a texture atlas... using a texture atlas, I think that the json contains the x,y width and height of every image? 

 

How do you have a single sprite texture height and with from a texture atlas?

 

Thanks

Link to comment
Share on other sites

  • 4 years later...

Hello 
Well i have a texture atlas with some sprite. I add in stage the sprite like this: this.testImage = new Phaser.Sprite(this.game, 0, 0, 'atlas', 'test');
this.gameContainerGroup.add(this.testImage); 
Now need in my code to use the texture of this sprite. When i write this.testImage.texture shows me the whole atlas.

Please need a help anyone can help what can i do?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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