In Flixel, you have a camera object. This camera gives you a viewport into the world. With the camera, you can control what the camera is focusing on at any given point. Now, how do we have the camera follow the player?

Camera Following

The camera in Flixel can be set to follow the player or any other target of your choosing. The way to do this is a simple function known as follow. This function also allows you to modify the type of camera such as a top-down or lock-on camera and how much the camera will lag behind when the player moves. You can even modify the dead zone as well.

Here’s an example of how to use it in game in a single line:, TOPDOWN, 2);

This would have the camera follow the player in a simple manner. Here’s how it would look in game:

As you can see it’s straightforward to get the following in Flixel implemented. The Flixel API has several utility functions that continue to make life easier when creating the game of your choosing. Additionally, you can stop the following of the player simply with another method. There’s much more you can do with the camera, which you can find at the API link here. You can even have multiple cameras to create a split-screen setup for your game!


With that said, happy game making!!

%d bloggers like this: