const { ccclass , property } = cc . _decorator ; @ ccclass export default class Dissolve_color extends cc . Component { materialList : cc . Material [ ] = [ ] ; fadePct : number = 0 ; activeFlag : boolean = false ; symbol : number = 1 ; speed : number = 0.3 ; public StartShowEffect ( sprite ) { this . materialList = [ ] ; this . materialList . push ( sprite . getMaterial ( 0 ) ) ; if ( this . activeFlag ) return ; this . activeFlag = true ; } toggle ( ) { if ( this . activeFlag ) return ; this . activeFlag = true ; } update ( dt ) { if ( ! this . activeFlag ) return ; this . materialList . forEach ( ( material ) => material . setProperty ( 'fade_pct' , this . fadePct ) ) ; if ( this . fadePct >= 0 && this . fadePct <= 1 ) { this . fadePct += this . symbol * dt * this . speed ; } else { this . fadePct = this . fadePct > 1 ? 1 : 0 ; this . symbol = - this . symbol ; this . activeFlag = false ; } } }