Jump to content

how to scale image before use it on tilesprite?


sombriks
 Share

Recommended Posts

Hello all,

 

i have a small code on phaser wich needs to parallax two textures at different speeds.

 

i've set the game canvas to transparent mode and my tiles are 1024x512.

 

However, i have the need of resize it according to screen resolution, i.e. apply scale to have a good aspect ratio.

 

how do i do that?

 

here's what i'm seeing. i need to scale it in order to parallax it nicely

 

http://imgur.com/a/swwOI

Link to comment
Share on other sites

UPDATE:

 

http://phaser.io/docs/2.4.3/Phaser.TileSprite.html#tileScale

 

tried tileScale, but i'm missing something.

          var s = game.add.tileSprite(0, 0, op.w, op.h, data.img);          s.tileScale.set(512/op.h,512/op.h);          data.left=function(){              game.add.tween(s.tilePosition).to({x:"+100"},666).start();          };          data.right=function(){              game.add.tween(s.tilePosition).to({x:"-100"},666).start();          };

data.img have 1024x512 as dimensions, and i tried to use it agains canvas height in order to generate a good proportion but it still seems strange

 

 

UPDATE2:

 

changed 

 

s.tileScale.set(512/op.h,512/op.h);

 

to

 

s.tileScale.set(op.h/512,op.h/512);

 

and now it's better, much better.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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