dd
This commit is contained in:
@@ -14,59 +14,38 @@ export class HeroCardViewComp extends CCComp {
|
||||
card_name:string = "hero_card";
|
||||
card_type:string = "hero";
|
||||
card_uid:number = 1000;
|
||||
/** 方向 */
|
||||
private _dir: Vec2 = new Vec2(0, 0);
|
||||
public get dir(): Vec2 {
|
||||
return this._dir;
|
||||
}
|
||||
public set dir(value: Vec2) {
|
||||
this._dir = value;
|
||||
}
|
||||
pos_x=0;
|
||||
pos_y=0;
|
||||
|
||||
|
||||
protected onLoad(): void {
|
||||
this.node.on(NodeEventType.TOUCH_START, this.onTouch, this);
|
||||
this.node.on(NodeEventType.TOUCH_MOVE, this.onTouchMove, this);
|
||||
this.node.on(NodeEventType.TOUCH_END, this.onTouchEnd, this);
|
||||
this.node.on(NodeEventType.TOUCH_CANCEL, this.onTouchEnd, this);
|
||||
oops.message.on("destroy hero_card", this.on_destroy_node, this);
|
||||
// this.node.on(NodeEventType.TOUCH_START, this.onTouch, this);
|
||||
// this.node.on(NodeEventType.TOUCH_MOVE, this.onTouchMove, this);
|
||||
// this.node.on(NodeEventType.TOUCH_END, this.onTouchEnd, this);
|
||||
// this.node.on(NodeEventType.TOUCH_CANCEL, this.onTouchEnd, this);
|
||||
// oops.message.on("active_card_eid", this.do_active_card_eid, this);
|
||||
}
|
||||
|
||||
|
||||
private on_destroy_node(event: string, args: any) {
|
||||
// if(this.ent.eid == args){
|
||||
// this.reset();
|
||||
// }
|
||||
}
|
||||
onTouch(){
|
||||
smc.vm_data.cards.eid = this.ent.eid;
|
||||
let parent = this.node.parent;
|
||||
let active = parent.getChildByName("active");
|
||||
active.setPosition(this.pos_x,this.pos_y)
|
||||
active.active = true;
|
||||
active.setPosition(this.node.position.x+47.5,this.node.position.y+47.5);
|
||||
}
|
||||
onTouchMove(event: EventTouch) {
|
||||
smc.vm_data.cards.eid = this.ent.eid;
|
||||
// if(this.ent.eid == smc.vm_data.cards.eid){
|
||||
// this.node.getChildByName("active").active = true;
|
||||
// }else{
|
||||
// this.node.getChildByName("active").active = false;
|
||||
// }
|
||||
let delta = event.getDelta();
|
||||
this.node.setPosition(this.node.position.x+delta.x,this.node.position.y+delta.y);
|
||||
}
|
||||
onTouchEnd(){
|
||||
let parent = this.node.parent;
|
||||
let active = parent.getChildByName("active");
|
||||
active.setPosition(this.pos_x+47.5,this.pos_y+47.5)
|
||||
if(this.node.position.y-this.pos_y > 110){
|
||||
active.active = false;
|
||||
this.use_card()
|
||||
}else{
|
||||
this.node.setPosition(this.pos_x,this.pos_y);
|
||||
private do_active_card_eid(event: string, args: any) {
|
||||
console.log("active_card_eid",args,this.ent.eid)
|
||||
if(this.ent.eid != args.eid){
|
||||
this.no_active()
|
||||
}
|
||||
}
|
||||
do_active(){
|
||||
|
||||
}
|
||||
no_active(){
|
||||
// this.node.getChildByName("active").active=false;
|
||||
// this.node.getChildByName("use").active=false;
|
||||
// this.node.getChildByName("bag").active=false;
|
||||
}
|
||||
doit(){
|
||||
// this.do_active()
|
||||
console.log("doit",this.ent)
|
||||
smc.vm_data.cards.eid = this.ent.eid;
|
||||
// oops.message.dispatchEvent("active_card_eid",{eid:this.ent.eid})
|
||||
}
|
||||
|
||||
use_card(){
|
||||
if(smc.vm_data.gold.min >= CardSet[this.card_uid].level){
|
||||
oops.message.dispatchEvent("do_add_hero",{uuid:this.card_uid})
|
||||
@@ -74,13 +53,12 @@ export class HeroCardViewComp extends CCComp {
|
||||
smc.vm_data.gold.min -= CardSet[this.card_uid].level;
|
||||
}else{
|
||||
oops.gui.toast("金币不够");
|
||||
this.node.setPosition(this.pos_x,this.pos_y);
|
||||
}
|
||||
}
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
start() {
|
||||
this.pos_x=this.node.position.x;
|
||||
this.pos_y=this.node.position.y;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/** 全局消息逻辑处理 */
|
||||
|
||||
Reference in New Issue
Block a user