import { Tween } from 'cc'; import { Quat } from 'cc'; import { tween } from 'cc'; import { _decorator, Component, Node } from 'cc'; const { ccclass, property, executeInEditMode } = _decorator; @ccclass('SelfRotate') @executeInEditMode export class SelfRotate extends Component { @property speed: number = 360; @property onLoadPlay: boolean = true; public IsPlaying: boolean = false; start() { if (this.onLoadPlay) { this.play(); } } protected update(dt: number): void { if (this.IsPlaying) this.node.angle -= this.speed * dt //this.node.rotate(Quat.fromEuler(new Quat(), 0, 0, -this.speed * dt)) } play() { this.IsPlaying = true; // Tween.stopAllByTarget(this.node); // tween(this.node).by(1, { angle: this.speed }).repeatForever().start(); } stop() { this.IsPlaying = false; } }