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

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...