RoleTitleItem.ts 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import Main from "../../../main/Main";
  2. import { __RoleIcon } from "../../data/sdata/SManage";
  3. /**
  4. * 称号节点
  5. */
  6. const {ccclass, property} = cc._decorator;
  7. @ccclass
  8. export default class RoleTitleItem extends cc.Component {
  9. @property(cc.Sprite)
  10. mIcon: cc.Sprite = null;//图片
  11. @property(cc.Label)
  12. mName: cc.Label = null;//名字
  13. @property(cc.Node)
  14. mLock: cc.Node = null;//锁
  15. public roleIcon:__RoleIcon
  16. private callback:(frameIcon:RoleTitleItem)=>void
  17. public setCallback(callback:(frameIcon:RoleTitleItem)=>void){
  18. this.callback = callback
  19. }
  20. public onclick(){
  21. if(this.callback){
  22. this.callback(this)
  23. }
  24. }
  25. public init(){
  26. this.mName.string = this.roleIcon.name
  27. cc.resources.load('icon/role_head/ch/'+this.roleIcon.icon, cc.SpriteFrame, (err, spriteFrame:cc.SpriteFrame) =>{
  28. if(err){
  29. cc.error(err);
  30. }else{
  31. this.mIcon.spriteFrame = spriteFrame;
  32. }
  33. });
  34. }
  35. public flushLock(main:Main){
  36. let roleIcon = main.player.roleIcon
  37. if(roleIcon.data.indexOf(this.roleIcon.id) < 0){
  38. this.mLock.active = true
  39. }else{
  40. this.mLock.active = false
  41. }
  42. }
  43. }