2022-06-20 19:21:02 +08:00

26 lines
588 B
TypeScript

const {ccclass, property} = cc._decorator;
@ccclass
export default class IconBtn extends cc.Component {
@property(cc.Sprite)
btnSprite: cc.Sprite = null
@property(cc.Label)
titleLabel: cc.Label = null
callback: (title: string) => void
start () {
}
init(title: string, icon: cc.SpriteFrame) {
this.btnSprite.spriteFrame = icon
this.titleLabel.string = title
}
bindCallback(method: (title: string) => void) {
this.callback = method
}
onBtnClicked() {
this.callback && this.callback(this.titleLabel.string)
}
}