MaxSixth Posted May 12, 2016 Share Posted May 12, 2016 Hi, everyone, I am new in the framework of the phaser, and I came to ask your help to know how to create a parallax effect equal to the GitHub site when it is not found the page, example here: https://github.com/errorr4frsf wanted this effect between two background images, where the last image moves contrary to the mouse movement. Link to comment Share on other sites More sharing options...
shohan4556 Posted May 12, 2016 Share Posted May 12, 2016 the link you posted here is not found Link to comment Share on other sites More sharing options...
Milton Posted May 12, 2016 Share Posted May 12, 2016 15 minutes ago, shohan4556 said: the link you posted here is not found That's the point Move your mouse and see the effect. Link to comment Share on other sites More sharing options...
drhayes Posted May 13, 2016 Share Posted May 13, 2016 Well, first you have to track the mouse and get its x and y. You then create some graphics and lay them on top of each other. Let's call them A, B, and C. A moves the most when you move the mouse, probably a ratio like -0.7 * x. That means it'll move in the opposite direction of the mouse, but not by as much. B moves the least, maybe -0.2 * x. C moves maybe 0.4 * x, so it looks like everything pivots on a point near B somehow. You'll have to play with this and probably offset it from the center of the graphics, but that's the gist. MaxSixth and shohan4556 2 Link to comment Share on other sites More sharing options...
MaxSixth Posted May 14, 2016 Author Share Posted May 14, 2016 On 13/05/2016 at 11:53 AM, drhayes said: Well, first you have to track the mouse and get its x and y. You then create some graphics and lay them on top of each other. Let's call them A, B, and C. A moves the most when you move the mouse, probably a ratio like -0.7 * x. That means it'll move in the opposite direction of the mouse, but not by as much. B moves the least, maybe -0.2 * x. C moves maybe 0.4 * x, so it looks like everything pivots on a point near B somehow. You'll have to play with this and probably offset it from the center of the graphics, but that's the gist. That was my doubts even thank you! now I understand how it works this logic. So the secret is just taking control of the mouse and so apply this logic? Link to comment Share on other sites More sharing options...
drhayes Posted May 16, 2016 Share Posted May 16, 2016 I'd try that first, yeah. Link to comment Share on other sites More sharing options...
Recommended Posts