// IceMelt.ts



const { ccclass, property } = cc._decorator;

@ccclass()
export class IceMelt extends cc.Component {

    speed: number = 1;

    //是否融化
    private _isMelt: boolean = false;
    private _time: number = 0;
    private _material: cc.MaterialVariant;

    start() {
        this._material = this.node.getComponent(cc.Sprite).getMaterial(0);
    }

    update(dt) {
        if (this._material && this._isMelt) {
            this._material.setProperty('u_time', this._time);
            this._time += dt * this.speed;
        }
    }

    //开始融化
    startMelt() {
        this._isMelt = true;
        this._time = 0;
    }
}