Setting an out of bounds event in phaser ce

For this post I will be writing about a Phaser ce example that I built around the onOutOfBounds event for sprites. This event will fire if the sprites checkWorldBounds boolean is set to true, and can be used to define some logic that will fire each time a sprite leaves the game world. This event is useful for bringing sprites back to a pool to be reuse again when working with groups, and the example will also cover that as well. In any case this post should give readers a better sense of how to dead with sprites that go out of bounds when making a phaser ce powered game with javaScript.

Read More

Examples of the _.keyby method in lodash

If I am ever in a situation in which I need to create an object with keys that are generated from the properties of objects in an array, or collection in general, I can use the lodash _.keyBy method to make quick work of that if lodash is there to work with in a project. The _.keyBy method works a lot like _.groupBy, and also the _.countBy methods only it will only create one key for each value in a source collection, rather than creating groups as needed for two or more elements that meet a condition, or give a count of elements that meet a condition.

There is also the question of doing what they key by methods does with just a little vanilla javaScript code when it comes to not bothering with lodash and just working with core javaScript also. With that said in this post I will be going over some use case examples of _.keyBy, and some vanilla js alternatives for doing so as well when it comes to doing something like this with just native javaScript by itself.

Read More

A Runner phaser plug-in example

Fot the next few days I would like to have some fun with phaser ce, and make some plug-in examples. In this post I will be covering plug-ins that create the beginnings of a simple runner game. I hope to make a few posts like this where I start writing about how to go about making something that is starting to look like an actual game, rather than just simple demos that do not do much of anything interesting.

Read More

Rotating a sprite from one angle to another in phaser

In many phaser ce projects there will come a time where I will want to rotate a sprite from one angle to another. When doing so i will want to have the sprite rotate in a direction that is the shortest angular distance. Thankfully there is a Math Class method in phaser ce that is there for this very purpose called Phaser.Math.rotateToAngle, in this post i will be covering a quick example that makes use of this method.

Read More

The autocull component in phaser ce

The auto cull component in Phaser ce is a fairly simple component that just adds two boolean values. One of which can be used to enable auto culling of sprites in a project keeping sprites that are outside of the camera from rendering, and the other is just an inCamera boolean that can be used to find out if a sprite is outside of the camera or not. In this post I will be outlining a simple example that makes use of what is added to sprites in phaser ce thanks to the auto cull component.

Read More