CocosCreator实现左右跳游戏JumpLR.zip
const {ccclass, property} = cc._decorator;
@ccclass
export default class Box extends cc.Component {
@property(cc.Label)
txtNum: cc.Label = null;
private mPrevBox: cc.Node = null;
private mNextBox: cc.Node = null;
private mOffset: number = 0; // [-4,4]
// LIFE-CYCLE CALLBACKS:
// onLoad () {}
start () {
}
// update (dt) {}
setOffset(offset: number){
this.mOffset = offset;
}
getOffset(){
return this.mOffset;
}
setPrev(prev: cc.Node){
this.mPrevBox = prev;
}
getPrev(){
return this.mPrevBox;
}
setNext(next: cc.Node){
this.mNextBox = next;
}
getNext(){
return this.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