CocosCreator-Shader-Effect-.../assets/scripts/OutterGlowEffectScene.ts

42 lines
1.3 KiB
TypeScript
Raw Normal View History

2019-12-19 02:52:32 +00:00
const { ccclass, property } = cc._decorator;
@ccclass
export default class MainSceneCtrl extends cc.Component {
@property(cc.Sprite)
exampleSprite: cc.Sprite = null;
@property(cc.Label)
exampleLabel: cc.Label = null;
start() {
this._updateSpriteOutlineWidth(0);
this._updateLabelOutlineWidth(0);
}
onSideCallBack(slider: cc.Slider, customEventData: string) {
this._updateSpriteOutlineWidth(slider.progress / 100);
this._updateLabelOutlineWidth(slider.progress / 100);
}
/**
*
*
* 1.
* 2. unitform
* 3.
*
* @property outlineSize [0,1] 0.5*0.5 *0.5
*/
private _updateSpriteOutlineWidth(outlineSize: number) {
let spriteMaterial: cc.Material = this.exampleSprite.getMaterial(0);
spriteMaterial.setProperty("outlineSize", outlineSize);
this.exampleSprite.setMaterial(0, spriteMaterial);
}
private _updateLabelOutlineWidth(outlineSize: number) {
let labelMaterial: cc.Material = this.exampleLabel.getMaterial(0);
labelMaterial.setProperty("outlineSize", outlineSize);
this.exampleLabel.setMaterial(0, labelMaterial);
}
}