Introduction
I have long wanted to make at least some toy for a mobile phone. Game development is one of my hobbies. I spend very little time for this, but I do it with pleasure.
Previously, he developed small toys on a PC (for example, friends and colleagues to play), browser games and games for social networks. I didn’t do anything special in this direction, but I had a good time.
Oh yeah, I also worked in a couple of software developers and publishers of computer games as a programmer, but I quickly realized that passion was one thing, and working at a large game development firm was quite another.
')
I have never made games for mobile devices and now I decided to explore the issue, try and develop, and publish, and generally find out how everything is there.
Technology selection
I installed Unity twice, made a test project, and I don’t know - something doesn’t lie to this technology, everything is uncomfortable for me and everything is done.
I tried sdl2 and cocos2d - I liked these technologies much more, but I definitely stumbled upon the limitations of the engine in some aspects, without which one could do without, but I really wanted more space for maneuvers.
I tried haxe - a very interesting thing, but building an application for a long time, the build via Android SDK / NDK is often buggy (I have several development environments for working with my Android SDK / NDK repositories, maybe they conflict with haxe), and the performance is not much better than Starling for AIR.
I was tinkering for a long time in different engines and at some point I decided to just release a toy for the sake of the process itself. Therefore, I turned to an old friend - AS3 with AIR technology. Somehow I made small radio-controlled toys and instead of using the remote I used a phone on which simple interfaces of the WI-FI control joystick were developed. Just for this, I used AIR, because I used to make toys on Flash, and creating an application for an AIR mobile phone was extremely fast and easy.
Stage3D
Vector animation has never been very good in performance, but a small number of animations work fine. You can't make a serious toy on this, and for a long time I wanted to learn how to work with a video card via Stage3D. I also tried bitmap blitting as it behaves on a mobile phone - not very bad, but since this is all for personal pleasure, I decided to master Stage3D.
At first I took Starling and Genome2D. Starling was very convenient, but did not meet my expectations in performance, if you use animations with different display filters, it is better to use the usual DisplayList and MovieClip. It is difficult to work and search for information with Genome2D, and not much more productive. Looking at the sources, it became clear to me that these engines are a very tough implementation of the features of Stage3D. I decided to look at Stage3D myself.
I was inspired by this
bunnymark , developed on the basis of an example from Adobe - GPUSprite. So many sprites jumping on the screen, I immediately wondered how.
I looked at this small engine (GPUSprite). In principle, almost everything for happiness is (camera, sprites, rotation, movement, scaling, transparency), plus all the possibilities that you add. There was not enough for a small engine in the example of animations, several display filters, and of control of all features.
It would seem a little, but this is not so easy to do. There are some problems arising from the principle of working with a video card. You can select your video card object for each sprite, but it doesn’t work that fast, so you can safely apply any pixel shaders to a specific sprite and linearly increase the number of sprites. More sprites can be displayed if you store several sprites in one video card object, if we represent sprites in the form of rectangles, then we will need 4 vertices per sprite. But there is a limitation in the number of vertices of the video card object, well, you can attach a limited number of textures (sprites). For those settings that I used for more coverage of devices, 16384 sprites per object are obtained and limited to one texture.
Also, you need to sort by the depth of the display of sprites. From all this there is such a picture:
Ђ We iterate over the sprites in the drawing sequence;
• For the first sprite, create a video card object and attach the associated spriteshit as a texture;
• We look at the next sprite: if it is from another sprite, the limit is filled in 16384 sprites in the object or requires another pixel shader for display effects, then create a new video card object.
Managing this whole business is not easy, but takes time to process. But you can do it another way - not to turn spriteshit as it is into a texture, but to create a texture as you draw it with the necessary sprites, and here you have your drawbacks.
I went through a lot of different ways, and each had its own pros and cons. In the end, I removed almost all automatic processing for manual control. Difficult to use, but good efficiency. Otherwise, all something like Starling is obtained by performance.
Made support for frame-by-frame animation and software (bone animation) and small programs for converting MovieClips from Adobe Animate into sprite sheets and software description files and frame-by-frame animation.
Then I wanted to use the usual stage for GUI elements, but this slowed down, distracted by the development of GPUGUI, a simple engine and a converter into raster fonts. With the text is generally difficult too. For simple, rarely changing phrases made auto sprite shaping by drawing a TextField in BitmapData.
findings
Amused, of course, as I could. I did dozens of bicycles, but it was fascinating, and this is still a hobby. There were also several problems with the behavior of Stage3D on Android. For example, if the screen is horizontally oriented, if someone calls during the game, then after returning to the game, a white screen remains, well, or the color you chose in the default background settings. While you can poke on the invisible buttons, listen to the sounds and the usual stage works, and all the application code is functioning, just nothing is displayed. There are articles on this issue on the Internet.
Publishing on Google Play is also a fun activity, everything seems to be written in Russian, but nothing is so easy to understand and it is useful to read the explanations on third-party sites of experienced people. Chinese interface they probably compose.
To test all this, I developed a simple arcade "Ancient Runes" and published it on Google Play.
For now I’ll do other hobbies, and then it’s interesting to develop a small online mobile toy.
Here, if interested, an example of the apk benchmark from starling (I changed only static pictures on the animation, maybe something can be accelerated there) and an example of the engine based on Adobe's GPUSprite with animation→
starling→
GPUSprite