64 lines
1.5 KiB
JavaScript
64 lines
1.5 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, '4fa6cO05aBKGoM+5EX9zhkC', 'TmoSprite');
|
|
// Script/TmoSprite.js
|
|
|
|
"use strict";
|
|
|
|
exports.__esModule = true;
|
|
exports["default"] = void 0;
|
|
|
|
var _TmoAssembler = require("./TmoAssembler");
|
|
|
|
var _default = cc.Class({
|
|
"extends": cc.Sprite,
|
|
|
|
/**
|
|
* 设置TextureIndex
|
|
*/
|
|
setTextureIdx: function setTextureIdx(idx) {
|
|
this._textureIdx = idx;
|
|
this.setVertsDirty();
|
|
},
|
|
_getDefaultMaterial: function _getDefaultMaterial() {
|
|
// 从TiledMap取得默认的材质
|
|
return this._getTiledMap().getObjectMaterial();
|
|
},
|
|
_updateMaterial: function _updateMaterial() {
|
|
// make sure material is belong to self.
|
|
var material = this.getMaterial(0);
|
|
|
|
if (material) {
|
|
if (material.getDefine('USE_TEXTURE') !== undefined) {
|
|
material.define('USE_TEXTURE', true);
|
|
} // 手动设置哈希值,避免无法合批
|
|
|
|
|
|
material.updateHash(999999); // 增加WITH_COLOR宏定义
|
|
|
|
var noColor = this.isNoColor();
|
|
material.define('WITH_COLOR', !noColor);
|
|
}
|
|
|
|
cc.BlendFunc.prototype._updateMaterial.call(this);
|
|
},
|
|
_resetAssembler: function _resetAssembler() {
|
|
// 修改默认Assembler
|
|
var assembler = this._assembler = new _TmoAssembler.TmoAssembler();
|
|
assembler.init(this);
|
|
|
|
this._updateColor();
|
|
|
|
this.setVertsDirty();
|
|
},
|
|
_getTiledMap: function _getTiledMap() {
|
|
return this.node._tiledMap;
|
|
},
|
|
isNoColor: function isNoColor() {
|
|
return this._getTiledMap().isNoColor();
|
|
}
|
|
});
|
|
|
|
exports["default"] = _default;
|
|
module.exports = exports["default"];
|
|
|
|
cc._RF.pop(); |