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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
"use strict";
cc._RF.push(module, 'ddce69j8fFOFYJV2XdB+Cj/', 'role_head_item');
// Scripts/mod/role/view/role_head_item.js
 
"use strict";
 
// --------------------------------------------------------------------
// @author: whjing2012@syg.com(必填, 创建模块的人员)
// @description:
//      头像选择
// <br/>Create: new Date().toISOString()
// --------------------------------------------------------------------
var PlayerHead = require("playerhead");
 
var RoleHeadItem = cc.Class({
  "extends": PlayerHead,
  ctor: function ctor() {},
  initPanel: function initPanel() {
    this._super();
  },
  registerEvent: function registerEvent() {
    this._super();
  },
  onShow: function onShow() {
    this.setLockStatus(this.data.status == 1);
    this.setUsed(this.data.use == 1);
    this.setName(this.data.name);
    this.setHeadRes(this.data.face_id);
 
    if (this.extend_data.select_func) {
      this.extend_data.select_func(this);
    }
  },
  setData: function setData(data) {
    this.data = data;
    this.show(data);
  },
  setExtendData: function setExtendData(data) {
    this.extend_data = data;
  },
  // 设置名称
  setName: function setName(name) {
    if (name) {
      if (!this.name_node) {
        this.name_node = new cc.Node();
        this.name_label = this.name_node.addComponent(cc.Label);
        this.root_wnd.addChild(this.name_node);
        this.name_node.setPosition(0, -75);
        this.name_node.color = new cc.Color(0x68, 0x45, 0x2a);
        this.name_label.fontSize = 24;
      }
 
      this.name_label.string = name;
    }
  },
  // 设置使用状态 
  setUsed: function setUsed(bool) {
    if (!this.root_wnd) return;
 
    if (bool) {
      if (!this.use_node) {
        this.use_node = new cc.Node();
        this.use_node_sprite = this.use_node.addComponent(cc.Sprite);
        this.loadRes(PathTool.getUIIconPath("face", "txt_cn_face_use"), function (bg_sp) {
          this.use_node_sprite.spriteFrame = bg_sp;
        }.bind(this));
        this.root_wnd.addChild(this.use_node, 100);
        this.use_node.setPosition(12, -33);
      }
 
      this.use_node.active = true;
    } else if (this.use_node) {
      this.use_node.active = false;
    }
  },
  // 设置选择状态 
  setSelected: function setSelected(bool) {
    if (!this.root_wnd) return;
 
    if (bool) {
      if (!this.select) {
        this.select = new cc.Node();
        this.select_sprite = this.select.addComponent(cc.Sprite);
        var common_res_path = PathTool.getCommonIcomPath("common_1060");
        this.loadRes(common_res_path, function (sf_obj) {
          this.select_sprite.spriteFrame = sf_obj;
        }.bind(this));
        this.root_wnd.addChild(this.select);
      }
 
      this.select.active = bool;
      this.select.runAction(cc.repeatForever(cc.sequence(cc.fadeIn(0.7), cc.fadeOut(0.7))));
    } else if (this.select) {
      this.select.active = bool;
      this.select.stopAllActions();
    }
  },
  onDelete: function onDelete() {
    if (this.select) {
      this.select.destroy();
      this.select = null;
      this.select_sprite = null;
    }
 
    if (this.use_node) {
      this.use_node.destroy();
      this.use_node = null;
      this.use_node_sprite = null;
    }
  }
});
module.exports = RoleHeadItem;
 
cc._RF.pop();