scene_page_dir.ts 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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.on(Node.EventType.TOUCH_END,()=>{
  33. if(this.mLeftCallBack!=null){
  34. this.mLeftCallBack()
  35. }
  36. })
  37. this.btn_down.on(Node.EventType.TOUCH_END,()=>{
  38. if(this.mRightCallBack!=null){
  39. this.mRightCallBack()
  40. }
  41. })
  42. this.btn_left.on(Node.EventType.TOUCH_END,()=>{
  43. if(this.mLeftCallBack!=null){
  44. this.mLeftCallBack()
  45. }
  46. })
  47. this.btn_right.on(Node.EventType.TOUCH_END,()=>{
  48. if(this.mRightCallBack!=null){
  49. this.mRightCallBack()
  50. }
  51. })
  52. }
  53. hideUpBtn(){
  54. this.btn_left.active = false;
  55. this.btn_up.active = false;
  56. }
  57. hideNextBtn(){
  58. this.btn_right.active = false;
  59. this.btn_down.active = false;
  60. }
  61. hideAllBtn(){
  62. this.hideUpBtn()
  63. this.hideNextBtn()
  64. }
  65. showAllBtn(){
  66. if(this.mType===config.Scene_Type_List.many_screen_switch_up_down){
  67. this.btn_down.active = true;
  68. this.btn_up.active = true;
  69. }else{
  70. this.btn_left.active = true;
  71. this.btn_right.active = true;
  72. }
  73. }
  74. }