scene_page_dir.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import { _decorator, Component, Node } from 'cc';
  2. import { scene_item_data } from '../../data/data';
  3. import { config } from '../config';
  4. const { ccclass, property } = _decorator;
  5. @ccclass('scene_page_dir')
  6. export class scene_page_dir extends Component {
  7. @property(Node) btn_left:Node = null;
  8. @property(Node) btn_right:Node = null;
  9. @property(Node) btn_up:Node = null;
  10. @property(Node) btn_down:Node = null;
  11. private mLeftCallBack = null;
  12. private mRightCallBack = null;
  13. private mType:number = 0;
  14. public initView(type:number,left_call,right_call){
  15. this.mLeftCallBack = left_call;
  16. this.mRightCallBack = right_call;
  17. this.btn_left.active = false;
  18. this.btn_right.active = false;
  19. this.btn_down.active = false;
  20. this.mType = type;
  21. this.btn_up.active = false;
  22. if(type===config.Scene_Type_List.single_screen){
  23. }else{
  24. if(type===config.Scene_Type_List.many_screen_switch_up_down){
  25. this.btn_down.active = true;
  26. this.btn_up.active = true;
  27. }else{
  28. this.btn_left.active = true;
  29. this.btn_right.active = true;
  30. }
  31. }
  32. this.btn_up.off(Node.EventType.TOUCH_END)
  33. this.btn_up.on(Node.EventType.TOUCH_END,()=>{
  34. if(this.mLeftCallBack!=null){
  35. this.mLeftCallBack()
  36. }
  37. })
  38. this.btn_down.off(Node.EventType.TOUCH_END)
  39. this.btn_down.on(Node.EventType.TOUCH_END,()=>{
  40. if(this.mRightCallBack!=null){
  41. this.mRightCallBack()
  42. }
  43. })
  44. this.btn_left.off(Node.EventType.TOUCH_END)
  45. this.btn_left.on(Node.EventType.TOUCH_END,()=>{
  46. if(this.mLeftCallBack!=null){
  47. this.mLeftCallBack()
  48. }
  49. })
  50. this.btn_right.off(Node.EventType.TOUCH_END)
  51. this.btn_right.on(Node.EventType.TOUCH_END,()=>{
  52. if(this.mRightCallBack!=null){
  53. this.mRightCallBack()
  54. }
  55. })
  56. }
  57. hideUpBtn(){
  58. this.btn_left.active = false;
  59. this.btn_up.active = false;
  60. }
  61. hideNextBtn(){
  62. this.btn_right.active = false;
  63. this.btn_down.active = false;
  64. }
  65. hideAllBtn(){
  66. this.hideUpBtn()
  67. this.hideNextBtn()
  68. }
  69. showAllBtn(){
  70. if(this.mType===config.Scene_Type_List.many_screen_switch_up_down){
  71. this.btn_down.active = true;
  72. this.btn_up.active = true;
  73. }else{
  74. this.btn_left.active = true;
  75. this.btn_right.active = true;
  76. }
  77. }
  78. }