difenduandada
2024-12-31 34abe6963b344c882358274957f4b992456fee40
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
"use strict";
cc._RF.push(module, '19045l0mIlJL47l1HTz/p4z', 'adventure_floor_result_item_panel');
// Scripts/mod/adventure/view/adventure_floor_result_item_panel.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: xxx@syg.com(必填, 创建模块的人员)
// @description:
//     收益物品展示
// <br/>Create: 2019-05-14 11:11:02
// --------------------------------------------------------------------
var PathTool = require("pathtool");
 
var Adventure_floor_result_itemPanel = cc.Class({
  "extends": BasePanel,
  ctor: function ctor() {
    this.prefabPath = PathTool.getPrefabPath("adventure", "adventure_floor_result_item");
  },
  // 可以初始化声明一些变量的
  initConfig: function initConfig() {
    this.is_completed = false;
  },
  // 初始化一些配置数据,可以用于声明一些变量之类的
  initPanel: function initPanel() {
    this.init_pos_y = this.root_wnd.y;
    this.container = this.root_wnd.getChildByName("container");
    this.item_name = this.container.getChildByName("item_name").getComponent(cc.Label);
    this.item_num = this.container.getChildByName("item_num").getComponent(cc.Label);
    this.playEnterActions();
 
    if (this.data) {
      this.updateInfo();
    }
  },
  // 注册事件监听的接口,不需要手动调用,如果是使用gcore.GlobalEvent监听,可以直接调用addGlobalEvent
  registerEvent: function registerEvent() {},
  playEnterActions: function playEnterActions() {
    this.root_wnd.x = 200;
    this.root_wnd.opacity = 0;
    var move_to = cc.moveTo(0.2, cc.v2(460, this.init_pos_y));
    var fade_in = cc.fadeIn(0.2);
    var move_to_1 = cc.moveTo(0.1, cc.v2(360, this.init_pos_y));
    this.root_wnd.runAction(cc.sequence(cc.spawn(move_to, fade_in), move_to_1));
  },
  setData: function setData(data) {
    this.data = data;
 
    if (this.root_wnd) {
      this.updateInfo();
    }
  },
  updateInfo: function updateInfo() {
    if (this.data) {
      var item_config = Utils.getItemConfig(this.data.bid);
 
      if (item_config) {
        if (this.item_icon == null) {
          this.item_icon = Utils.createImage(this.container, null, -this.container.width / 2 + 164, 0, cc.v2(0.5, 0.5));
          this.item_icon.node.setScale(0.4);
        }
 
        if (this.item_icon_res != item_config.icon) {
          this.item_icon_res = item_config.icon;
          this.loadRes(PathTool.getItemRes(item_config.icon), function (sf_obj) {
            this.item_icon.spriteFrame = sf_obj;
          }.bind(this));
        }
 
        this.item_name.string = item_config.name;
        this.item_num.string = this.data.num;
      }
    }
  },
  // 预制体加载完成之后,添加到对应主节点之后的回调可以设置一些数据了
  onShow: function onShow(params) {},
  // 面板设置不可见的回调,这里做一些不可见的屏蔽处理
  onHide: function onHide() {},
  // 当面板从主节点释放掉的调用接口,需要手动调用,而且也一定要调用
  onDelete: function onDelete() {}
});
 
cc._RF.pop();