CocosCreator实现左右跳游戏JumpLR.zipconst{ccclass,property}=cc._decorator;@ccclassexportdefaultclassBoxextendscc.Component{@property(cc.Label)txtNum:cc.Label=null;privatemPrevBox:cc.Node=null;privatemNextBox:cc.Node=null;privatemOffset:number=0;//[-4,4]//LIFE-CYCLECALLBACKS://onLoad(){}start(){}//update(dt){}setOffset(offset:number){this.mOffset=offset;}getOffset(){returnthis.mOffset;}setPrev(prev:cc.Node){this.mPrevBox=prev;}getPrev(){returnthis.mPrevBox;}setNext(next:cc.Node){this.mNextBox=next;}getNext(){returnthis.mNextBox;}setNum(num:number){this.txtNum.string=`${num}`;}down(y:number){this.node.runAction(cc.sequence(cc.moveBy(0.4,0,y),cc.callFunc(()=>{NodeMgr.putBox(this.node);})));}}
1