98 lines
2.7 KiB
TypeScript
98 lines
2.7 KiB
TypeScript
import Define from "../common/Define";
|
|
|
|
// Learn TypeScript:
|
|
// - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/typescript.html
|
|
// - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/typescript.html
|
|
// Learn Attribute:
|
|
// - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
|
|
// - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/reference/attributes.html
|
|
// Learn life-cycle callbacks:
|
|
// - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
|
|
// - [English] http://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
|
|
|
|
const {ccclass, property} = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class ViewBase extends cc.Component {
|
|
|
|
private isNeedAddEvent:boolean = true;
|
|
protected showActionType:number = Define.center;
|
|
|
|
isShow:boolean = false;
|
|
//显示
|
|
showView(){
|
|
if(this.isNeedAddEvent){
|
|
this.initView();
|
|
this.addEvent();
|
|
this.isNeedAddEvent = false;
|
|
}
|
|
|
|
this.node.setSiblingIndex(this.node.getParent().childrenCount)
|
|
|
|
this.node.active = true;
|
|
this.refreshView(true);
|
|
if(this.showActionType == Define.center){
|
|
this.node.position = cc.Vec2.ZERO;
|
|
}else{
|
|
this.showAction();
|
|
}
|
|
this.isShow = true;
|
|
}
|
|
|
|
//隐藏
|
|
hideView(){
|
|
this.node.position = new cc.Vec2(-9999,-9999);
|
|
this.node.active = false;
|
|
this.isShow = false;
|
|
}
|
|
|
|
refreshView(isFristRefresh:boolean = false){
|
|
|
|
}
|
|
|
|
refreshGoldInfo(){
|
|
|
|
}
|
|
|
|
//点击点击事件 //只调用一次
|
|
addEvent(){
|
|
// Common.addClickEvent(this.btn_getReward,this.onClick.bind(this));
|
|
}
|
|
/*
|
|
onClick(tag:string){
|
|
if(tag == "btn_getReward"){
|
|
}
|
|
}*/
|
|
//只调用一次
|
|
initView(){
|
|
|
|
}
|
|
|
|
showAction(){
|
|
|
|
if(this.showActionType == Define.left){
|
|
this.node.position = new cc.Vec2(-640,0);
|
|
}else if(this.showActionType == Define.right){
|
|
this.node.position = new cc.Vec2(640,0);
|
|
}else if(this.showActionType == Define.down){
|
|
this.node.position = new cc.Vec2(0,-1136);
|
|
}else if(this.showActionType == Define.up){
|
|
this.node.position = new cc.Vec2(0,1136);
|
|
}
|
|
|
|
let moveAction = cc.moveTo(0.5,cc.Vec2.ZERO).easing(cc.easeBackOut());
|
|
this.node.runAction(cc.sequence(moveAction,cc.callFunc(function(){
|
|
this.showActionCallBack()
|
|
}.bind(this))));
|
|
}
|
|
//动作
|
|
showActionCallBack(){
|
|
|
|
}
|
|
|
|
//额外的事件调用
|
|
executeEvent(eventTag:string = "defualt"){
|
|
|
|
}
|
|
}
|