const { ccclass, property } = cc._decorator; @ccclass export default class NewClass extends cc.Component { @property private speed: number = 1; @property private isRotate: boolean = true; @property private isChangeDir: boolean = false; @property private isChangeRotateDir: boolean = false; // LIFE-CYCLE CALLBACKS: // onLoad () {} start() { if ((this.isChangeDir && this.node.parent.x > 0) || (this.isChangeRotateDir && this.node.parent.scaleX < 0)) { this.speed = -this.speed; } } update(dt) { if (!this.isRotate) return; this.node.angle += this.speed; } }