|
@@ -1,69 +1,53 @@
|
|
|
cc.Class({
|
|
cc.Class({
|
|
|
- extends: require("basePlayerController"),
|
|
|
|
|
|
|
+ extends: require("BasePlayerController"),
|
|
|
|
|
|
|
|
properties: {
|
|
properties: {
|
|
|
- leftTouchNode:cc.Node,
|
|
|
|
|
- rightTouchNode:cc.Node,
|
|
|
|
|
- charactor:cc.Node,
|
|
|
|
|
|
|
+ leftTouchNode: cc.Node,
|
|
|
|
|
+ rightTouchNode: cc.Node,
|
|
|
|
|
+ charactor: cc.Node,
|
|
|
},
|
|
},
|
|
|
- onLoad () {
|
|
|
|
|
|
|
+ onLoad() {
|
|
|
//注册回调事件
|
|
//注册回调事件
|
|
|
let Self = this;
|
|
let Self = this;
|
|
|
- this.leftTouchNode.on('gesture', function (event) {
|
|
|
|
|
|
|
+ this.leftTouchNode.on('gesture', function(event) {
|
|
|
console.log(event.name);
|
|
console.log(event.name);
|
|
|
Self.leftGesture(event.name);
|
|
Self.leftGesture(event.name);
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- this.rightTouchNode.on('gesture', function (event) {
|
|
|
|
|
|
|
+ this.rightTouchNode.on('gesture', function(event) {
|
|
|
console.log(event.name);
|
|
console.log(event.name);
|
|
|
Self.rightGesture(event.name);
|
|
Self.rightGesture(event.name);
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
- start () {
|
|
|
|
|
|
|
+ start() {
|
|
|
this.init();
|
|
this.init();
|
|
|
},
|
|
},
|
|
|
- init(){
|
|
|
|
|
|
|
+ init() {
|
|
|
//角色脚本
|
|
//角色脚本
|
|
|
this.ctorScp = this.charactor.getComponent('baseCharactor');
|
|
this.ctorScp = this.charactor.getComponent('baseCharactor');
|
|
|
},
|
|
},
|
|
|
- leftGesture(name)
|
|
|
|
|
- {
|
|
|
|
|
- if(name == 'up')
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ leftGesture(name) {
|
|
|
|
|
+ if (name == 'up') {
|
|
|
this.ctorScp.attack(1);
|
|
this.ctorScp.attack(1);
|
|
|
- }
|
|
|
|
|
- else if(name == 'down')
|
|
|
|
|
- {
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
- else if(name == 'left')
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ } else if (name == 'down') {
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
- else if(name == 'right')
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ } else if (name == 'left') {
|
|
|
|
|
+
|
|
|
|
|
+ } else if (name == 'right') {
|
|
|
this.ctorScp.attack(1);
|
|
this.ctorScp.attack(1);
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- rightGesture(name)
|
|
|
|
|
- {
|
|
|
|
|
- if(name == 'up')
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ rightGesture(name) {
|
|
|
|
|
+ if (name == 'up') {
|
|
|
this.ctorScp.attack(0);
|
|
this.ctorScp.attack(0);
|
|
|
- }
|
|
|
|
|
- else if(name == 'down')
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ } else if (name == 'down') {
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
- else if(name == 'left')
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ } else if (name == 'left') {
|
|
|
this.ctorScp.attack(0);
|
|
this.ctorScp.attack(0);
|
|
|
- }
|
|
|
|
|
- else if(name == 'right')
|
|
|
|
|
- {
|
|
|
|
|
-
|
|
|
|
|
|
|
+ } else if (name == 'right') {
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// update (dt) {},
|
|
// update (dt) {},
|
|
|
-});
|
|
|
|
|
|
|
+});
|