This document provides an overview of Starling, an open source ActionScript 3 library that allows developers to build native iOS and Android games. Some key points:
- Starling is based on Sparrow, an Objective-C library that mimics the Flash display list. It allows building games using an API similar to Flash.
- Starling renders all content using the GPU for high performance. It includes classes for common display objects like sprites, images, and movie clips.
- Texture atlases and the QuadBatch class can be used to optimize performance by batching draw calls.
- Features like particles systems, UI components, and game frameworks are available to simplify development of mobile games with Starling
6. Sparrow is a pure Objective-C library created by
Gamua that allows developers to build native iOS
games using an API similar to Flash.
7. Sparrow is a pure Objective-C library created by
Gamua that allows developers to build native iOS
games using an API similar to Flash.
Starling is based on Sparrow and is a pure AS3
library that mimics the conventional Flash display
list and all content is rendered by the GPU.
63. ANIMATION IN STARLING
The enter frame event behaves more like a real game timer
this.addEventListener(EnterFrameEvent.ENTER_FRAME, loop);
64. ANIMATION IN STARLING
The enter frame event behaves more like a real game timer
this.addEventListener(EnterFrameEvent.ENTER_FRAME, loop);
private function loop(event:EnterFrameEvent):void
65. ANIMATION IN STARLING
The enter frame event behaves more like a real game timer
this.addEventListener(EnterFrameEvent.ENTER_FRAME, loop);
private function loop(event:EnterFrameEvent):void
{
66. ANIMATION IN STARLING
The enter frame event behaves more like a real game timer
this.addEventListener(EnterFrameEvent.ENTER_FRAME, loop);
private function loop(event:EnterFrameEvent):void
{
trace("Time since last frame: " + event.passedTime);
67. ANIMATION IN STARLING
The enter frame event behaves more like a real game timer
this.addEventListener(EnterFrameEvent.ENTER_FRAME, loop);
private function loop(event:EnterFrameEvent):void
{
trace("Time since last frame: " + event.passedTime);
enemy.moveBy(event.passedTime * enemy.velocity);
68. ANIMATION IN STARLING
The enter frame event behaves more like a real game timer
this.addEventListener(EnterFrameEvent.ENTER_FRAME, loop);
private function loop(event:EnterFrameEvent):void
{
trace("Time since last frame: " + event.passedTime);
enemy.moveBy(event.passedTime * enemy.velocity);
}
72. EXPORT A RELEASE BUILD
The speed di鍖erence between the debug and release builds in
Starling are huge. Dont make any assumptions on performance
until you export a release build.
74. FLATTEN NON-CHANGING SPRITES
Calling flatten on a sprite is similar to cacheAsBitmap in the regular
display list. It reduces the number of draw calls dramatically.
mySprite.flatten();
76. MAKE CONTAINERS UNTOUCHABLE
If a container and its children do not need to be
interactive with touch set its touchable property to false.
container.touchable = false;
81. MINIMIZE STATE CHANGES
Starling batches draw calls whenever possible. Changing the state
of a display object will force a new draw call to the GPU. Properties
that change the state include:
82. MINIMIZE STATE CHANGES
Starling batches draw calls whenever possible. Changing the state
of a display object will force a new draw call to the GPU. Properties
that change the state include:
The texture (textures from the same atlas are fine)
83. MINIMIZE STATE CHANGES
Starling batches draw calls whenever possible. Changing the state
of a display object will force a new draw call to the GPU. Properties
that change the state include:
The texture (textures from the same atlas are fine)
The blendMode of display objects
84. MINIMIZE STATE CHANGES
Starling batches draw calls whenever possible. Changing the state
of a display object will force a new draw call to the GPU. Properties
that change the state include:
The texture (textures from the same atlas are fine)
The blendMode of display objects
The smoothing value of images
85. MINIMIZE STATE CHANGES
Starling batches draw calls whenever possible. Changing the state
of a display object will force a new draw call to the GPU. Properties
that change the state include:
The texture (textures from the same atlas are fine)
The blendMode of display objects
The smoothing value of images
The repeat mode of textures
86. MINIMIZE STATE CHANGES
Starling batches draw calls whenever possible. Changing the state
of a display object will force a new draw call to the GPU. Properties
that change the state include:
The texture (textures from the same atlas are fine)
The blendMode of display objects
The smoothing value of images
The repeat mode of textures
The tinted property of quads
89. THE QUADBATCH CLASS
QuadBatch is a low-level class that Starling uses to batch draw
calls. It is lighter weight than a flattened Sprite.
90. THE QUADBATCH CLASS
QuadBatch is a low-level class that Starling uses to batch draw
calls. It is lighter weight than a flattened Sprite.
All the objects you add must have the same state (i.e. use
textures from the same atlas).
91. THE QUADBATCH CLASS
QuadBatch is a low-level class that Starling uses to batch draw
calls. It is lighter weight than a flattened Sprite.
All the objects you add must have the same state (i.e. use
textures from the same atlas).
You can only add instances of the Image, Quad, or
QuadBatch class.
92. THE QUADBATCH CLASS
QuadBatch is a low-level class that Starling uses to batch draw
calls. It is lighter weight than a flattened Sprite.
All the objects you add must have the same state (i.e. use
textures from the same atlas).
You can only add instances of the Image, Quad, or
QuadBatch class.
It's a one-way road: you can only add objects.
98. USE SEPARATE SET OF HD TEXTURES
SD texture
iPhone 3G
HD texture
iPhone 4S
100. CONTENT SCALE FACTOR
Use this value to scale textures appropriately
var scale:Number = starling.contentScaleFactor;
var texture:Texture = Texture.fromBitmap(bmp,
true, false, scale);