import { Laya } from "Laya" ; import { Main } from "./../Main" ; import { Animation } from "laya/display/Animation" ; import { Stage } from "laya/display/Stage" ; import { Event } from "laya/events/Event" ; import { Rectangle } from "laya/maths/Rectangle" ; import { Loader } from "laya/net/Loader" ; import { Texture } from "laya/resource/Texture" ; import { Image } from "laya/ui/Image" ; import { Browser } from "laya/utils/Browser" ; import { Handler } from "laya/utils/Handler" ; import { WebGL } from "laya/webgl/WebGL" ; export class Animation_Altas { private AniConfPath : string = "res/fighter/fighter.json" ; Main : typeof Main = null ; constructor ( maincls ) { this . Main = maincls ; Laya . init ( Browser . clientWidth , Browser . clientHeight , WebGL ) ; Laya . stage . alignV = Stage . ALIGN_MIDDLE ; Laya . stage . alignH = Stage . ALIGN_CENTER ; Laya . stage . scaleMode = "showall" ; Laya . stage . bgColor = "#232628" ; Laya . loader . load ( this . AniConfPath , Handler . create ( this , this . createAnimation ) , null , Loader . ATLAS ) ; } private createAnimation ( _e = null ) { var ani = new Animation ( ) ; ani . loadAtlas ( this . AniConfPath ) ; ani . interval = 30 ; ani . index = 1 ; ani . play ( ) ; var bounds = ani . getGraphicBounds ( ) ; ani . pivot ( bounds . width / 2 , bounds . height / 2 ) ; ani . pos ( Laya . stage . width / 2 , Laya . stage . height / 2 ) ; this . Main . box2D . addChild ( ani ) ; } private onMouseDown ( ani ) { if ( ani . index > ani . count ) { ani . index = 0 ; } else { ani . index ++ ; } } }