TheClansman Posted May 20, 2015 Share Posted May 20, 2015 Hello! I am newbie to game development and i chose the phaser to learning. My question is how to make the setting the scenary and personage to behave for the top view, as the example image below. Only managed to make the scenario behave horizontally, like the Mario Bros. could help me? Greetings from Brazil! : D Link to comment Share on other sites More sharing options...
ForgeableSum Posted May 21, 2015 Share Posted May 21, 2015 Hi Clansman and welcome to Phaser. There are two things that contribute to making the horizontal screen scroll and top/down perspective. The first is gravity. By default, sprites that are physics enabled will have gravity turned on, so they will move in such a way that the top part of the screen is the sky and the bottom part is the ground (the way you would want to have it in a 2D screen-scroll game). To disable this, you need to turn off the sprite's gravity:sprite.enableBody = true;sprite.body.allowGravity = false;Make sure that the sprite is physics-enabled and has a body before you do that of course. If your sprite is not physics-enabled, there is no need to turn off gravity. The other thing which affects the top/down vs horizontal perspective is the artwork itself. In the screenshot you posted, the artwork is drawn in the isometric or dimetric perspective. This means that the camera is positioned not directly on top of the characters (what would be a full top-down game) but also not directly across from the characters (what would be a 2D screen-scroll perspective). Instead, the camera is somewhere in-between. This is a common perspective in game dev because it allows the viewers to see a large number of angles all at once. So, once you've got gravity disabled, it's just a matter of making sure the artwork is in the correct perspective. That's it! Link to comment Share on other sites More sharing options...
drhayes Posted May 21, 2015 Share Posted May 21, 2015 You should also check out the Phaser.Group#sort method. The example in the documentation even calls out a Zelda-like RPG as an example. Link to comment Share on other sites More sharing options...
Recommended Posts