colorBlock/assets/effect/融化.ts
YZ\249929363 4ca3daaa48 提交
2025-06-26 14:44:43 +08:00

33 lines
653 B
TypeScript

// 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;
}
}