123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- import i18n from "../../../../i18n/i18n";
- /**
- * 对话中的属性选择
- */
- const {ccclass, property} = cc._decorator;
- /**
- * 对话属性内容
- */
- export interface DialogAttrContent{
- name:string,
- about:string,
- icon:string,
- vaule:number,
- type:number,//添加属性类型
- }
- @ccclass
- export default class FDialogAttr extends cc.Component {
- @property(cc.Label)
- mName: cc.Label = null;
- @property(cc.Label)
- mAbout: cc.Label = null;
- @property(cc.Label)
- mVaule: cc.Label = null;
- @property(cc.Sprite)
- mIcon: cc.Sprite = null;
- public attr:DialogAttrContent;
- private callback:(attr:FDialogAttr)=>void;
- public onclick(){
- if(this.callback){
- this.callback(this);
- }
- }
- public setCallback(callback:(attr:FDialogAttr)=>void){
- this.callback = callback;
- }
- public setVaule(attr:DialogAttrContent){
- this.attr = attr;
- this.mName.string = i18n.t(attr.name)
- this.mAbout.string = i18n.t(attr.about)
- this.mVaule.string = attr.vaule + '%';
- cc.resources.load('icon/attr/'+attr.icon, cc.SpriteFrame, (err, spriteFrame:cc.SpriteFrame) =>{
- if(err){
- cc.error(err);
- }else{
- this.mIcon.spriteFrame = spriteFrame;
- }
- } );
-
- }
- }
|