TomLeGrand Posted January 16, 2018 Share Posted January 16, 2018 Hi there, Before reading, I want you to know that you can test my little code here : https://jsfiddle.net/TomLeGrand/meL44k5k/ (Arrows to move the player and mousse to aim in a direction) So, I had some problems using the camera.follow (), moveToPointer () and world.scale.set () functions simultaneously. It seems that the world's scaling influence the x and y properties of world's object (like the camera, the input, etc...). To be more specific, I can't use the camera.follow(player), because the player get out from the camera at some point. The only solution I found was to set the x and y camera's values in the update function but now I don't know how I can get a "smooth effect" without using the camera.follow() function. The moveToPointer() method react badly too, the farthest I go, the worst It get, even with game.input.scale.set(). I'll be glad if you can help me to fix the camera and the moveToPointer() methods Link to comment Share on other sites More sharing options...
gauravD Posted January 16, 2018 Share Posted January 16, 2018 Hi Tom. Camera follow has been fixed in a newer version of Phaser. You should update to either phaser-ce or 2.6.2 Because you move the camera around, the pointer's arctan to the player will not be computed correctly if you use the pointer's local (x,y). You need the arctan from the pointer's (x,y) in world coordinates. Passing the world to moveToPointer(), will use the pointer's world coordinates (this is not intuitive, I know). game.physics.arcade.angleToPointer(player, game.input.activePointer, game.world); With these changes in, check out : https://jsfiddle.net/gauravdixitv/tmnen92m/ samme and TomLeGrand 1 1 Link to comment Share on other sites More sharing options...
TomLeGrand Posted January 16, 2018 Author Share Posted January 16, 2018 Great ! This is so cool it's all working as I would ! Thanks a lot But what do you mean by Quote Camera follow has been fixed in a newer version of Phaser. You should update to either phaser-ce or 2.6.2 Am i using a old version of Phaser ? If yes how can I get the newest version ? Link to comment Share on other sites More sharing options...
gauravD Posted January 16, 2018 Share Posted January 16, 2018 Cool Quote Am i using a old version of Phaser ? Your fiddle was using an older version. You can always check what version you are using - Phaser prints it in your console! Quote If yes how can I get the newest version ? Um, depends on how you are including it. It might look like <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/phaser/2.6.2/phaser.min.js"></script> //Or If you have downloaded the source, it could be something like: <script type="text/javascript" src="../libs/phaser/phaser.min.js"></script> You can update to phaser-ce by 1. Grabbing the latest source from https://github.com/photonstorm/phaser-ce and including it in your project ( with something like <script type="text/javascript" src="../libs/phaser/phaser.min.js"></script>) OR 2. Pointing to a newer phaser source with <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/phaser-ce/2.9.4/phaser.min.js"></script> Link to comment Share on other sites More sharing options...
samme Posted January 16, 2018 Share Posted January 16, 2018 11 hours ago, gauravD said: Passing the world to moveToPointer(), will use the pointer's world coordinates (this is not intuitive, I know). You actually just need to pass true there. Link to comment Share on other sites More sharing options...
gauravD Posted January 17, 2018 Share Posted January 17, 2018 11 hours ago, samme said: You actually just need to pass true there. Oh right! I stand corrected Quote * @param {boolean} [world=false] - Calculate the angle using World coordinates (true), or Object coordinates (false, the default) Link to comment Share on other sites More sharing options...
Recommended Posts