import { Laya } from "Laya" ; import { Sprite } from "laya/display/Sprite" ; import { Stage } from "laya/display/Stage" ; import { Browser } from "laya/utils/Browser" ; import { Tween } from "laya/utils/Tween" ; import { WebGL } from "laya/webgl/WebGL" ; import { Main } from "./../Main" ; export class Tween_SimpleSample { 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 . bgColor = "#232628" ; this . setup ( ) ; } private setup ( ) { var terminalX = 200 ; var characterA = this . createCharacter ( "res/cartoonCharacters/1.png" ) ; characterA . pivot ( 46.5 , 50 ) ; characterA . y = 100 ; var characterB = this . createCharacter ( "res/cartoonCharacters/2.png" ) ; characterB . pivot ( 34 , 50 ) ; characterB . y = 250 ; this . Main . box2D . graphics . drawLine ( terminalX , 0 , terminalX , Laya . stage . height , "#FFFFFF" ) ; Tween . to ( characterA , { "x" : terminalX } , 1000 ) ; characterB . x = terminalX ; Tween . from ( characterB , { "x" : 0 } , 1000 ) ; } private createCharacter ( skin ) { var character = new Sprite ( ) ; character . loadImage ( skin ) ; this . Main . box2D . addChild ( character ) ; return character ; } dispose ( ) { this . Main . box2D . graphics . clear ( ) ; } }