FrontAccelerationBand.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. const PlayerStateStatic = require('PlayerState');
  2. const ai = require('Ai_count');
  3. cc.Class({
  4. extends: cc.Component,
  5. properties: {
  6. },
  7. start: function () {
  8. },
  9. // 只在两个碰撞体开始接触时被调用一次
  10. onBeginContact: function (contact, selfCollider, otherCollider) {
  11. CustomLog("进入,","自己",selfCollider.node.name,"其他",otherCollider.node.name);
  12. if(otherCollider.node.name === 'Hero')
  13. {
  14. var line = otherCollider.node.getChildByName("Player").getChildByName("PlayerCollisionLine");
  15. var PlayerStateScript = otherCollider.getComponent("PlayerState");
  16. PlayerStateScript.CurrentInZoneType = PlayerStateStatic.ZoneType.FrontAccelerationBand;
  17. // cc.log("触碰点 左面 进",x);
  18. // cc.log("触碰点",PlayerStateScript.CurrentInZoneType );
  19. }
  20. },
  21. // 只在两个碰撞体结束接触时被调用一次
  22. onEndContact: function (contact, selfCollider, otherCollider) {
  23. },
  24. // 每次将要处理碰撞体接触逻辑时被调用
  25. onPreSolve: function (contact, selfCollider, otherCollider) {
  26. },
  27. // 每次处理完碰撞体接触逻辑时被调用
  28. onPostSolve: function (contact, selfCollider, otherCollider) {
  29. },
  30. // onCollisionEnter: function (other) {
  31. // if(other.node.name === 'PlayerCollisionLine')
  32. // {
  33. // var PlayerCollisionLine = other.getComponent("PlayerCollisionLine");
  34. // // cc.log("触碰点 左面 进",PlayerCollisionLine);
  35. // var PlayerStateScript = PlayerCollisionLine.Hero.getComponent("PlayerState");
  36. // PlayerStateScript.CurrentInZoneType = PlayerStateStatic.ZoneType.FrontAccelerationBand;
  37. // // cc.log("触碰点 左面 进",x);
  38. // // cc.log(PlayerStateScript.CurrentInZoneType );
  39. // }
  40. //
  41. // if(other.node.name === 'PlayerCollisionLine_ai')
  42. // {
  43. // console.log('相交 左 进');
  44. // // cc.log("触碰点 左面 进",other);
  45. // var PlayerCollisionLine = other.getComponent("PlayerCollisionLine");
  46. // var x =PlayerCollisionLine.Hero.x;
  47. // var userData = {
  48. // name: 0,
  49. // p: x,
  50. // };
  51. // this.getComponent("Ai_count").addData("ai",userData);
  52. // }
  53. //
  54. // },
  55. // onCollisionStay: function (other) {
  56. //
  57. // if(other.node.name === 'PlayerCollisionLine_ai')
  58. // {
  59. // // console.log('相交 左 中');
  60. // }
  61. // },
  62. // onCollisionExit: function (other) {
  63. // if(other.node.name === 'PlayerCollisionLine_ai')
  64. // {
  65. // // console.log('相交 左 出');
  66. // }
  67. // }
  68. });