// 获取节点/子节点数组(递归) function getNodeList(node){ var list = [node] var children = node.getChildren() for(var i = 0 ; i < children.length ; i++) { var rtn = getNodeList(children[i]) Array.prototype.push.apply(list , rtn) } return list } // 递归设置/还原node及子节点灰色 function setGray(node , bGray){ var list = getNodeList(node) var program = bGray ? cc.Scale9Sprite.WebGLRenderCmd._getGrayShaderProgram() : cc.shaderCache.programForKey(cc.macro.SHADER_SPRITE_POSITION_TEXTURECOLOR) for(var i = 0 ; i < list.length ; i++) { var sprite = list[i].getComponent(cc.Sprite) var display = list[i].getComponent(dragonBones.ArmatureDisplay) // sprite if(sprite) sprite._sgNode.setState(bGray ? cc.Scale9Sprite.state.GRAY : cc.Scale9Sprite.state.NORMAL) // dragonBones if( display && display._sgNode ) { var children = display._sgNode.getChildren() for(var j = 0 ; j < children.length ; j++) { children[j]._renderCmd._shaderProgram = program } } } }
QQ:393422044
Email:fkrfkrfkr@163.com