Test.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { _decorator, Component, Node, tween, Vec3 } from 'cc';
  2. const { ccclass, property } = _decorator;
  3. @ccclass('Test')
  4. export class Test extends Component {
  5. @property({ type: Node, tooltip: "test" })
  6. testNode: Node;
  7. start() {
  8. // systemEvent.setAccelerometerEnabled(true);
  9. // systemEvent.on(SystemEventType.DEVICEMOTION, this.onDeviceMotionEvent, this);
  10. }
  11. private onButon() {
  12. tween(this.testNode).
  13. to(0.5, { position: new Vec3(1, 1, 0) }, { easing: "bounceOutIn" }).
  14. delay(0.5).call(() => {
  15. this.testNode.position = new Vec3(100, 100, 0);
  16. }).
  17. // to(0.5, { position: new Vec3(100, 100, 1,) }, { easing: "bounceInOut" }).
  18. // to(0.15, { position: v1 }, { easing: "sineOut" }).
  19. // to(0.2, { position: v3 }, { easing: "sineIn" }).
  20. // to(0.05, { position: nowPostion }, { easing: "sineIn" }).
  21. start();
  22. }
  23. onDestroy() {
  24. // systemEvent.off(SystemEventType.DEVICEMOTION, this.onDeviceMotionEvent, this);
  25. // }
  26. // onDeviceMotionEvent(event: EventAcceleration) {
  27. // console.log(event.acc.x + " " + event.acc.y);
  28. // }
  29. }
  30. }