
const { ccclass, property } = cc._decorator;
@ccclass
export default class Clund_06 extends cc.Component {
    @property(cc.Node)
    yun_1: cc.Node = null;
    @property(cc.Node)
    yun_2: cc.Node = null;
    @property(cc.Node)
    yun_3: cc.Node = null;
    @property(cc.Node)
    yun_4: cc.Node = null;
    @property(cc.Node)
    yun_5: cc.Node = null;
    @property(cc.Node)
    yun_6: cc.Node = null;
    @property(cc.Node)
    yun_7: cc.Node = null;
    private speed: number;
    private speed2: number;
    private width: number;//背景图宽度
    public onEnable() {

    }
    protected onDestroy(): void {
    }
    protected onLoad(): void {
        this.speed = 0.5;
        this.speed2 = 0.8;
        let size = cc.view.getCanvasSize();
        let scale = (size.width / size.height) / (1920 / 1080);
        if (scale > 1) {
            Math.floor(this.node.width *= scale);
            Math.floor(this.node.width *= scale);
            Math.floor(this.node.width *= scale);
        }
        this.width = this.node.width / 2;
    }

    protected update(dt) {
        this.yun_1.x += this.speed;
        this.yun_2.x += this.speed2;
        this.yun_4.x += this.speed2;
        this.yun_3.x -= this.speed;
        this.yun_5.x -= this.speed2;
        this.yun_6.x -= this.speed;
        this.yun_7.x -= this.speed;
        if (this.yun_1.x > this.width + 200)
            this.yun_1.x = -this.width - 150;
        if (this.yun_2.x > this.width + 200)
            this.yun_2.x = -this.width - 150;
        if (this.yun_4.x > this.width + 200)
            this.yun_4.x = -this.width - 150;


        if (this.yun_3.x < -this.width - 200)
            this.yun_3.x = this.width + 150;
        if (this.yun_5.x < -this.width - 200)
            this.yun_5.x = this.width + 150;

        if (this.yun_6.x < -this.width - 200)
            this.yun_6.x = this.width + 150;
        if (this.yun_7.x < -this.width - 200)
            this.yun_7.x = this.width + 150;
    }

}
