gamua / starling-framework Goto Github PK
View Code? Open in Web Editor NEWThe Cross Platform Game Engine
Home Page: http://www.starling-framework.org
License: Other
The Cross Platform Game Engine
Home Page: http://www.starling-framework.org
License: Other
I guess range of .currentFrame is 0 ~ n-1.
and .numFrames is n.
n = mTextures.length
so this causes little bit confusing.
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.
Make sure that users have all necessary options to react to stage RESIZE events.
in the render() method of DisplayObjectContainer there is no check if the container itself has visible=false || alpha==0.
Could be a small optimization to do a early exit if it is.
When emulating multitouch, the HOVER phase is misleading:
http://forum.starling-framework.org/topic/simulatemultitouch-bug-in-values
Evaluate what to do against it; perhaps the HOVER phase should be removed altogether when multitouch is simulated.
EDIT: environments like the Wii allow 2 cursors with HOVER phase, so it would make sense to implement the HOVER phase on all cursors instead.
refer to http://opensource.adobe.com/wiki/display/flexsdk/Coding+Conventions
fyi : even getter/setter that generated from Flash Builder use this "_" prefix
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.
I hope you don't get angry on me for bursting "bugs" on you but anyway...
I guess to keep consistency the render() method of DisplayObject should throw a AbstractMethodError if not overridden just like getBounds() does
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]
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
Tutorial pdf page 7:
var image:Image = new Image(texture);
// set the properties
quad.pivotX = 50
...
quad == image?
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.
Currently, there's a problem when you've got several Starling instances (either simultaneously or one after the other). More information can be found here:
(sigh)
This method always returns a point from the classical coordinate system whose origin is at upper-left.
It should return a point according to the actual pivotX and Y of a display object.
Here are some simple tips that can have a positive effect on performance:
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.
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.
x / 2 <=> x >> 1;
x * 2 <=> x << 1;
Using Fixed length vectors also helps, and to remove complex code from constructors.
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 ?
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
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.
As discussed here.
Please add Version class and/or changelog. Ideally, would be nice to see a SWC supplied as well with the version number. ex starlingframework_0.9.swc
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.
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
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.
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));
}
Allow accessing the Starling stage from a Starling instance.
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.
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).
The touch events take precedence in the current implementation. It should, of course, work in both cases.
So that users can, say, add support for HTML text.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.