Sign in to follow this  
sombriks

how to scale image before use it on tilesprite?

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

Share this post


Link to post
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.

Share this post


Link to post
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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.