How Do I Remove an object on click?
How can you destroy an object on click in Phaser 3? What if you have many objects on the stage? With this code, the object clicked gets passed to the function and destroyed
How can you destroy an object on click in Phaser 3? What if you have many objects on the stage? With this code, the object clicked gets passed to the function and destroyed
One of the most useful features of Flash/Actionscript was the ability to dispatch custom events. Phaser does have an event class built-in and with a little ES5 magic, we can easily create a global messaging system. This post is part of a series of building a platform game in Phaser 3. You can find the …
I’m sure that some of you may be nostalgic for the days of youth when the Nintendo NES was the most popular game system on the planet. My first video game was pong, which was followed quickly by the Atari 2600. I saw the Nintendo controller a bit of a breakout. The way it was …
intro The Problem Sometimes, the bounding box of the hit area is not the size that we need. This can cause problems with collisions. In the example below, even if the ninja was able to dodge an obstacle, without such a big hit area (shown in purple around the ninja), the player is sure to …
When I was building virtual worlds in Flash/As3 it took quite a bit of maths to make the background scroll. And then to scroll only when the avatar wasn’t near the edge of the world. Phaser’s built-in camera class makes this all very easy and quick. This code continues to build on the code we …
Platform games have been a staple in video games since Mario Brothers came along in the early 80’s. Because the framework gives us a lot of code to work with, setting Up Phaser 3 platform games isn’t too difficult. There are a lot of 3rd party tools to help you do this, but I’m going …
When animations contain a lot of images and have a lot of animations it is easier to use JSON Animations. This is an update from my old Phaser 2 post. Software The software I use to create animations is called Texture Packer. They have both paid and free versions. You’ll only need the free version …
In the last post, I showed how you can use gravity and velocity together to make a sprite jump. In this post, we will add a jump meter to the project to show the user just how much power they will use. This project uses the Utility Template. Making the meter image The first thing …
In last week’s post, we explored how to use gravity in Phaser 3. Now we will defy that gravity and make the ball jump. We can do this by setting the velocity of the ball to counteract the gravity. So far in the code, we’ve set up a ball that falls until it collides against …
Making objects hit the ground One of the great things about Phaser is the physics engines that you can use with it. In this post, I’ll show you how to use gravity on an an object. I’ll be using the Utility template to set this up. Although we don’t need any of the features for …