StarlingSwf-Egret
By zmLiu In StarlingSwf目录
- StarlingSwf介绍
- Egret介绍
- 关键代码
- 下载与安装
关键代码
private swf:starlingswf.Swf;
-
/**
-
* 创建游戏场景
-
*/
-
private createGameScene():void{
-
var swfData:Object = RES.getRes("test_swf");
-
var spriteSheet:egret.SpriteSheet = RES.getRes("test");
-
-
var assetsManager = new starlingswf.SwfAssetManager();
-
assetsManager.addSpriteSheet("test",spriteSheet);
-
-
this.swf = new starlingswf.Swf(swfData,assetsManager,60);
-
-
this.test1();
-
-
egret.Profiler.getInstance().run();
-
-
}
-
-
/**
-
* Sprite测试
-
* */
-
private test1():void{
-
var sprite:starlingswf.SwfSprite = this.swf.createSprite("spr_1");
-
this.addChild(sprite);
-
}
-
-
/**
-
* MovieClip测试
-
* */
-
private test2():void{
-
-
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"];
-
for(var i:number = 0 ; i < 50 ; i++){
-
var mcName:string = mcNames[Math.floor(Math.random() * mcNames.length)];
-
var mc:starlingswf.SwfMovieClip = this.swf.createMovie(mcName);
-
mc.x = Math.random() * 480;
-
mc.y = Math.random() * 320;
-
this.addChild(mc);
-
}
-
-
}
-
-
/**
-
* 动画事件测试
-
* */
-
private test3():void{
-
var mc:starlingswf.SwfMovieClip = this.swf.createMovie("mc_Tain");
-
mc.x = 480 / 2;
-
mc.y = 320 / 2;
-
mc.addEventListener(egret.Event.COMPLETE,this.mcComplete,mc);
-
this.addChild(mc);
-
}
-
-
private mcComplete(e:egret.Event):void{
-
console.log("mcComplete");
-
}
来个截图
No Comment