attributes_container.ts 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import { _decorator, Component, instantiate, Node, Prefab } from 'cc';
  2. import { Attributes } from '../Attributes';
  3. import { config } from '../../config';
  4. import { widget_item } from '../widget_item';
  5. import { att_click_data, att_container, widget_item_data } from '../../../data/data';
  6. const { ccclass, property } = _decorator;
  7. @ccclass('attributes_container')
  8. export class attributes_container extends Component {
  9. @property(Node) btn_add_image:Node = null;
  10. @property(Node) btn_add_animation:Node = null;
  11. @property(Node) btn_add_drop:Node = null;
  12. @property(Node) btn_add_click:Node = null;
  13. @property(Node) btn_add_slide:Node = null;
  14. @property(Prefab) item_prefab:Prefab = null;
  15. private cur_att_manager:Attributes = null
  16. private call_back = null;
  17. public initView(call,att_manager:Attributes){
  18. this.cur_att_manager = att_manager
  19. this.call_back = call;
  20. }
  21. addWidgetByType(type:number){
  22. // let node = instantiate(this.item_prefab)
  23. let node = this.cur_att_manager.getMain().control_view.getWidgetByType(type)
  24. // let temp_data = node.getComponent(widget_item).getData();
  25. // node.getComponent(widget_item).initWidgetByScene(data)
  26. let att = Attributes.Singleton.get_cur_att_data()
  27. // if(att.container_layer==null){
  28. // att.container_layer = new att_container
  29. // }
  30. // let data = new widget_item_data(temp_data.name,temp_data.type)
  31. // data.att = temp_data.att;
  32. // att.container_layer.widget_list.push(data)
  33. // if(this.call_back){
  34. // this.call_back()
  35. // }
  36. this.cur_att_manager.getMain().onPushEndWidget(node,att.id,type)
  37. }
  38. start() {
  39. this.btn_add_animation.on(Node.EventType.TOUCH_END,()=>{
  40. this.addWidgetByType(config.Widget_Type_List.ACTION_TYPE)
  41. })
  42. this.btn_add_image.on(Node.EventType.TOUCH_END,()=>{
  43. this.addWidgetByType(config.Widget_Type_List.IMG_TYPE)
  44. })
  45. this.btn_add_drop.on(Node.EventType.TOUCH_END,()=>{
  46. this.addWidgetByType(config.Widget_Type_List.DRAG_TYPE)
  47. })
  48. this.btn_add_click.on(Node.EventType.TOUCH_END,()=>{
  49. this.addWidgetByType(config.Widget_Type_List.CLICK_TYPE)
  50. })
  51. this.btn_add_slide.on(Node.EventType.TOUCH_END,()=>{
  52. this.addWidgetByType(config.Widget_Type_List.SLIDE_TYPE)
  53. })
  54. }
  55. update(deltaTime: number) {
  56. }
  57. }