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