/* * This script is automatically generated by Cocos Creator and is only compatible with projects prior to v2.1.0. * You do not need to manually add this script in any other project. * If you don't use cc.Toggle in your project, you can delete this script directly. * If your project is hosted in VCS such as git, submit this script together. * * 此脚本由 Cocos Creator 自动生成,仅用于兼容 v2.1.0 之前版本的工程, * 你无需在任何其它项目中手动添加此脚本。 * 如果你的项目中没用到 Toggle,可直接删除该脚本。 * 如果你的项目有托管于 git 等版本库,请将此脚本一并上传。 */ if (cc.Toggle) { // Whether the 'toggle' and 'checkEvents' events are fired when 'toggle.check() / toggle.uncheck()' is called in the code // 在代码中调用 'toggle.check() / toggle.uncheck()' 时是否触发 'toggle' 与 'checkEvents' 事件 cc.Toggle._triggerEventInScript_check = true; } (function () { let map = { Node: { "active": "Active", "opacity": "Opacity" }, Sprite: { "spriteFrame": "SpriteFrame" }, Label: { "string": "String" }, Button: { "interactable": "Interactable" } }; let keys1 = Object.keys(map); for (let i = 0; i < keys1.length; i += 1) { let compName = keys1[i]; let compMap = map[compName]; let keys2 = Object.keys(compMap); for (let j = 0; j < keys2.length; j += 1) { let type = keys2[j]; let funcName = compMap[type]; cc.Node.prototype["getChild" + funcName] = function (childName) { let comp = nodeTools_getComp(this, compName, childName); if (comp) { let _type = comp[type]; return _type; } } cc.Node.prototype["setChild" + funcName] = function (childName, comp_prototype) { let comp = nodeTools_getComp(this, compName, childName); if (comp) { comp[type] = comp_prototype; } } } } })() var nodeTools_getComp = function (targetThis, compName, childName) { let cacheName = "_cacheChild_" + compName + "_" + childName; let cacheComp = targetThis[cacheName]; if (cacheComp) { return cacheComp; } else { let targetNode = nodeTools_checkChildName(targetThis, childName); let getComp = compName == "Node" ? this : targetNode.getComponent(cc[compName]); if (getComp) { targetNode[cacheName] = getComp; return getComp; } else { cc.error("未找到节点上有组件"); debugger; } return null; } } var nodeTools_checkChildName = function (targetThis, childName) { let foundArr = childName.split("/"); let foundNode = targetThis; for (let i = 0; i < foundArr.length; i += 1) { let foundName = foundArr[i]; foundNode = foundNode.getChildByName(foundName); if (foundNode == null) { cc.error("未找到对应的子节点"); debugger; } } return foundNode; } cc.Button.prototype._onTouchEnded = function (event) { if (!this.interactable || !this.enabledInHierarchy) return; if (this._pressed) { cc.Component.EventHandler.emitEvents(this.clickEvents, event); this.node.emit('click', this); } this._pressed = false; this._audiocb && this._audiocb(); this._updateState(); event.stopPropagation(); } Array.prototype.remove = function (val) { var index = this.indexOf(val); if (index > -1) { this.splice(index, 1); } }; Array.prototype.sum = function () { let sumNum = 0; for (let i = 0; i < this.length; i += 1) { sumNum += this[i]; } return sumNum; }