blackgames Posted March 20, 2014 Share Posted March 20, 2014 Hi at all, I can't figure out how to scale correctly.I have a sprite with a size of 2300 x 600 pixel. I want to dynamically scale the logo-sprite in proportion to the screen-size.now I'm doing this so that I change the width and height: from the memory: logo = game.add.sprite(0, 0, 'logo')logo.width = game.world.width - logo.width / 4 it works well. In the examples it's shown that it is worked with scaleTo...that works too, but not when changing the size expample:Screen width = 600It works with logo.scaleTo(0.25, 0.25)but with a screen-width off 200 isnt it dynamically. how is it in phaser provided? Unfortunately, my other question is really stupid, and I'm sorry for that:How I read the documentation correctly? in the upper example i create a sprite and I can use the method scaleTo.But there ist no entry in the docs for sprites. http://docs.phaser.io/Phaser.Sprite.htmlwhere can I find the method? this is also true for the other things I apologize once again for the newbie question Thanks for your time reading this. Link to comment Share on other sites More sharing options...
jyapayne Posted March 20, 2014 Share Posted March 20, 2014 I can answer your first question. You need to find the factor to scale by. When you call logo.scaleTo(0.25, 0.25), you are telling phaser to scale the sprite by 1/4th by x and y. It doesn't automatically scale by screen size. So what you could do is this:var scalex = (game.camera.width - logo.width/4)/2300;var scaley = (game.camera.height - logo.height/4)/600;logo.scale.setTo(scalex, scaley);and that should make it so that the logo is always within the bounds of the camera, even if your world size is larger than normal. Link to comment Share on other sites More sharing options...
blackgames Posted March 21, 2014 Author Share Posted March 21, 2014 Thank you jyapayne, I will test this! can someone explain to me how the documenation is read? I'm sorry, but i dont understand this. Link to comment Share on other sites More sharing options...
Recommended Posts