/ Published in: ActionScript 3
Starling2D Engine is using the power of FLASH STAGE3D to create 2D games so you can use alot of sprites, particles .... with no impact on your SWF performance.
To start the Engine, you have to download the last version of Starling from this site: http://gamua.com/starling/download/
create a new action script project inside flash builder and add the SWC or the source files to your project
now create 2 class, one of them is to start the starling engine, and the 2nd class will be targeted with the 1st class with its CLASS NAME to run the 2nd class on STAGE3D.
Expand |
Embed | Plain Text
The 1st CLASS to START THE STARLING2D ENGINE: package { import flash.display.Sprite; import flash.display.StageAlign; import flash.display.StageScaleMode; import net.hires.debug.Stats; import starling.core.Starling; // the properties of the SWF FILE [SWF(frameRate="60",width="780",height="680",backgroundColor="#002143")] public class StarlingTest extends Sprite { // We have to create a Variable for the Starling FrameWork to start private var intilStarling:Starling; public function StarlingTest() { /* Status Class for FPS Stage Aligns Create our Starling Instance Set the Anti-Aliasing (Higher better but slow performance) Note: Anti-Aliasing Values: 0 = no, 2 = Minimal, 4 = high, 16 = Very High Then we start the FrameWork */ stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; intilStarling = new Starling(Main,stage); //MAIN IS OUR GAME OR APP MAIN CLASS NAME intilStarling.antiAliasing = 2; intilStarling.start(); } } } The 2nd CLASS: NOTE: THE NAME OF THIS CLASS SHOULD BE THE SAME AS THE CLASS NAME TARGETED BY STARLING. package { import starling.core.Starling; import starling.display.DisplayObject; import starling.display.MovieClip; import starling.display.Sprite; import starling.events.Event; import starling.textures.Texture; import starling.textures.TextureAtlas; public class Main extends Sprite { // XML Data [Embed(source="SpriteSheet.xml",mimeType="application/octet-stream")] private var AtlasXML:Class; // Texture File [Embed(source="SpriteSheet.png")] private var AtlasTexture:Class; private var mc:MovieClip; public function Main() { addEventListener(Event.ADDED_TO_STAGE,onAdded); } private function onAdded(e:starling.events.Event):void { CreateMovieClip(); } private function CreateMovieClip():void { // Create a Texture Var using yout Photo var texture:Texture = Texture.fromBitmap(new AtlasTexture()); var xml:XML = new XML(new AtlasXML()); var atlas:TextureAtlas = new TextureAtlas(texture,xml); mc = new MovieClip(atlas.getTextures("SpriteSheet"),20); addChild(mc); // To start Animating the MovieClip Starling.juggler.add(mc); } } }
You need to login to post a comment.
