/**
* name 容器
*/
module laya{
import Sprite = Laya.Sprite;
import Stage = Laya.Stage;
import Texture = Laya.Texture;
import Browser = Laya.Browser;
import Handler = Laya.Handler;
import WebGL = Laya.WebGL;
export class Sprite_Container{
private HeroCtn: Sprite;
constructor(){
Laya.init(Browser.clientWidth,Browser.clientHeight,WebGL);
Laya.stage.alignV = Stage.ALIGN_MIDDLE;//alignH:垂直对齐方式,默认值为"left"。 取值范围: "left" :居左对齐; "center" :居中对齐; "right" :居右对齐;
Laya.stage.alignH = Stage.ALIGN_CENTER;//alignH:水平对齐方式, 取值范围: "top" :居顶部对齐; "middle" :居中对齐; "bottom" :居底部对齐;
Laya.stage.scaleMode="showall";
Laya.stage.bgColor = "#232628";
this.createHero();
}
private createHero():void{
var layoutRadius : number = 150;//半径
var RadiusUnit : number =Math.PI/2;//半径单位
this.HeroCtn = new Sprite();
Laya.stage.addChild(this.HeroCtn);
for (var i :number = 0; i < 4; i++) {
var Hero : Sprite = new Sprite();
Hero.loadImage("res/hero"+ i +".png");
Hero.pivot(55,72);
Hero.pos(
Math.cos(RadiusUnit*i)*layoutRadius,
Math.sin(RadiusUnit*i)*layoutRadius
);
this.HeroCtn.addChild(Hero);
this.HeroCtn.pos(Laya.stage.width/2,Laya.stage.height/2);
Laya.timer.frameLoop(1,this,this.animate);
}
}
private animate(e:Event):void{
this.HeroCtn.rotation+=1;
} }
}
new laya.Sprite_Container();