Actor.js 657 B

123456789101112131415161718192021222324252627
  1. const Api = require('../net/Api');
  2. var DWTool = require('../utils/DWTool');
  3. cc.Class({
  4. extends: cc.Component,
  5. properties: {
  6. avatarSprite: cc.Sprite,
  7. genderSprite: cc.Sprite,
  8. nickLabel: cc.Label,
  9. starCountLabel: cc.Label,
  10. },
  11. bind(user) {
  12. Api.createImageFromUrl(user.head, (spriteFrame) => {
  13. this.avatarSprite.spriteFrame = spriteFrame;
  14. });
  15. DWTool.setGenderIcon(user.gender).then(spriteFrame => {
  16. this.genderSprite.spriteFrame = spriteFrame;
  17. });
  18. this.nickLabel.string = user.nick;
  19. this.starCountLabel.string = user.stars;
  20. },
  21. });