In the snippet below, we create a sample object with the Isometric plug-in. We will just use the objects from the isometric library, instead of standard Phaser.js objects. In this section as you probably remember from the first Phaser article on, we create our game scene. Now we will move to the create function of the Phaser game engine. That is all for the preload function of the Phaser game engine. ('characterAnim', 'images/tiles/characterAnim.png', 70, 74) ('cactus2', 'images/tiles/obstacle2.png') ('cactus1', 'images/tiles/obstacle1.png') Later they will be used to assign assets to their isometric representations. The most important are the internal names of the loaded assets – “cactus1”, “cactus2”, “rock”, ”characterAnim”, etc.
#How to set background in phaser 3.0 code#
You upload them to the game engine like shown in the code snippet below. As in a standard Phaser.js setup we have two types of assets - animated and static assets. In the preload section of the Phaser game engine we will also have to load up the graphical representations of the tiles in our isometric world. set the middle of the world in the middle of the screen Setting the () function gives us the ability to put the center of our isometric world in a specific point of the screen in relation to the Phaser camera. The last line may not look like important, but it is. That is why in the next line we are enabling the physics system. Also we want to have some physics in our game, for example moving obstacles. The two last parameters are the width and height of the world. The first two parameters are the starting points of the world (x and y), so we want to keep them at the 0 value.
![how to set background in phaser 3.0 how to set background in phaser 3.0](https://cascade.madmimi.com/promotion_images/3928/5167/original/makingfirstgame.png)
Next we are setting the bounds of the world by using the () method. As you can see as a parameter we pass a new instance of the Isometric engine, which in turn takes our Phaser game object as a parameter. As you can see below, in the preload function of the Phaser game engine we have put the () function which is used to actually import the isometric system into the Phaser game engine. Having done that, we can start writing our setup code in JavaScript. Remember to put the Isometric plug-in import line after the Phaser.js import line. In our case the Isometric plug-in into our project into the HTML document. The first thing to do is, as always, to import the library. Then we will focus here only on the Isometric plug-in setup and features.
#How to set background in phaser 3.0 how to#
We describe also how to check collisions using the Phaser physics system and overlapping with collectible items.Īs this article is based on Phaser.js and there is an existing article on about setting up Phaser.js. Create tiles for the world and obstacles. You will also learn how to setup the Isometric plug-in in Phaser.js. 1) attached to this article, which was developed using the Tizen SDK 2.3 (rev2).įigure 1 – The PhaserIso.wgt sample application using Phaser.js with the Isometric plug-in
![how to set background in phaser 3.0 how to set background in phaser 3.0](https://phaser.io/content/news/2018/07/phaser-3110-released-tilemap.png)
And it is covered in the sample application PhaserIso.wgt (fig. We also show you how to use the plug-in with the Phaser.js library to create a simple wild west like world with a hero, some items to collect and an exit point. That is why in this article we present you the isometric plug-in for the Phaser game engine, which was earlier described in this article.
![how to set background in phaser 3.0 how to set background in phaser 3.0](https://phaser.io/content/news/2020/12/phaser-350-released6.png)
But is it really necessary in times when the web is just bursting with web frameworks for HTML5 games? You can always write your own isometric game engine.
![how to set background in phaser 3.0 how to set background in phaser 3.0](https://media.springernature.com/lw685/springer-static/image/art%3A10.1038%2Fs41467-021-27075-0/MediaObjects/41467_2021_27075_Fig1_HTML.png)
Have you ever wondered how to create an isometric world for your game? Is it difficult? What needs to be done in order to have a world like, for example, in the popular Zelda game series? The answer is easy.