EventHelp.ts 840 B

12345678910111213141516171819202122
  1. const { ccclass, property } = cc._decorator;
  2. @ccclass
  3. export class EventHelp extends cc.Component {
  4. @property(cc.Component.EventHandler) beginHandler: cc.Component.EventHandler = null;
  5. @property(cc.Component.EventHandler) moveHandler: cc.Component.EventHandler = null;
  6. @property(cc.Component.EventHandler) endHandler: cc.Component.EventHandler = null;
  7. start() {
  8. this.node.on(cc.Node.EventType.TOUCH_START, (e: TouchType) => {
  9. this.beginHandler && this.beginHandler.emit([e]);
  10. }, this);
  11. this.node.on(cc.Node.EventType.TOUCH_MOVE, (e: TouchType) => {
  12. this.beginHandler && this.moveHandler.emit([e]);
  13. }, this);
  14. this.node.on(cc.Node.EventType.TOUCH_END, (e: TouchType) => {
  15. this.beginHandler && this.endHandler.emit([e]);
  16. }, this);
  17. }
  18. }