RideBikeEnd.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. },
  5. start () {
  6. },
  7. // onCollisionEnter: function (other)
  8. // {
  9. // if(other.node.name === 'PlayerCollisionLine')
  10. // {
  11. // var Level = this.node.parent.parent;
  12. // var Canvas = Level.getComponent('LevelControl').Canvas;
  13. // var GameStates = Canvas.getComponent('GameStates');
  14. //
  15. // // other.node.parent.getComponent('HeroControl').EnableHeroMoving(false);
  16. // // other.node.parent.getComponent('HeroControl').SetCurrentSpeed(0);
  17. // other.node.parent.parent.getComponent('HeroControl').PlayerStateScript .CurrentSpeed = 0;
  18. // // other.node.parent.getComponent('HeroControl').ResetSpeed();
  19. // //获取场景
  20. // var scene = cc.director.getScene();
  21. // // cc.log("父亲",scene);
  22. // var charactor = scene.getChildByName("Hero").getChildByName("Player").getComponent("Charactor");
  23. // // cc.log("有么",charactor);
  24. // if (charactor != null) {
  25. // charactor.idle();
  26. // var Canvas = cc.find("Canvas");
  27. // Canvas.getComponent("NodeTouch").enableTouch = false;
  28. // }
  29. // }
  30. // },
  31. // onCollisionStay: function (other) {
  32. // // console.log('on collision stay');
  33. // },
  34. // onCollisionExit: function (other) {
  35. //
  36. // },
  37. onBeginContact: function (contact, selfCollider, otherCollider) {
  38. // CustomLog("撞了",otherCollider);
  39. // CustomLog("刚体 棍子限制 碰撞 进入 ,",otherCollider.node.name);
  40. if(otherCollider.node.name === 'Hero')
  41. {
  42. var Canvas = cc.find("Canvas");
  43. var GameStates = Canvas.getComponent('GameStates');
  44. // other.node.parent.getComponent('HeroControl').EnableHeroMoving(false);
  45. // other.node.parent.getComponent('HeroControl').SetCurrentSpeed(0);
  46. otherCollider.getComponent('HeroControl').PlayerStateScript .CurrentSpeed = 0;
  47. // other.node.parent.getComponent('HeroControl').ResetSpeed();
  48. //获取场景
  49. var scene = cc.director.getScene();
  50. // cc.log("父亲",scene);
  51. var charactor = scene.getChildByName("Hero").getChildByName("Player").getComponent("Charactor");
  52. // cc.log("有么",charactor);
  53. if (charactor != null) {
  54. charactor.idle();
  55. var Canvas = cc.find("Canvas");
  56. Canvas.getComponent("NodeTouch").enableTouch = false;
  57. }
  58. }
  59. },
  60. // 只在两个碰撞体结束接触时被调用一次
  61. onEndContact: function (contact, selfCollider, otherCollider) {
  62. },
  63. // 每次将要处理碰撞体接触逻辑时被调用
  64. onPreSolve: function (contact, selfCollider, otherCollider) {
  65. },
  66. // 每次处理完碰撞体接触逻辑时被调用
  67. onPostSolve: function (contact, selfCollider, otherCollider) {
  68. },
  69. });