An overview of the main phaser input manager via game.input

This post is an overview of the main phaser ce input hander that can be found at game.input in a phaser game object instance. There is much to be said about Input (what is used via game.input), and InputHander (what is used in game objects like sprites). However this post is mainly just an outline of what there is to work with via the Input instance at game.input.

Read More

Getting started with sprite sheets in phaser.

Sprite sheets come into play when starting to work with sprites. As a sprite needs to be skinned with something it is wise to start with sprite sheets before moving on to learning more about sprites. In this post I will be covering how to get started with the basics of sprite sheets in phaser ce by way of involving an external image that must be loaded. However I will also branch off into other topics that involve making a sprite sheet from canvas with javaScript code, and cover some basics with animations and sprites.

Read More

The lodash _.nth method use case example

When grabbing an element from an Array I need to give a zero relative index value where zero will be the first element, and that the last element in the array will end up having a value of one less from that of the total length of the array. This is a trivial matter for even a new javaScript developer as it is one of the first things I remember becoming aware of when learning javaScript for the first time.

There is a question of how to handle index values that fall outside the index range of the array though, that is when a negative index value is given. There are plenty of ways to handle that sort of thing with just plain old vanilla javaScript, such as making use of a mathematical modulo method that will work well, but if I am using lodash in a project there is the _.nth method.

Read More

The lodash _.times method as an alternative to loops, forEach.

How often do I need to use a while loop, or something like Array.forEach in a project? All the time of course, it seems to come up at every twist and turn actually. I could write a post about what way of looping is the fastest, or what way is the most concise when it comes to making code a little more readable. However I am not going to bother with that sort of thing here, at least not today.

This is yet another one of my lodash posts, so I will be writing about the _.times method in lodash naturally. This method is a way to call a method that is given as a first argument a number of times that is given as the second argument. However I will also touch base on some vanilla js alternatives as well when it comes to making my own lodash times style method with plain old javaScript by itself.

Read More