import { Laya } from "Laya" ; import { Sprite } from "laya/display/Sprite" ; import { Stage } from "laya/display/Stage" ; import { Event } from "laya/events/Event" ; import { Browser } from "laya/utils/Browser" ; import { Main } from "./../Main" ; export class Sprite_Container { private apesCtn : Sprite ; Main : typeof Main = null ; constructor ( maincls ) { this . Main = maincls ; Laya . init ( Browser . clientWidth , Browser . clientHeight ) ; Laya . stage . alignV = Stage . ALIGN_MIDDLE ; Laya . stage . alignH = Stage . ALIGN_CENTER ; Laya . stage . scaleMode = "showall" ; Laya . stage . bgColor = "#232628" ; this . createApes ( ) ; } private createApes ( ) { var layoutRadius = 150 ; var radianUnit = Math . PI / 2 ; this . apesCtn = new Sprite ( ) ; this . Main . box2D . addChild ( this . apesCtn ) ; for ( var i = 0 ; i < 4 ; i ++ ) { var ape = new Sprite ( ) ; ape . loadImage ( "res/apes/monkey" + i + ".png" ) ; ape . pivot ( 55 , 72 ) ; ape . pos ( Math . cos ( radianUnit * i ) * layoutRadius , Math . sin ( radianUnit * i ) * layoutRadius ) ; this . apesCtn . addChild ( ape ) ; } this . apesCtn . pos ( Laya . stage . width / 2 , Laya . stage . height / 2 ) ; Laya . timer . frameLoop ( 1 , this , this . animate ) ; } private animate ( e = null ) { this . apesCtn . rotation += 1 ; } dispose ( ) { Laya . timer . clear ( this , this . animate ) ; } }