📜 ⬆️ ⬇️

Features new version of the game framework Flixel 2.5

Not so long ago, a new version of Flixel , a fairly well-known and popular framework for creating games, was released (the latest changes on github date back to April 28). Now the serial number of the framework has reached tsiferki 2.5. This update includes several, in my opinion, interesting features that can simplify the life of Flash developers even more. If you are interested in Flixel, then I strongly recommend that you familiarize yourself with the original description , which contains a number of examples demonstrating new features, which will be discussed below.

Cameras

One of the new features of Flixel is the emergence of a flexible and powerful class for controlling cameras, which is called ( SUDDENLY! ) FlxCamera . By default, a new project is created with one camera, the dimensions of which coincide with the size of the FlashPlayer window. Access to this camera can be obtained through the FlxG.camera link. You can replace this camera or add additional cameras to create effects like split-screen, picture-in-picture or mini-map. Each camera is an independent visual object, with its own settings for approximation, color shade, rotation and scaling. Also, each game object maintains its own list of cameras , so you can simply configure certain game objects to display in certain cameras. Game developers in the “adventure” style can also familiarize themselves with the source code of the game “Mode” to learn more ways to use cameras in games.

Finding the way

The concept of “ finding a path ” means finding answers to the questions “How to get from point A to point B?” Or “Is it possible to get from point A to point B?”. The FlxTilemap class has a new function FlxTilemap.findPath () , which returns a FlxPath object, which is a list of “nodes” ( FlxPoint objects). Think of this list as just a list of X and Y coordinates in space that start from the starting position and end with the finishing position. When you find a valid path, you can pass this data to any FlxObject using the FlxObject.followPath () function. This function “tells” objects to start following a given path. You can adjust the speed, direction (reverse, yoyo, etc.), as well as set the possibility of “following” the path only horizontally (convenient for objects reacting to gravity). These settings allow you to use the paths not only for organizing AI characters, but also for organizing “elevators”, moving platforms and looped background animation.

Repetitions

Replays is a new and powerful feature of Flixel. “Repetitions” is a list with information about the pressed buttons of the keyboard and data on the behavior of the mouse, in accordance with the time. Since Flixel to a greater degree delimits the functionality of its components, we can use the “replay” information to re-create game sessions that were recorded by someone else. "Replays" can be used for debugging, creating "attract-mode" modes, in-game demo modes, as well as creating videos. The “repeat” control can be done through the “VCR” panel in the debugging layer, or directly through functions such as FlxG.loadReplay () , FlxG.recordReplay () , and FlxG.reloadReplay () . Game developers in the “adventure” style can also get acquainted with the source code of the game “Mode” to see examples of loading “replays” from a file to create the “attract mode” mode.
')
Groups and collisions

Flixel game objects can be “saved” inside FlxGroup objects. Groups can be used to simplify, automate and organize updates, rendering, collision search, controlling cameras, calculating scrolling values, and more. When you want to avoid calling such resource-intensive functions as FlxG.collide () more than a few times in each game cycle, you can use nested groups as a way to simplify these calls. For example, the objects in your game are divided into 3 different groups: Apples, Pears and Bananas. And you also want to organize the functionality of the "landing" of objects. To implement this functionality, it may seem like a good solution to call the FlxG.collide () function 3 times: FlxG.collide (Apples, ground), FlxG.collide (Pears, ground), FlxG.collide (Bananas, ground). A better solution would be to create a 4th group, let's say it would be called Fruit, and add 3 groups of objects (Apples, Pears, Bananas) to this group, and then the FlxG.collide function (Fruit, ground) can be called. In this case, you will save the functionality of the "landing" game objects, as well as get a significant performance boost.

Tilemaps and Auto-Tiling

Inspired by the old video games in which the game environment was created from a grid of square " tiles ", the developers of Flixel created the FlxTilemap class. Each grid cell has a number or an index with which you can refer to a specific part of the graphic, which in turn can be used several times to create the playing space. Tile graphics have many advantages, for example, it is easy to understand how tiles should be displayed, how tiles should overlap objects, and what particular properties each tile should have. Flixel also provides algorithms for automatically placing tiles of walls and floors, based on arrays with binary information about tiles. It is a simple and flexible system that is well suited for rapid prototyping.

Particles

The concepts of "particles" and "particle emitters" refer to separate classes that are used to create special effects and behavior. "Emitters" are objects that create particles and control them. FlxParticle is a simple extension of the FlxSprite class, and FlxEmitter is just an extension of FlxGroup , so the particle systems in Flixel are not much different from other regular sprite groups. Particle systems simply add functionality to create and “ launch ” particles, and particles have some properties to customize their behavior so that it looks more realistic. The FlxEmitter class also has some properties for adjusting the “spread” of speeds, rotation speed, gravity, collision behavior, etc.

Save game

Flash technology provides an easy way to save information locally, and FlxSave objects provide an interface for working with data storage. This method of saving is not suitable for all tasks. For example, if you want to create an online table of records, then this method will not allow you to do this. If you want players to be able to move and trade game save files, then using this save method is also not a good idea. FlxSave is well suited for quickly and easily saving local data, such as game progress or user settings.

PS:

Initially I found out that Flixel quit post on flashgameblogs.ru .

Source: https://habr.com/ru/post/119039/


All Articles