Egret飛行模擬-開發記錄01
阿新 • • 發佈:2018-11-29
1、專案結構簡介
1.1 index.html:應用入口檔案,我們可以在這裡面配置專案的旋轉縮放模式背景顏色等。 1.2 egretProperties.json:這個檔案裡面進行專案配置,包括模組和第三方庫的配置,釋出和native相關配置,比較常用的設定就是新增模組和第三方庫。 1.3 manifest.json:清單檔案 1.4 tsconfig.json:typescript 編譯配置檔案。 1.5 wingProperties.json:Egret Wing 專案配置檔案 2、egret 自定義字型 2.1 ttf字型庫引入 首先在樣式表中新增外部字型: @font-face { font-family:"ziti1"; src: url("kaiti.ttf"); } 其次新增偵聽,使得進入遊戲之前完成字型載入: <script> document.fonts.ready.then(success, fail); function success(){ egret.runEgret({renderMode:"webgl", audioType:0}); } function fail(){ } </script> 最後在程式中呼叫即可: label.fontFamily ="ziti1"; 2.2 點陣圖字型 2.2.1使用Texture Merger工具,編輯文字,匯出一張點陣圖和一個.fnt檔案。 2.2.2資源載入配置2.2.3程式碼實現
module demo{ export class BitMapTextView extends egret.DisplayObjectContainer{ private _bitmapText : egret.BitmapText = null; private _bitmapFont : egret.BitmapFont = null; public constructor(){ super(); this._bitmapText = new egret.BitmapText(); this._bitmapFont = RES.getRes("cartoon-font_fnt"); this._bitmapText.font = this._bitmapFont; this._bitmapText.x = this._bitmapText.y = 150; this.addChild( this._bitmapText ); } /** * 顯示文字 */ public showText( $str : string ) : void{ this._bitmapText.text = $str; } } } 呼叫: let $demo : BitMapTextView = new BitMapTextView(); this.addChild($demo); $demo.showText("I am Aonaufly!");