cocos-awesome/assets/Scene/Mosaic/Mosaic.ts

19 lines
497 B
TypeScript
Raw Normal View History

2020-05-28 13:40:16 +00:00
const { ccclass, property } = cc._decorator;
@ccclass
export default class Mosaic extends cc.Component {
material: cc.Material = null;
onLoad() {
this.material = this.node.getChildByName('npc').getComponent(cc.Sprite).getMaterial(0);
}
setPixelCount(slide: cc.Slider, type: 'x' | 'y') {
this.material.setProperty(`${type}_count`, Math.floor(slide.progress * 100));
}
togglePixel(toggle: cc.Toggle) {
this.material.define('USE_MASAIC', toggle.isChecked, 0, true);
}
}