var renderEngine = cc.renderer.renderEngine; var Material = renderEngine.Material; var ShaderMaterial = require('ShaderMaterial'); let Transition = cc.Enum({ /** * !#en The none type. * @property {Number} NONE */ NONE: 0, /** * !#en The color type. * @property {Number} COLOR */ COLOR: 1, /** * !#en The sprite type. * @property {Number} SPRITE */ SPRITE: 2, /** * !#en The scale type * @property {Number} SCALE */ SCALE: 3 }); cc.Sprite.prototype.setState = function(state) { if (this._state === state) return; this._shaderMeterial&&this._shaderMeterial.cleanUp&&this._shaderMeterial.cleanUp(); this._state = state; this._activateMaterial(); } cc.Sprite.prototype.cleanShader = function() { this._shaderMeterial&&this._shaderMeterial.cleanUp&&this._shaderMeterial.cleanUp(); this._shaderMeterial = null } cc.Sprite.prototype.onDestroy = function(){ this._shaderMeterial&&this._shaderMeterial.cleanUp&&this._shaderMeterial.cleanUp(); cc.RenderComponent.prototype.onDestroy.call(this); this._shaderMeterial = null } cc.Sprite.prototype.onDisable = function () { cc.RenderComponent.prototype.onDisable.call(this); this.node.off("size-changed", this._onNodeSizeDirty, this); this.node.off("anchor-changed", this._onNodeSizeDirty, this); } cc.Sprite.prototype.onEnable = function () { cc.RenderComponent.prototype.onEnable.call(this); if (!this._spriteFrame || !this._spriteFrame.textureLoaded()) { // Do not render when sprite frame is not ready this.disableRender(); if (this._spriteFrame) { this._spriteFrame.once('load', this._onTextureLoaded, this); this._spriteFrame.ensureLoadTexture(); } } this._updateAssembler(); this._activateMaterial(); if(this._shaderMeterial){ this._material = this._shaderMeterial; this._renderData.material = this._shaderMeterial; } this.node.on("size-changed", this._onNodeSizeDirty, this); this.node.on("anchor-changed", this._onNodeSizeDirty, this); } cc.Label.prototype.onDestroy =function() { this._shaderMeterial&&this._shaderMeterial.cleanUp&&this._shaderMeterial.cleanUp(); this._shaderMeterial = null this._assembler && this._assembler._resetAssemblerData && this._assembler._resetAssemblerData(this._assemblerData); this._assemblerData = null; this._letterTexture = null; if (this._ttfTexture) { this._ttfTexture.destroy(); this._ttfTexture = null; } cc.RenderComponent.prototype.onDestroy.call(this); } // cc.Label.prototype.onDestroy=function () { // this._assembler && this._assembler._resetAssemblerData && this._assembler._resetAssemblerData(this._assemblerData); // this._assemblerData = null; // this._letterTexture = null; // if (this._ttfTexture) { // this._ttfTexture.destroy(); // this._ttfTexture = null; // } // this._material&&this._material.cleanUp&&this._material.cleanUp(); // cc.RenderComponent.prototype.onDestroy.call(this); // } // cc.Button.prototype._updateDisabledState = function() { // if(this.useShader){ // return // } // if (this._sprite) { // if (this.enableAutoGrayEffect) { // if (!(this.transition === Transition.SPRITE && this.disabledSprite)) { // if (!this.interactable) { // this._sprite.setState(cc.Sprite.State.GRAY); // return; // } // } // } // this._sprite.setState(cc.Sprite.State.NORMAL); // } // } sp.Skeleton.prototype.changepic= function(name,texture){ if(!this.texTureChange){ this.texTureChange = {} } this.texTureChange[name] = texture } sp.Skeleton.prototype.cleanshader= function(name,texture){ if(this._shaderMeterial){ this._shaderMeterial = null this._updateMaterial(new cc.renderer.renderEngine.SpineMaterial()) } } sp.Skeleton.prototype.lateUpdate=function(dt) { if(this._shaderMeterial && this._shaderMeterial.needUpdate){ this._shaderMeterial.shadercfg.update(this._shaderMeterial,dt); } }