日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

《Starting with Starling》 Ep 1~11

發布時間:2023/12/9 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 《Starting with Starling》 Ep 1~11 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

starling 1.3,Hi-ReS-Stats

FlashDevelop設置

Project->Properties ->Output->Platform->Flash Player->11.5 ->Classpaths->Add Classpath->(starling和Stats的src文件夾)

程序入口

[SWF(frameRate="60", width="800", height="600", backgroundColor="0x333333")] public class Main extends Sprite {private var mStarling:Starling;public function Main():void {if (stage) init();else addEventListener(Event.ADDED_TO_STAGE, init);}private function init(e:Event = null):void {removeEventListener(Event.ADDED_TO_STAGE, init);this.addChild(new Stats());mStarling = new Starling(Game, stage); //Game繼承自starling.display.SpritemStarling.antiAliasing = 1;mStarling.start();} }

代碼自動生成

this.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);右鍵onAddedToStage->Refactor->Code Generator->Generate Event handler

版本控制

Setting->SourceControl->SVN ->Enable SVN->True ->SVN Path->(SlikSvn\bin\svn.exe) ->TortoiseSVN Proc Path->(TortoiseSVN\bin\TortoiseProc.exe) 1. 創建項目repo目錄,右鍵->TortoiseSVN->Create repository here->Create folder structure。 2. 項目右鍵->Shell Menu...->TortoiseSVN->Import...->URL of repository(項目repo目錄/trunk)。 3. 項目右鍵->Shell Menu...->SVN Checkout...->URL of repository(項目repo目錄/trunk)。 4. Source Control->...

Sprite Sheet(Texture Atlas)
TexturePacker->Sparrow

內嵌資源

public class Assets {[Embed(source="../media/graphics/bgWelcome.jpg")]public static const BgWelcome:Class;[Embed(source="../media/graphics/mySpritesheet.png")]public static const AtlasTextureGame:Class;[Embed(source="../media/graphics/mySpritesheet.xml", mimeType="application/octet-stream")]public static const AtlasXmlGame:Class;private static var gameTextures:Dictionary = new Dictionary();private static var gameTextureAtlas:TextureAtlas;public static function getTexture(name:String):Texture{if (gameTextures[name] == undefined) {var bitmap:Bitmap = new Assets[name](); //Assets[name]()是什么意思?gameTextures[name] = Texture.fromBitmap(bitmap);}return gameTextures[name];}public static function getAtlas():TextureAtlas{if (gameTextureAtlas == null){var texture:Texture = getTexture("AtlasTextureGame");var xml:XML = XML(new AtlasXmlGame());gameTextureAtlas = new TextureAtlas(texture, xml);}return gameTextureAtlas;} }

使用資源

private var bg:Image = new Image(Assets.getTexture("BgWelcome"));private var heroArt:MovieClip = new MovieClip(Assets.getAtlas().getTextures("fly_"), 20); starling.core.Starling.juggler.add(heroArt);

自定義事件

public class NavigationEvent extends Event {public static const CHANGE_SCREEN:String = "changeScreen";public var params:Object;public function NavigationEvent(type:String, _params:Object = null, bubbles:Boolean=false){super(type, bubbles);this.params = _params;} }

派發事件

this.dispatchEvent(new NavigationEvent(NavigationEvent.CHANGE_SCREEN, {id: "play"}, true)); //冒泡,讓父容器處理事件。

處理事件

private function onChangeScreen(event:NavigationEvent):void {switch (event.params.id) {case "play":screenWelcome.disposeTemporarily();screenInGame.initialize();break;} }

單位變換
deg2red()

碰撞檢測

if (obstacleToTrack.bounds.intersects(hero.bounds))

Embedded Fonts

[Embed(source="../media/fonts/embedded/BADABB__.TTF", fontFamily="MyFontName", embedAsCFF="false")] public static var MyFont:Class;
//使用
private var scoreText:TextField = new TextField(300, 100, "Score: 0", "MyFontName", 24, 0xffffff);

Bitmap Fonts

[Embed(source="../media/fonts/myFont.png")] public static const FontTexture:Class; [Embed(source="../media/fonts/myFont.fnt", mimeType="application/octet-stream")] public static const FontXML:Class;private static var myFont:BitmapFont;public static function getFont():BitmapFont {if (myFont == null) {var fontTexture:Texture = Texture.fromBitmap(new FontTexture());var fontXML:XML = XML(new FontXML());myFont = new BitmapFont(fontTexture, fontXML);starling.text.TextField.registerBitmapFont(myFont);}return myFont; }
//使用
private var scoreText:TextField = new TextField(300, 100, "Score: 0", Assets.getFont().name, 24, 0xffffff);

粒子系統

[Embed(source="../media/particles/particleCoffee.pex", mimeType="application/octet-stream")] public static var ParticleXML:Class;[Embed(source="../media/particles/texture.png")] public static var ParticleTexture:Class;
//使用
private var particle:PDParticleSystem; particle = new PDParticleSystem(XML(new AssetsParticles.ParticleXML()), Texture.fromBitmap(new AssestsParticles.ParticleTexture())); Starling.juggler.add(particle); particle.start();

轉載于:https://www.cnblogs.com/joojoosue/archive/2013/02/10/2909698.html

總結

以上是生活随笔為你收集整理的《Starting with Starling》 Ep 1~11的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。