Giter VIP home page Giter VIP logo

starling-framework's Introduction

Starling Framework

The Cross Platform Game Engine

The Starling Framework allows you to create hardware accelerated apps in ActionScript 3. The main target is the creation of 2D games, but Starling may be used for any graphical application. Thanks to Adobe AIR, Starling-based applications can be deployed to mobile devices (iOS, Android) and the desktop (Windows, macOS).

While Starling mimics the classic display tree architecture of Adobe AIR/Flash, it provides a much better performance: all objects are rendered directly by the GPU (using the Stage3D API). The complete architecture was designed for working well with the GPU; common game development tasks were built right into its core. Starling hides Stage3D internals from developers, but makes it easy to access them for those who need full performance and flexibility.

Starling aims to be as lightweight and easy to use as possible. As an Open Source project, much care was taken to make the source code easy to read, understand and extend. With under 20k lines of code, experienced developers can easily grasp it in its entirety, or modify it to their needs.

Quick Links

News and Updates

Adobe AIR – Provided by HARMAN

  • Get the latest AIR SDK here.

starling-framework's People

Contributors

adolio avatar bsideup avatar bwhiting avatar carlosrovira avatar ehsanmarufi avatar esidegallery avatar francescomaisto avatar hamidhomatash avatar honzabrecka avatar jkillian avatar johnfn avatar joshtynjala avatar jsandhu avatar kadiryazgan avatar kevinfoley avatar kukulski avatar matsefr avatar mikatalk avatar morvans avatar muaoloniel avatar oddwhocanfly avatar peerobo avatar primaryfeather avatar racarone avatar rokannon avatar samystudio avatar tconkling avatar travisism avatar uenon avatar zeh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

starling-framework's Issues

Use relative paths for embedded assets

