A major improvement in the GameBuilder Engine is support for rendering GPU accelerated 2D graphics for your games. This, along with some other improvements that we have made, allows you to build games running 60 fps across multiple platforms. We have done this using the popular gpu rendering framework known as Starling. It is an open source framework backed by Adobe. We believe in open source tech and try to provide integrations that allow you to build as many games as you can at the lowest cost to you as a game developer.
No Major API Changes
We wanted something that would not require a lot of re-writing of existing game engine code but just allow you to switch the rendering layer of your game by changing class names. Starling provided the easiest way of doing this because it so closely mirrors the traditional flash display list. We mirrored the basic 2D rendering package already in the GameBuilder Engine and just added A G2D extension to all rendering classes. For example:
var entity : IEntity = PBE.allocateEntity(); var gameView : SceneView = new SceneView(); this.addChild(gameView); //Traditional Flash display list scene var scene : DisplayObjectScene = new DisplayObjectScene(); scene.sceneView = gameView; entity.addComponent(scene, "Scene"); var spriteRenderer : SpriteRenderer = new SpriteRenderer(); spriteRenderer.fileName = "assets/customimage.png"; spriteRenderer.position = new Point(200, 200); //Add the renderer to a scene to display it spriteRenderer.scene = scene; entity.addComponent(spriteRenderer, "SpriteRenderer");
Rendering a sprite to screen was done like the above before in code. Now you can leverage gpu rendering simply by changing class names and everything works as it did before:
var entity : IEntity = PBE.allocateEntity(); //Creates a Starling instance var gameView : SceneViewG2D = new SceneViewG2D(); gameView.starlingInstance.showStats = true; this.addChild(gameView); //Rendering using the Starling display list var scene : DisplayObjectSceneG2D = new DisplayObjectSceneG2D(); scene.sceneView = gameView; entity.addComponent(scene, "Scene"); var spriteRenderer : SpriteRendererG2D = new SpriteRendererG2D(); spriteRenderer.fileName = "assets/customimage.png"; spriteRenderer.position = new Point(200, 200); //Add the renderer to a scene to display it spriteRenderer.scene = scene; entity.addComponent(spriteRenderer, "SpriteRenderer");
**Note: With your existing GameBuilder Studio projects you will not have to change anything. All of this is handled for you when you launch your game because this is now the default rendering engine used for the editor.
There is no need to use the Starling Juggler class because GameBuilder Engine has its own process manager that handles game ticks. The entire wrapping of the Starling Instance creation is handled by the SceneViewG2D class. Once you remove a SceneViewG2D class from the display list the internal starling instance is disposed of. Whenever the game stage becomes deactivated the starling instance will stop running and pause the internal game process manager.
The only thing that is not currently supported in the starling2D rendering package is modifiers on renderers. This will be integrated in the future using texture shaders.