diff --git a/cocos2d/core/base-nodes/BaseNodesPropertyDefine.js b/cocos2d/core/base-nodes/BaseNodesPropertyDefine.js deleted file mode 100644 index 21c2262f3b..0000000000 --- a/cocos2d/core/base-nodes/BaseNodesPropertyDefine.js +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** - Copyright (c) 2013-2016 Chukong Technologies Inc. - - http://www.cocos.com - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated engine source code (the "Software"), a limited, - worldwide, royalty-free, non-assignable, revocable and non-exclusive license - to use Cocos Creator solely to develop games on your target platforms. You shall - not use Cocos Creator software for developing other software or tools that's - used for developing games. You are not granted to publish, distribute, - sublicense, and/or sell copies of Cocos Creator. - - The software or tools in this License Agreement are licensed, not sold. - Chukong Aipu reserves all rights not expressly granted to you. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -var _p = _ccsg.Node.prototype; - -cc.defineGetterSetter(_p, "x", _p.getPositionX, _p.setPositionX); -cc.defineGetterSetter(_p, "y", _p.getPositionY, _p.setPositionY); -cc.defineGetterSetter(_p, "width", _p._getWidth, _p._setWidth); -cc.defineGetterSetter(_p, "height", _p._getHeight, _p._setHeight); -cc.defineGetterSetter(_p, "anchorX", _p._getAnchorX, _p._setAnchorX); -cc.defineGetterSetter(_p, "anchorY", _p._getAnchorY, _p._setAnchorY); -cc.defineGetterSetter(_p, "skewX", _p.getSkewX, _p.setSkewX); -cc.defineGetterSetter(_p, "skewY", _p.getSkewY, _p.setSkewY); -cc.defineGetterSetter(_p, "zIndex", _p.getLocalZOrder, _p.setLocalZOrder); -cc.defineGetterSetter(_p, "vertexZ", _p.getVertexZ, _p.setVertexZ); -cc.defineGetterSetter(_p, "rotation", _p.getRotation, _p.setRotation); -cc.defineGetterSetter(_p, "rotationX", _p.getRotationX, _p.setRotationX); -cc.defineGetterSetter(_p, "rotationY", _p.getRotationY, _p.setRotationY); -cc.defineGetterSetter(_p, "scale", _p.getScale, _p.setScale); -cc.defineGetterSetter(_p, "scaleX", _p.getScaleX, _p.setScaleX); -cc.defineGetterSetter(_p, "scaleY", _p.getScaleY, _p.setScaleY); -cc.defineGetterSetter(_p, "children", _p.getChildren); -cc.defineGetterSetter(_p, "childrenCount", _p.getChildrenCount); -cc.defineGetterSetter(_p, "parent", _p.getParent, _p.setParent); -cc.defineGetterSetter(_p, "visible", _p.isVisible, _p.setVisible); -cc.defineGetterSetter(_p, "running", _p.isRunning); -cc.defineGetterSetter(_p, "ignoreAnchor", _p.isIgnoreAnchorPointForPosition, _p.setIgnoreAnchorPointForPosition); -cc.defineGetterSetter(_p, "scheduler", _p.getScheduler, _p.setScheduler); -//cc.defineGetterSetter(_p, "boundingBox", _p.getBoundingBox); -cc.defineGetterSetter(_p, "shaderProgram", _p.getShaderProgram, _p.setShaderProgram); -cc.defineGetterSetter(_p, "opacity", _p.getOpacity, _p.setOpacity); -cc.defineGetterSetter(_p, "opacityModifyRGB", _p.isOpacityModifyRGB); -cc.defineGetterSetter(_p, "cascadeOpacity", _p.isCascadeOpacityEnabled, _p.setCascadeOpacityEnabled); -cc.defineGetterSetter(_p, "color", _p.getColor, _p.setColor); -cc.defineGetterSetter(_p, "cascadeColor", _p.isCascadeColorEnabled, _p.setCascadeColorEnabled); diff --git a/cocos2d/core/base-nodes/CCSGNode.js b/cocos2d/core/base-nodes/CCSGNode.js index 4fe7ba8129..4856e1f5ed 100644 --- a/cocos2d/core/base-nodes/CCSGNode.js +++ b/cocos2d/core/base-nodes/CCSGNode.js @@ -24,6 +24,8 @@ THE SOFTWARE. ****************************************************************************/ +var Misc = require('../utils/misc'); + var ActionManagerExist = !!cc.ActionManager; var emptyFunc = function () {}; @@ -2191,4 +2193,22 @@ _ccsg.Node.performType = { _ccsg.Node._performStacks = [[]]; _ccsg.Node._performing = 0; -require('./BaseNodesPropertyDefine'); + +var SameNameGetSets = ['skewX', 'skewY', 'vertexZ', 'rotation', 'rotationX', 'rotationY', 'scale', 'scaleX', 'scaleY', + 'children', 'childrenCount', 'parent', 'scheduler', 'shaderProgram', 'opacity', 'color']; +var DiffNameGetSets = { + x: ['getPositionX', 'setPositionX'], + y: ['getPositionY', 'setPositionY'], + width: ['_getWidth', '_setWidth'], + height: ['_getHeight', '_setHeight'], + anchorX: ['_getAnchorX', '_setAnchorX'], + anchorY: ['_getAnchorY', '_setAnchorY'], + zIndex: ['getLocalZOrder', 'setLocalZOrder'], + visible: ['isVisible', 'setVisible'], + running: ['isRunning'], + ignoreAnchor: ['isIgnoreAnchorPointForPosition', 'setIgnoreAnchorPointForPosition'], + opacityModifyRGB: ['isOpacityModifyRGB', 'setOpacityModifyRGB'], + cascadeOpacity: ['isCascadeOpacityEnabled', 'setCascadeOpacityEnabled'], + cascadeColor: ['isCascadeColorEnabled', 'setCascadeColorEnabled'], +}; +Misc.propertyDefine(_ccsg.Node, SameNameGetSets, DiffNameGetSets); diff --git a/cocos2d/core/sprites/CCSGSprite.js b/cocos2d/core/sprites/CCSGSprite.js index f999430098..6ea966598b 100644 --- a/cocos2d/core/sprites/CCSGSprite.js +++ b/cocos2d/core/sprites/CCSGSprite.js @@ -25,6 +25,7 @@ ****************************************************************************/ var EventTarget = require("../event/event-target"); +var Misc = require('../utils/misc'); /** *