The texture that is used for the multitouch helper is included with an absolute path, which breaks compilation when the project is set up in a different way than expected (e.g. when it's included directly in a game).

awkward getter/settter

refer to http://opensource.adobe.com/wiki/display/flexsdk/Coding+Conventions

  1. it should be "private var _foo" instead of "private var mFoo" (weird!)
  2. i think you don't need to call getter eg. "x" instead of "mX" in it own class or extended class (function look up is cost CPU)
  3. there is no invalidate state? eg. if(_x==value)return; then invalidate after that if need (set some value is cost CPU)

fyi : even getter/setter that generated from Flash Builder use this "_" prefix

Using StageScaleMode.NO_SCALE in IE will result in an exception (Error #3669 at flash.display3D::Context3D/configureBackBuffer())

Hi,
I have a bug which occur in IE (IE9 at least but it seems like a common IE problem). If I use this line:
stage.scaleMode = StageScaleMode.NO_SCALE;
Then I get an exception during Starling init:

Error: Error #3669: Taille d’entrée incorrecte.
at flash.display3D::Context3D/configureBackBuffer()
at starling.core::Starling/updateViewPort()[D:\workspaces\Flex\Flex_4.5_branch\StarlingLib\src\starling\core\Starling.as:233]
at starling.core::Starling/initializeGraphicsAPI()[D:\workspaces\Flex\Flex_4.5_branch\StarlingLib\src\starling\core\Starling.as:209]
at starling.core::Starling/onContextCreated()[D:\workspaces\Flex\Flex_4.5_branch\StarlingLib\src\starling\core\Starling.as:318]

When you get into the code, you can notice that the stageWidth and stageHeight are both at 0. It looks like a swfobject.js + IE problem, see this thread: http://www.actionscript.org/forums/showthread.php3?t=128143

Solution is to listen for the Event.RESIZE event on the stage passed to Starling and initialize the viewport once both dimensions are not zero. From my tests, it takes 2 resize events to get the correct dimensions.

Fabien

Missing handle for 'bold' in TextField constructor

I found TextField's bold property is not working, bacuase contructor does not handle for bold.
so i assign like below, and it works fine.

[code]
public function TextField(width:int, height:int, text:String, fontName:String="Verdana",
fontSize:Number=12, color:uint=0x0, bold:Boolean=false)
{
....
mBold = bold;
....
}
[/code]

DataEvent class

Hello,

I know it's trivial, but while you're reimplementing the event dispatching model in Starling API you might as well include a DataEvent class.

Re-use vertex/index buffers when using same resource Image/Movieclip

When creating multiple Movieclips or Images utilizing same texture/same size, Starling creates multiple buffers instead of reutilizing the same vertex/index buffer.
This is particularly important for particle generators and special effects. Current performance can significantly benefit from this.

Force users to handle missing Stage3D

Currently, this is the constructor
of the Starling class:

public function Starling(rootClass:Class, stage:flash.display.Stage,
                           viewPort:Rectangle=null, stage3D:Stage3D=null,
                           renderMode:String="auto")
{
    // ...
    if (stage3D == null) stage3D = stage.stage3Ds[0];
}

As you can see, the user can provide a stage3D object manually; if he
doesn't, Starling uses the first available.

But we could also do it like this:

public function Starling(rootClass:Class, stage:flash.display.Stage,
                           stage3D:Stage3D, viewPort:Rectangle=null,
                           renderMode:String="auto")

Note that "stage3D" does not have a default value anymore: the user has
to provide Starling with it. (If he passes null, we could throw an
exception).

That way, the user is forced to check for the availability of Stage3D
himself. (Which should be even less work than listening to an event
telling him that it's not available.) We could further push this by
adding such a check in all our samples.

Error #1009 in TouchProcessor.as

With an Air application, I have the following error when alternating left and right click.

[Fault] exception, information=TypeError: Error #1009: Cannot access a property or method of a null object reference.

Sometimes, the touch event target is null so I tried to put additional tests into the following lines:

Line 85

if (currentTouch.target != null && currentTouch.target.stage == null)
   currentTouch.setTarget(mStage.hitTest(
      new Point(currentTouch.globalX, currentTouch.globalY), true));

Line 121

if (touch.target != null) {
   touch.target.dispatchEvent(new TouchEvent(TouchEvent.TOUCH, mCurrentTouches,
                                                       mShiftDown, mCtrlDown));
}

Memory Leak in Starling

There is a memory leak within the Starling Framework. Create a very basic Starling project with a main flash.display.Sprite class that instantiates Starling and a main starling.display.Sprite class and then start Starling within the profile (Flash Builder) without any other added objects. Peak memory keeps slowly climbing.

Reference image: http://dl.dropbox.com/u/189315/Starling_Leak.png

Resize event width and height don't match stage.stageWidth and stage.height

With the following function:
private function event_stage_resize(event:ResizeEvent):void {
trace(event.width + " " + this.stage.width + " " + this.stage.stageWidth);
}

I get completely different values for each. The event.width actually matches the stage width and height. I have no idea where the values come from for stage.width (it increases but doesn't actually match the size of the stage). The stage.stageWidth value never changes from its original value. This is an unexpected behavior. In Flash, the stage.stageWidth will always reflect the actual size of the stage.

Tutorial typo

Tutorial pdf page 7:

var image:Image = new Image(texture);
// set the properties
quad.pivotX = 50
...

quad == image?

Enhance performance by adhering to AS3 best practices

Here are some simple tips that can have a positive effect on performance:

for loops

Instead of

for (var i:int=0; i<container.numChildren; ++i)

it's more efficient to write

var limit:uint = container.numChildren;
for (var i:int=0; i<limit; ++i)

Because otherwise, the "numChildren" method will be called in every loop.

Array/Vector element access

As described in this article, it's a good practice to cast any Vector/Array access to the expected type.

var element:int = vector[3] as int;

Furthermore, the index operator should always be cast to int when it's the result of an operation:

myArray[int(i+2)];

Otherwise, it might be converted to 'Number' and then back to 'int' before being used.

Use bitwise operations for division and multiplication by powers of 2.

x / 2 <=> x >> 1;
x * 2 <=> x << 1;

Misc

Using Fixed length vectors also helps, and to remove complex code from constructors.

Allow to specify background color

We may want to include the ability to
specific the buffer background color.

For now, you clear() so we have a black background.

Maybe you could allow to pass a color, even better add an automatic mode
where it automatically takes the SWF background color.

Turning of Events (and/or using ObjectPools for them)

I have been working a bit with the Starling framework and it looks great.
There is one thing though: Events.
I would like to have the option to turn off events completely. Im developing a game for mobile and I am not using events at all since I don't have to and I like it that way. Even if I'm not using Events they are still dispatched (created, bubbled and erased) and eating my CPU and MEM (little but still.)
It would be a very nice feature to be able to turn off events.
I would also suggest (I don't know if it's possible but) to use an object pool for the events to spare the garbage collector.
On mobile there is a big thing to create and erase objects and since the events are seldom persistent but just handled for a very short time I guess that would be great for performance.

mChildren field in DisplayObjectContainer is private

The mChildren field is private making it hard to extend DisplayObjectContainer to do, for example, quick z-sorting of all its children.
I would like to request the field to be protected since I then can sort all the children on their y position very fast if you compare to sorting it by swapping children

Find a way to handle a lost context

Feedback from Aaron:

Handle device loss. The CONTEXT3D_CREATE event could fire at any given time when the GPU context is lost (screensaver coming on, or another app taking it, or the OS itself taking it). Starling should make this event invisible to the user so that they don’t have to re-upload all the resources manually. Right now Starling will throw an error that Programs have already been registered, and rendering will stop.

Remarks:

Device Loss: To simulate a device loss event, it is as easy as leaving the CONTEXT3D_CREATE eventListener on the stage3D, then calling context3D.dispose(). If the listener is attached when calling dispose() the event will immediately fire, simulating a device loss and device regain cycle. To test the real thing is easy too. On Windows all you have to do is do ctrl+alt+delete to enter the admin screen. On Mac it's trickier, but should occur if you close the laptop lid or put the screen to sleep, or allow the screen saver to come on.

Setting up Staring in FDT 4 flash.display.Stage issue

I am wanting to get started with Starling and I use FDT. I have Flex 4.5.1 / AIR 3 / flash 11 player global all setup and working. I am following the examples lee put up on gotoandlearn.com for getting started with starling.

I don't know if this is an issue with FDT or with the way I am setting things up but I get an error in the Starling.as file for passing in Stage in the constructor function witch is typed to flash.display.Stage. http://grab.by/b2dc

Not sure how to get around this issue. Of course Starling.as also references the starling "Stage" so I do understand why typing vars in the class with the full package is needed.

Anyone know how to get around this ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.