完善马赛卡demo

This commit is contained in:
caizhitao 2020-01-01 16:31:44 +08:00
parent c9f4f83f19
commit 35bd6ec693
2 changed files with 823 additions and 43 deletions

File diff suppressed because it is too large Load Diff

View File

@ -6,10 +6,11 @@ export default class MosaicEffectScene extends cc.Component {
private _xMosaicCountSliderLabel: cc.Label = null; private _xMosaicCountSliderLabel: cc.Label = null;
private _yMosaicCountSlider: cc.Slider = null; private _yMosaicCountSlider: cc.Slider = null;
private _yMosaicCountSliderLabel: cc.Label = null; private _yMosaicCountSliderLabel: cc.Label = null;
private _mosaicCountSlider: cc.Slider = null;
private _mosaicCountSliderLabel: cc.Label = null;
private _examplesParentNode: cc.Node = null; private _examplesParentNode: cc.Node = null;
onLoad() { onLoad() {
// 关闭动态合图 // 关闭动态合图
cc.dynamicAtlasManager.enabled = false; cc.dynamicAtlasManager.enabled = false;
@ -18,6 +19,8 @@ export default class MosaicEffectScene extends cc.Component {
this._xMosaicCountSliderLabel = cc.find("Canvas/Content/Sliders/XMosaicCountSlider/ValueLabel").getComponent(cc.Label); this._xMosaicCountSliderLabel = cc.find("Canvas/Content/Sliders/XMosaicCountSlider/ValueLabel").getComponent(cc.Label);
this._yMosaicCountSlider = cc.find("Canvas/Content/Sliders/YMosaicCountSlider/Slider").getComponent(cc.Slider); this._yMosaicCountSlider = cc.find("Canvas/Content/Sliders/YMosaicCountSlider/Slider").getComponent(cc.Slider);
this._yMosaicCountSliderLabel = cc.find("Canvas/Content/Sliders/YMosaicCountSlider/ValueLabel").getComponent(cc.Label); this._yMosaicCountSliderLabel = cc.find("Canvas/Content/Sliders/YMosaicCountSlider/ValueLabel").getComponent(cc.Label);
this._mosaicCountSlider = cc.find("Canvas/Content/Sliders/MosaicCountSlider/Slider").getComponent(cc.Slider);
this._mosaicCountSliderLabel = cc.find("Canvas/Content/Sliders/MosaicCountSlider/ValueLabel").getComponent(cc.Label);
this._examplesParentNode = cc.find("Canvas/Content/Examples"); this._examplesParentNode = cc.find("Canvas/Content/Examples");
} }
@ -25,17 +28,30 @@ export default class MosaicEffectScene extends cc.Component {
onEnable() { onEnable() {
this._xMosaicCountSlider.node.on("slide", this._onSliderChanged, this); this._xMosaicCountSlider.node.on("slide", this._onSliderChanged, this);
this._yMosaicCountSlider.node.on("slide", this._onSliderChanged, this); this._yMosaicCountSlider.node.on("slide", this._onSliderChanged, this);
this._mosaicCountSlider.node.on("slide", this._onSliderChangedTogether, this);
} }
onDisable() { onDisable() {
this._xMosaicCountSlider.node.off("slide", this._onSliderChanged, this); this._xMosaicCountSlider.node.off("slide", this._onSliderChanged, this);
this._yMosaicCountSlider.node.off("slide", this._onSliderChanged, this); this._yMosaicCountSlider.node.off("slide", this._onSliderChanged, this);
this._mosaicCountSlider.node.off("slide", this._onSliderChangedTogether, this);
} }
start() { start() {
this._onSliderChanged(); this._onSliderChanged();
} }
private _onSliderChangedTogether() {
let mosaicCount = Math.round(this._mosaicCountSlider.progress * 300);
this._mosaicCountSliderLabel.string = `${mosaicCount}`;
// 更新材质
this._updateRenderComponentMaterial({
xBlockCount: mosaicCount,
yBlockCount: mosaicCount
});
}
private _onSliderChanged() { private _onSliderChanged() {
let xMosaicCount = Math.round(this._xMosaicCountSlider.progress * 300); let xMosaicCount = Math.round(this._xMosaicCountSlider.progress * 300);
this._xMosaicCountSliderLabel.string = `${xMosaicCount}`; this._xMosaicCountSliderLabel.string = `${xMosaicCount}`;