EasyController.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import { EventHandler, _decorator, director } from 'cc';
  2. export class EasyControllerEvent{
  3. /**
  4. * Dispatched when camera rotating
  5. * @params rx: horizontal rotation
  6. * @params ry: vertical rotation.
  7. */
  8. public static CAMERA_ROTATE:string = 'EasyControllerEvent.CAMERA_ROTATE';
  9. /**
  10. * Dispatched when camera zooming
  11. * @params delta: amount of camera zoom
  12. */
  13. public static CAMERA_ZOOM:string = 'EasyControllerEvent.CAMERA_ZOOM';
  14. /**
  15. * Dispatched when the movement controller is moving
  16. * @param degree: direction in degrees, with positive X-axis as 0, increasing in a counter-clockwise direction.
  17. * @param strength: movement strength, [0.0, 1.0], can be used for fine-tuning the movement speed.
  18. */
  19. public static MOVEMENT:string = 'EasyControllerEvent.MOVEMENT';
  20. /**
  21. * Dispatched when the movement controller stops moving
  22. */
  23. public static MOVEMENT_STOP:string = 'EasyControllerEvent.MOVEMENT_STOP';
  24. /**
  25. * Dispatched when one of the buttons is pressed.
  26. * @param buttonName: string, indicates which button is pressed.
  27. */
  28. public static BUTTON:string = 'EasyControllerEvent.BUTTON';
  29. /**
  30. * Dispatched when screen is touched.
  31. */
  32. public static SCREEN_TOUCH_START:string = 'EasyControllerEvent.SCREEN_TOUCH_START';
  33. /**
  34. * Dispatched when screen is touched end.
  35. */
  36. public static SCREEN_TOUCH_END:string = 'EasyControllerEvent.SCREEN_TOUCH_END';
  37. }
  38. export class EasyController{
  39. public static on(type:string,callback:any,target?:any){
  40. director.on(type,callback,target);
  41. }
  42. public static off(type:string,callback?:any,target?:any){
  43. director.off(type,callback,target);
  44. }
  45. }