_ccsg.Sprite is a 2d image ( http://en.wikipedia.org/wiki/Sprite_(computer_graphics) )
@@ -757,4 +758,11 @@ _ccsg.Sprite = _ccsg.Node.extend({ cc.js.addon(_ccsg.Sprite.prototype, EventTarget.prototype); -require('./SpritesPropertyDefine'); +var SameNameGetSets = ['opacity', 'color', 'offsetX', 'offsetY', 'texture', 'batchNode', 'quad']; +var DiffNameGetSets = { + opacityModifyRGB: ['isOpacityModifyRGB', 'setOpacityModifyRGB'], + flippedX: ['isFlippedX', 'setFlippedX'], + flippedY: ['isFlippedY', 'setFlippedY'], + textureRectRotated: ['isTextureRectRotated'], +}; +Misc.propertyDefine(_ccsg.Sprite, SameNameGetSets, DiffNameGetSets); diff --git a/cocos2d/core/sprites/SpritesPropertyDefine.js b/cocos2d/core/sprites/SpritesPropertyDefine.js deleted file mode 100644 index 1d202882c0..0000000000 --- a/cocos2d/core/sprites/SpritesPropertyDefine.js +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** - Copyright (c) 2008-2010 Ricardo Quesada - Copyright (c) 2011-2012 cocos2d-x.org - Copyright (c) 2013-2014 Chukong Technologies Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -var _p = _ccsg.Sprite.prototype; - -// Override properties -cc.defineGetterSetter(_p, "opacityModifyRGB", _p.isOpacityModifyRGB, _p.setOpacityModifyRGB); -cc.defineGetterSetter(_p, "opacity", _p.getOpacity, _p.setOpacity); -cc.defineGetterSetter(_p, "color", _p.getColor, _p.setColor); - -// Extended properties -/** @expose */ -_p.dirty; -/** @expose */ -_p.flippedX; -cc.defineGetterSetter(_p, "flippedX", _p.isFlippedX, _p.setFlippedX); -/** @expose */ -_p.flippedY; -cc.defineGetterSetter(_p, "flippedY", _p.isFlippedY, _p.setFlippedY); -/** @expose */ -_p.offsetX; -cc.defineGetterSetter(_p, "offsetX", _p._getOffsetX); -/** @expose */ -_p.offsetY; -cc.defineGetterSetter(_p, "offsetY", _p._getOffsetY); -/** @expose */ -_p.atlasIndex; -/** @expose */ -_p.texture; -cc.defineGetterSetter(_p, "texture", _p.getTexture, _p.setTexture); -/** @expose */ -_p.textureRectRotated; -cc.defineGetterSetter(_p, "textureRectRotated", _p.isTextureRectRotated); -/** @expose */ -_p.textureAtlas; -/** @expose */ -_p.batchNode; -cc.defineGetterSetter(_p, "batchNode", _p.getBatchNode, _p.setBatchNode); -/** @expose */ -_p.quad; -cc.defineGetterSetter(_p, "quad", _p.getQuad);