TalentIconItem.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Learn TypeScript:
  2. // - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
  3. // Learn Attribute:
  4. // - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
  5. // Learn life-cycle callbacks:
  6. // - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
  7. import { MateData } from "../../datas/MateData";
  8. import MyExtends from "../../tools/MyExtends";
  9. const { ccclass, property } = cc._decorator;
  10. @ccclass
  11. export default class TalentIconItem extends cc.Component {
  12. @property(cc.Sprite)
  13. img: cc.Sprite = null;
  14. mateid: number = 1;
  15. talentid: number = 1;
  16. Init(mateid, talentid) {
  17. this.mateid = mateid;
  18. this.talentid = talentid;
  19. cc.loader.loadRes("xiyou/talent/" + mateid + "-" + talentid, cc.SpriteFrame, (err, res) => {
  20. if (err) {
  21. return;
  22. }
  23. this.img.spriteFrame = res;
  24. });
  25. }
  26. Click_Btn() {
  27. //显示详情
  28. let pos = MyExtends.convetOtherNodeSpaceAR(this.node, cc.find("Canvas"));
  29. MateData.Ins.DisplayTalentDetaile(this.mateid, this.talentid, pos);
  30. }
  31. }