📜 ⬆️ ⬇️

Unity vs Adobe Air, or As I wrote the first mobile game

Hello!

Today I would like to talk about the first experience of writing a game for mobile devices. I am a flasher by profession, and making games, albeit simple ones, is not new to me. However, mobile development is different and harbors a lot of unexplored.

Start

How did it all start? That's right, like many interesting and not very stories, with the dismissal from work. Time was freed, and to occupy oneself was simply necessary. Since Flash has not been much in demand lately, it was decided to try Adobe Air and its cross-platform functionality.
')
Idea

Paradoxically, I'm not a big fan of playing games, with the exception of "race cars" and "something simple and funny." Naturally, the first idea was something like an “exciting off-road race”. Then, inspired by such a game as Color Zen , I wanted something “interesting, beautiful and soothing.”

But, as they say, the 8-bit past took it up and it was decided to make a parody of Flappy Bird, which had just been removed and hated by many. Not a banal parody, no, it was decided to allow users to let off steam - to create a new character that will blow everything to hell. The name was found quickly - Rocket Toads, and the main characters were two (to make the name of the game in tune with the famous 8-bit game). The goal of the game is to destroy as many pipes as possible, just throwing dynamite, and at the same time stay alive, dodging shrapnel and explosions.

Implementation

The characters, the background and the main elements of the game were drawn quickly, because high levels of design was not exhibited. As, actually, and in the game, on which the parody was made.

Icon


Background and Main Menu


The following engines were chosen as engines:

- Starling (drawing graphics using GPU)
- Nape (the smartest physics engine)

If I didn’t worry about Starling and its speed, then the speed of physics calculation caused fears - it was planned that up to 30-40 objects would be present on the scene at the same time - fragments from blown-up pipes. I was also worried about the speed of execution of the ActionScript code, in particular, the algorithm for breaking the pipe into fragments.

First tests

When the main part of the game was ready, the long-awaited moment of testing on the real device came.
Samsung got into the hands with a single 1000 MHz processor and the Andreno 200 graphics accelerator. In general, due to its low performance, this is what is needed for the tests.

The game started perfectly, the hero happily flew skipping through the pipes, and the FPS kept around 60! But I didn’t have long to rejoice, after a while I tried to use dynamite to spool, and the game began to slow down a lot, precisely at the moments of breaking pipes into fragments and with a large number of physical objects, which I was afraid of.

The next few days to configure physical. engine and code optimization did not lead to anything. The profiler (Adobe Scout) explicitly stated that the speed of the execution of ActionScript code is a stumbling block.

ANE, Unity2d and Haxe

Mourning Adobe Air, I went and buried it in my garden and began to look for alternatives. As promising options for improving performance surfaced:



In the first embodiment, nothing really was found, because there was no “good man” who would make a full-fledged two-dimensional physics engine on ANE.

The second and third options were good and it was decided to do physical tests to evaluate the performance.
As a result, Unity won, and, if memory serves, with similar FPS, the results are approximately as follows:



Unity2d - rewrite the game again

Unity mastering was relatively easy. Switching from ActionScript to C # turned out to be easier than it was seen at the beginning. Unity Editor is also fun. Among the lessons would advise:

- Creating a 2D game with Unity
- Basics of creating a 2D character in Unity 3D 4.3
- Official video tutorials

I was also pleased with the large community of Unity developers, thanks to which almost any question that arises has a normal answer.

Testing again

Well, the first test results inspired - there were no strong brakes, and I began to confidently finish the game to the end. Later, some interesting bugs were discovered that slowed down the game:

- “First explosion” - the first execution of a script destroying a pipe was about 300 ms, subsequent calls are up to 20 times faster. It was necessary to make the first explosion automatically outside the camera (outside the user's eyes), while the player is still clicking the menu.

- “Clamped” - since some parts of the blown-up pipes remain static and some turn into dynamic fragments, there are cases when dynamic fragments are squeezed between static and generate many collisions and provoke “brakes”. I had to make a counter, which, with a certain amount of collisions in a static fragment, turns it into a dynamic one, and the squeezing is eliminated.

Total

  1. The game is ready and even laid out on Google Play. The speed of work on medium and advanced devices inspires optimism.
  2. Gained experience with a great Unity engine.
  3. Unity vs Adobe Air - friendship won. On the example of my game, of course, Unity was out of competition and for mobile-games demanding for performance, I would advise him. However, it is not perfect either - for example, Unity WebPlayer and its periodic crashes, the failure of the mouse button in Chrome, the editor hang on closing, the impossibility of fast and high-quality publishing to Flash and some other things. Also, judging by the rendering speed, Unity sometimes loses Adobe Air + Starling . So, if you decide to write a not too demanding game and publish it for Android, IOS or Flash player, Adobe Air + Starling will be a good solution.

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


All Articles