Tools
分类目录
文章归档
标签
   

StarlingSwf-Egret

目录

关键代码

private swf:starlingswf.Swf;
  1.     /**
  2.      * 创建游戏场景
  3.      */
  4.     private createGameScene():void{
  5.         var swfData:Object = RES.getRes("test_swf");
  6.         var spriteSheet:egret.SpriteSheet = RES.getRes("test");
  7.  
  8.         var assetsManager = new starlingswf.SwfAssetManager();
  9.         assetsManager.addSpriteSheet("test",spriteSheet);
  10.  
  11.         this.swf = new starlingswf.Swf(swfData,assetsManager,60);
  12.  
  13.         this.test1();
  14.  
  15.         egret.Profiler.getInstance().run();
  16.  
  17.     }
  18.  
  19.     /**
  20.      * Sprite测试
  21.      * */
  22.     private test1():void{
  23.         var sprite:starlingswf.SwfSprite = this.swf.createSprite("spr_1");
  24.         this.addChild(sprite);
  25.     }
  26.  
  27.     /**
  28.      * MovieClip测试
  29.      * */
  30.     private test2():void{
  31.  
  32.         var mcNames:string[] = ["mc_lajiao","mc_test1","mc_Tain","mc_Zombie_balloon","mc_Zombie_dolphinrider","mc_Zombie_gargantuar","mc_Zombie_imp","mc_Zombie_jackbox","mc_Zombie_ladder","mc_Zombie_polevaulter"];
  33.         for(var i:number = 0 ; i < 50 ; i++){
  34.             var mcName:string = mcNames[Math.floor(Math.random() * mcNames.length)];
  35.             var mc:starlingswf.SwfMovieClip = this.swf.createMovie(mcName);
  36.             mc.x = Math.random() * 480;
  37.             mc.y = Math.random() * 320;
  38.             this.addChild(mc);
  39.         }
  40.  
  41.     }
  42.  
  43.     /**
  44.      * 动画事件测试
  45.      * */
  46.     private test3():void{
  47.         var mc:starlingswf.SwfMovieClip = this.swf.createMovie("mc_Tain");
  48.         mc.x = 480 / 2;
  49.         mc.y = 320 / 2;
  50.         mc.addEventListener(egret.Event.COMPLETE,this.mcComplete,mc);
  51.         this.addChild(mc);
  52.     }
  53.  
  54.     private mcComplete(e:egret.Event):void{
  55.         console.log("mcComplete");
  56.     }

来个截图

No Comment

Post A Comment