Jump to content

resize a sprite to fill the screen


dcsan
 Share

Recommended Posts

I'm a bit new to phaser so forgive me if these are obvious:

 

It seems sprite tween resize is all relative, eg 2X

based on the size of the original bitmap it was based on

 

is there a way to scale a sprite to fill the screen exactly?

 

I can only think of 

- finding the original size of the sprite (not sure what the API for that is)

- find screensize

- screensize / bitmapsize = target scale factor

 

I got that working but wonder if i'm missing something.

 

 

  onDown: () ->    # tweener = game.add.tween(@sprite).to( {x:400, y:400},1000 )    BITMAP_SIZE = 10 # original bitmap    newSize = {      x: @state.game.width / BITMAP_SIZE      y: @state.game.height / BITMAP_SIZE    }    # newSize = {x:10, y: 10}    console.log("onDown", newSize)    tweener = game.add.tween(@sprite.scale).      to(newSize, 100, Phaser.Easing.Linear.None, true, 0, 0, true )

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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