EventButton.ts 417 B

1234567891011121314151617181920212223
  1. const {ccclass, property} = cc._decorator;
  2. /**
  3. * 主界面的事件按钮
  4. */
  5. @ccclass
  6. export default class EventButton extends cc.Component {
  7. @property(cc.Sprite)
  8. mIcon: cc.Sprite = null;
  9. private callback:()=>void;
  10. public setCallback(callback:()=>void){
  11. this.callback = callback;
  12. }
  13. public onclick(){
  14. if(this.callback){
  15. this.callback();
  16. }
  17. }
  18. }