PlayerController.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. cc.Class({
  2. extends: require("BasePlayerController"),
  3. properties: {
  4. leftTouchNode:cc.Node,
  5. rightTouchNode:cc.Node,
  6. charactor:cc.Node,
  7. },
  8. onLoad () {
  9. //注册回调事件
  10. let Self = this;
  11. this.leftTouchNode.on('gesture', function (event) {
  12. console.log(event.name);
  13. Self.leftGesture(event.name);
  14. })
  15. this.rightTouchNode.on('gesture', function (event) {
  16. console.log(event.name);
  17. Self.rightGesture(event.name);
  18. })
  19. },
  20. start () {
  21. this.init();
  22. },
  23. init(){
  24. //角色脚本
  25. this.ctorScp = this.charactor.getComponent('BaseCharactor');
  26. },
  27. leftGesture(name)
  28. {
  29. if(name == 'up')
  30. {
  31. this.ctorScp.attack(1);
  32. }
  33. else if(name == 'down')
  34. {
  35. }
  36. else if(name == 'left')
  37. {
  38. }
  39. else if(name == 'right')
  40. {
  41. this.ctorScp.attack(1);
  42. }
  43. },
  44. rightGesture(name)
  45. {
  46. if(name == 'up')
  47. {
  48. this.ctorScp.attack(0);
  49. }
  50. else if(name == 'down')
  51. {
  52. }
  53. else if(name == 'left')
  54. {
  55. this.ctorScp.attack(0);
  56. }
  57. else if(name == 'right')
  58. {
  59. }
  60. },
  61. // update (dt) {},
  62. });