From 091e9aeac76447c4f0b424eaa74a7d7a7543216d Mon Sep 17 00:00:00 2001 From: jianglong0156 Date: Fri, 17 Apr 2015 14:41:24 +0800 Subject: [PATCH 1/2] support extension module reduce --- .../script/extension/jsb_cocos2d_extension.js | 314 ++++++++++++++---- .../script/extension/jsb_ext_create_apis.js | 95 ------ .../script/extension/jsb_ext_property_apis.js | 102 ------ frameworks/js-bindings/bindings/script/jsb.js | 6 +- 4 files changed, 253 insertions(+), 264 deletions(-) delete mode 100644 frameworks/js-bindings/bindings/script/extension/jsb_ext_create_apis.js delete mode 100644 frameworks/js-bindings/bindings/script/extension/jsb_ext_property_apis.js diff --git a/frameworks/js-bindings/bindings/script/extension/jsb_cocos2d_extension.js b/frameworks/js-bindings/bindings/script/extension/jsb_cocos2d_extension.js index 7477ca64c2..83e75d7b80 100644 --- a/frameworks/js-bindings/bindings/script/extension/jsb_cocos2d_extension.js +++ b/frameworks/js-bindings/bindings/script/extension/jsb_cocos2d_extension.js @@ -20,50 +20,6 @@ * THE SOFTWARE. */ -/** - * @type {Object} - * @name jsb.AssetsManager - * jsb.AssetsManager is the native AssetsManager for your game resources or scripts. - * please refer to this document to know how to use it: http://www.cocos2d-x.org/docs/manual/framework/html5/v3/assets-manager/en - * Only available in JSB - */ -jsb.AssetsManager = cc.AssetsManager; -delete cc.AssetsManager; -/** - * @type {Object} - * @name jsb.EventListenerAssetsManager - * jsb.EventListenerAssetsManager is the native event listener for AssetsManager. - * please refer to this document to know how to use it: http://www.cocos2d-x.org/docs/manual/framework/html5/v3/assets-manager/en - * Only available in JSB - */ -jsb.EventListenerAssetsManager = cc.EventListenerAssetsManager; -delete cc.EventListenerAssetsManager; -/** - * @type {Object} - * @name jsb.EventAssetsManager - * jsb.EventAssetsManager is the native event for AssetsManager. - * please refer to this document to know how to use it: http://www.cocos2d-x.org/docs/manual/framework/html5/v3/assets-manager/en - * Only available in JSB - */ -jsb.EventAssetsManager = cc.EventAssetsManager; -delete cc.EventAssetsManager; - -// move from jsb_cocos2d -//start------------------------------ -cc.ControlButton.extend = cc.Class.extend; -cc.ControlColourPicker.extend = cc.Class.extend; -cc.ControlPotentiometer.extend = cc.Class.extend; -cc.ControlSlider.extend = cc.Class.extend; -cc.ControlStepper.extend = cc.Class.extend; -cc.ControlSwitch.extend = cc.Class.extend; -//end------------------------------ - -// -// cocos2d constants -// -// This helper file should be required after jsb_cocos2d.js -// - var cc = cc || {}; cc.SCROLLVIEW_DIRECTION_NONE = -1; @@ -73,7 +29,6 @@ cc.SCROLLVIEW_DIRECTION_BOTH = 2; cc.TABLEVIEW_FILL_TOPDOWN = 0; cc.TABLEVIEW_FILL_BOTTOMUP = 1; - /** * @constant * @type Number @@ -224,20 +179,255 @@ cc.CONTROL_STEPPER_LABELFONT = "CourierNewPSMT"; cc.AUTOREPEAT_DELTATIME = 0.15; cc.AUTOREPEAT_INCREASETIME_INCREMENT = 12; - -jsb.EventAssetsManager.ERROR_NO_LOCAL_MANIFEST = 0; -jsb.EventAssetsManager.ERROR_DOWNLOAD_MANIFEST = 1; -jsb.EventAssetsManager.ERROR_PARSE_MANIFEST = 2; -jsb.EventAssetsManager.NEW_VERSION_FOUND = 3; -jsb.EventAssetsManager.ALREADY_UP_TO_DATE = 4; -jsb.EventAssetsManager.UPDATE_PROGRESSION = 5; -jsb.EventAssetsManager.ASSET_UPDATED = 6; -jsb.EventAssetsManager.ERROR_UPDATING = 7; -jsb.EventAssetsManager.UPDATE_FINISHED = 8; -jsb.EventAssetsManager.UPDATE_FAILED = 9; -jsb.EventAssetsManager.ERROR_DECOMPRESS = 10; - -cc.ScrollView.extend = cc.Class.extend; -cc.TableView.extend = cc.Class.extend; -cc.TableViewCell.extend = cc.Class.extend; - +var _proto = null; +if (cc.AssetsManager) +{ + /** + * @type {Object} + * @name jsb.AssetsManager + * jsb.AssetsManager is the native AssetsManager for your game resources or scripts. + * please refer to this document to know how to use it: http://www.cocos2d-x.org/docs/manual/framework/html5/v3/assets-manager/en + * Only available in JSB + */ + jsb.AssetsManager = cc.AssetsManager; + delete cc.AssetsManager; +} + +if (cc.EventListenerAssetsManager) +{ + /** + * @type {Object} + * @name jsb.EventListenerAssetsManager + * jsb.EventListenerAssetsManager is the native event listener for AssetsManager. + * please refer to this document to know how to use it: http://www.cocos2d-x.org/docs/manual/framework/html5/v3/assets-manager/en + * Only available in JSB + */ + jsb.EventListenerAssetsManager = cc.EventListenerAssetsManager; + delete cc.EventListenerAssetsManager; + + jsb.EventListenerAssetsManager.prototype._ctor = function(assetsManager, callback) { + callback !== undefined && this.init(assetsManager, callback); + }; +} + +if (cc.EventAssetsManager) +{ + /** + * @type {Object} + * @name jsb.EventAssetsManager + * jsb.EventAssetsManager is the native event for AssetsManager. + * please refer to this document to know how to use it: http://www.cocos2d-x.org/docs/manual/framework/html5/v3/assets-manager/en + * Only available in JSB + */ + jsb.EventAssetsManager = cc.EventAssetsManager; + delete cc.EventAssetsManager; + + jsb.EventAssetsManager.ERROR_NO_LOCAL_MANIFEST = 0; + jsb.EventAssetsManager.ERROR_DOWNLOAD_MANIFEST = 1; + jsb.EventAssetsManager.ERROR_PARSE_MANIFEST = 2; + jsb.EventAssetsManager.NEW_VERSION_FOUND = 3; + jsb.EventAssetsManager.ALREADY_UP_TO_DATE = 4; + jsb.EventAssetsManager.UPDATE_PROGRESSION = 5; + jsb.EventAssetsManager.ASSET_UPDATED = 6; + jsb.EventAssetsManager.ERROR_UPDATING = 7; + jsb.EventAssetsManager.UPDATE_FINISHED = 8; + jsb.EventAssetsManager.UPDATE_FAILED = 9; + jsb.EventAssetsManager.ERROR_DECOMPRESS = 10; +} + +if (cc.Control) +{ + _proto = cc.Control.prototype; + cc.defineGetterSetter(_proto, "opacityModifyRGB", _proto.isOpacityModifyRGB, _proto.setOpacityModifyRGB); + cc.defineGetterSetter(_proto, "state", _proto.getState); + cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); + cc.defineGetterSetter(_proto, "selected", _proto.isSelected, _proto.setSelected); + cc.defineGetterSetter(_proto, "highlighted", _proto.isHighlighted, _proto.setHighlighted); +} + +if (cc.ControlButton) +{ + cc.ControlButton.extend = cc.Class.extend; + + _proto = cc.ControlButton.prototype; + cc.defineGetterSetter(_proto, "color", _proto.getColor, _proto.setColor); + cc.defineGetterSetter(_proto, "opacity", _proto.getOpacity, _proto.setOpacity); + cc.defineGetterSetter(_proto, "adjustBackgroundImage", _proto.getAdjustBackgroundImage, _proto.setAdjustBackgroundImage); + cc.defineGetterSetter(_proto, "zoomOnTouchDown", _proto.getZoomOnTouchDown, _proto.setZoomOnTouchDown); + cc.defineGetterSetter(_proto, "preferredSize", _proto.getPreferredSize, _proto.setPreferredSize); + cc.defineGetterSetter(_proto, "labelAnchor", _proto.getLabelAnchorPoint, _proto.setLabelAnchorPoint); + + cc.ControlButton.prototype._ctor = function(label, backgroundSprite, fontSize){ + if(fontSize != undefined) + this.initWithTitleAndFontNameAndFontSize(label, backgroundSprite, fontSize); + else if(backgroundSprite != undefined) + this.initWithLabelAndBackgroundSprite(label, backgroundSprite); + else if(label != undefined) + this.initWithBackgroundSprite(label); + else + this.init(); + }; + +} + +if (cc.ControlColourPicker) +{ + cc.ControlColourPicker.extend = cc.Class.extend; + + _proto = cc.ControlColourPicker.prototype; + cc.defineGetterSetter(_proto, "color", _proto.getColor, _proto.setColor); + cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); + cc.defineGetterSetter(_proto, "background", _proto.getBackground); + + cc.ControlColourPicker.prototype._ctor = function(){ + this.init(); + }; + +} + +if (cc.ControlHuePicker) +{ + _proto = cc.ControlHuePicker.prototype; + cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); + cc.defineGetterSetter(_proto, "hue", _proto.getHue, _proto.setHue); + cc.defineGetterSetter(_proto, "huePercent", _proto.getHuePercentage, _proto.setHuePercentage); + cc.defineGetterSetter(_proto, "background", _proto.getBackground); + cc.defineGetterSetter(_proto, "slider", _proto.getSlider); + cc.defineGetterSetter(_proto, "startPos", _proto.getStartPos); +} + +if (cc.ControlSaturationBrightnessPicker) +{ + _proto = cc.ControlSaturationBrightnessPicker.prototype; + cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); + cc.defineGetterSetter(_proto, "saturation", _proto.getSaturation); + cc.defineGetterSetter(_proto, "brightness", _proto.getBrightness); + cc.defineGetterSetter(_proto, "background", _proto.getBackground); + cc.defineGetterSetter(_proto, "overlay", _proto.getOverlay); + cc.defineGetterSetter(_proto, "shadow", _proto.getShadow); + cc.defineGetterSetter(_proto, "slider", _proto.getSlider); + cc.defineGetterSetter(_proto, "startPos", _proto.getStartPos); +} + +if (cc.ControlPotentiometer) +{ + cc.ControlPotentiometer.extend = cc.Class.extend; + + _proto = cc.ControlPotentiometer.prototype; + cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); + cc.defineGetterSetter(_proto, "value", _proto.getValue, _proto.setValue); + cc.defineGetterSetter(_proto, "minValue", _proto.getMinimumValue, _proto.setMinimumValue); + cc.defineGetterSetter(_proto, "maxValue", _proto.getMaximumValue, _proto.setMaximumValue); + cc.defineGetterSetter(_proto, "progressTimer", _proto.getProgressTimer, _proto.setProgressTimer); + cc.defineGetterSetter(_proto, "thumbSprite", _proto.getThumbSprite, _proto.setThumbSprite); + cc.defineGetterSetter(_proto, "prevLocation", _proto.getPreviousLocation, _proto.setPreviousLocation); + + cc.ControlPotentiometer.prototype._ctor = function(backgroundFile, progressFile, thumbFile){ + if (thumbFile != undefined) { + // Prepare track for potentiometer + var backgroundSprite = cc.Sprite.create(backgroundFile); + + // Prepare thumb for potentiometer + var thumbSprite = cc.Sprite.create(thumbFile); + + // Prepare progress for potentiometer + var progressTimer = cc.ProgressTimer.create(cc.Sprite.create(progressFile)); + this.initWithTrackSprite_ProgressTimer_ThumbSprite(backgroundSprite, progressTimer, thumbSprite); + } + }; +} + +if (cc.ControlSlider) +{ + cc.ControlSlider.extend = cc.Class.extend; + + _proto = cc.ControlSlider.prototype; + cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); + cc.defineGetterSetter(_proto, "value", _proto.getValue, _proto.setValue); + cc.defineGetterSetter(_proto, "minValue", _proto.getMinimumValue, _proto.setMinimumValue); + cc.defineGetterSetter(_proto, "maxValue", _proto.getMaximumValue, _proto.setMaximumValue); + cc.defineGetterSetter(_proto, "minAllowedValue", _proto.getMinimumAllowedValue, _proto.setMinimumAllowedValue); + cc.defineGetterSetter(_proto, "maxAllowedValue", _proto.getMaximumAllowedValue, _proto.setMaximumAllowedValue); + cc.defineGetterSetter(_proto, "thumbSprite", _proto.getThumbSprite); + cc.defineGetterSetter(_proto, "progressSprite", _proto.getProgressSprite); + cc.defineGetterSetter(_proto, "backgroundSprite", _proto.getBackgroundSprite); + + cc.ControlSlider.prototype._ctor = function(bgFile, progressFile, thumbFile){ + if (thumbFile != undefined) { + // Prepare background for slider + bgSprite = cc.Sprite.create(bgFile); + + // Prepare progress for slider + progressSprite = cc.Sprite.create(progressFile); + + // Prepare thumb (menuItem) for slider + thumbSprite = cc.Sprite.create(thumbFile); + + this.initWithSprites(bgSprite, progressSprite, thumbSprite); + } + }; +} + +if (cc.ControlStepper) +{ + cc.ControlStepper.extend = cc.Class.extend; + + _proto = cc.ControlStepper.prototype; + cc.defineGetterSetter(_proto, "wraps", _proto.getWraps, _proto.setWraps); + cc.defineGetterSetter(_proto, "value", _proto.getValue, _proto.setValue); + cc.defineGetterSetter(_proto, "minValue", _proto.getMinimumValue, _proto.setMinimumValue); + cc.defineGetterSetter(_proto, "maxValue", _proto.getMaximumValue, _proto.setMaximumValue); + cc.defineGetterSetter(_proto, "stepValue", _proto.getStepValue, _proto.setStepValue); + cc.defineGetterSetter(_proto, "continuous", _proto.isContinuous); + cc.defineGetterSetter(_proto, "minusSprite", _proto.getMinusSprite, _proto.setMinusSprite); + cc.defineGetterSetter(_proto, "plusSprite", _proto.getPlusSprite, _proto.setPlusSprite); + cc.defineGetterSetter(_proto, "minusLabel", _proto.getMinusLabel, _proto.setMinusLabel); + cc.defineGetterSetter(_proto, "plusSLabel", _proto.getPlusSLabel, _proto.setPlusSLabel); + + cc.ControlStepper.prototype._ctor = function(minusSprite, plusSprite){ + plusSprite !== undefined && this.initWithMinusSpriteAndPlusSprite(minusSprite, plusSprite); + }; +} + +if (cc.ControlSwitch) +{ + cc.ControlSwitch.extend = cc.Class.extend; + + _proto = cc.ControlSwitch.prototype; + cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); + + cc.ControlSwitch.prototype._ctor = function(maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel){ + offLabel !== undefined && this.initWithMaskSprite(maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel); + }; +} + +if (cc.ScrollView) +{ + cc.ScrollView.extend = cc.Class.extend; + + _proto = cc.ScrollView.prototype; + cc.defineGetterSetter(_proto, "width", _proto._getWidth, _proto._setWidth); + cc.defineGetterSetter(_proto, "height", _proto._getHeight, _proto._setHeight); + cc.defineGetterSetter(_proto, "direction", _proto.getDirection, _proto.setDirection); + + cc.ScrollView.prototype._ctor = function(size, container) { + size == undefined ? this.init() : (container ? this.initWithViewSize(size, container) : this.initWithViewSize(size)); + }; +} + +if (cc.TableView) +{ + cc.TableView.extend = cc.Class.extend; + + cc.TableView.prototype._ctor = function(dataSouurce, size, container){ + container == undefined ? this._init(dataSouurce, size) : this._init(dataSouurce, size, container); + }; +} + +if (cc.TableViewCell) +{ + cc.TableViewCell.extend = cc.Class.extend; + + _proto = cc.TableViewCell.prototype; + cc.defineGetterSetter(_proto, "objectId", _proto.getObjectID, _proto.setObjectID); +} \ No newline at end of file diff --git a/frameworks/js-bindings/bindings/script/extension/jsb_ext_create_apis.js b/frameworks/js-bindings/bindings/script/extension/jsb_ext_create_apis.js deleted file mode 100644 index ab0b45867e..0000000000 --- a/frameworks/js-bindings/bindings/script/extension/jsb_ext_create_apis.js +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2014 Chukong Technologies Inc. - * - * 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. - */ - -/************************************************************ - * - * Constructors with built in init function - * - ************************************************************/ - -jsb.EventListenerAssetsManager.prototype._ctor = function(assetsManager, callback) { - callback !== undefined && this.init(assetsManager, callback); -}; - - - -cc.ControlButton.prototype._ctor = function(label, backgroundSprite, fontSize){ - if(fontSize != undefined) - this.initWithTitleAndFontNameAndFontSize(label, backgroundSprite, fontSize); - else if(backgroundSprite != undefined) - this.initWithLabelAndBackgroundSprite(label, backgroundSprite); - else if(label != undefined) - this.initWithBackgroundSprite(label); - else - this.init(); -}; - -cc.ControlColourPicker.prototype._ctor = function(){ - this.init(); -}; - -cc.ControlPotentiometer.prototype._ctor = function(backgroundFile, progressFile, thumbFile){ - if (thumbFile != undefined) { - // Prepare track for potentiometer - var backgroundSprite = cc.Sprite.create(backgroundFile); - - // Prepare thumb for potentiometer - var thumbSprite = cc.Sprite.create(thumbFile); - - // Prepare progress for potentiometer - var progressTimer = cc.ProgressTimer.create(cc.Sprite.create(progressFile)); - this.initWithTrackSprite_ProgressTimer_ThumbSprite(backgroundSprite, progressTimer, thumbSprite); - } -}; - -cc.ControlSlider.prototype._ctor = function(bgFile, progressFile, thumbFile){ - if (thumbFile != undefined) { - // Prepare background for slider - bgSprite = cc.Sprite.create(bgFile); - - // Prepare progress for slider - progressSprite = cc.Sprite.create(progressFile); - - // Prepare thumb (menuItem) for slider - thumbSprite = cc.Sprite.create(thumbFile); - - this.initWithSprites(bgSprite, progressSprite, thumbSprite); - } -}; - -cc.ControlStepper.prototype._ctor = function(minusSprite, plusSprite){ - plusSprite !== undefined && this.initWithMinusSpriteAndPlusSprite(minusSprite, plusSprite); -}; - -cc.ControlSwitch.prototype._ctor = function(maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel){ - offLabel !== undefined && this.initWithMaskSprite(maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel); -}; - -cc.TableView.prototype._ctor = function(dataSouurce, size, container){ - container == undefined ? this._init(dataSouurce, size) : this._init(dataSouurce, size, container); -}; - -cc.ScrollView.prototype._ctor = function(size, container) { - size == undefined ? this.init() : (container ? this.initWithViewSize(size, container) : this.initWithViewSize(size)); -}; - - diff --git a/frameworks/js-bindings/bindings/script/extension/jsb_ext_property_apis.js b/frameworks/js-bindings/bindings/script/extension/jsb_ext_property_apis.js deleted file mode 100644 index eba04c4541..0000000000 --- a/frameworks/js-bindings/bindings/script/extension/jsb_ext_property_apis.js +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2014 Chukong Technologies Inc. - * - * 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 _proto = cc.Control.prototype; -cc.defineGetterSetter(_proto, "opacityModifyRGB", _proto.isOpacityModifyRGB, _proto.setOpacityModifyRGB); -cc.defineGetterSetter(_proto, "state", _proto.getState); -cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); -cc.defineGetterSetter(_proto, "selected", _proto.isSelected, _proto.setSelected); -cc.defineGetterSetter(_proto, "highlighted", _proto.isHighlighted, _proto.setHighlighted); - -_proto = cc.ControlButton.prototype; -cc.defineGetterSetter(_proto, "color", _proto.getColor, _proto.setColor); -cc.defineGetterSetter(_proto, "opacity", _proto.getOpacity, _proto.setOpacity); -cc.defineGetterSetter(_proto, "adjustBackgroundImage", _proto.getAdjustBackgroundImage, _proto.setAdjustBackgroundImage); -cc.defineGetterSetter(_proto, "zoomOnTouchDown", _proto.getZoomOnTouchDown, _proto.setZoomOnTouchDown); -cc.defineGetterSetter(_proto, "preferredSize", _proto.getPreferredSize, _proto.setPreferredSize); -cc.defineGetterSetter(_proto, "labelAnchor", _proto.getLabelAnchorPoint, _proto.setLabelAnchorPoint); - -_proto = cc.ControlColourPicker.prototype; -cc.defineGetterSetter(_proto, "color", _proto.getColor, _proto.setColor); -cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); -cc.defineGetterSetter(_proto, "background", _proto.getBackground); - -_proto = cc.ControlHuePicker.prototype; -cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); -cc.defineGetterSetter(_proto, "hue", _proto.getHue, _proto.setHue); -cc.defineGetterSetter(_proto, "huePercent", _proto.getHuePercentage, _proto.setHuePercentage); -cc.defineGetterSetter(_proto, "background", _proto.getBackground); -cc.defineGetterSetter(_proto, "slider", _proto.getSlider); -cc.defineGetterSetter(_proto, "startPos", _proto.getStartPos); - -_proto = cc.ControlPotentiometer.prototype; -cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); -cc.defineGetterSetter(_proto, "value", _proto.getValue, _proto.setValue); -cc.defineGetterSetter(_proto, "minValue", _proto.getMinimumValue, _proto.setMinimumValue); -cc.defineGetterSetter(_proto, "maxValue", _proto.getMaximumValue, _proto.setMaximumValue); -cc.defineGetterSetter(_proto, "progressTimer", _proto.getProgressTimer, _proto.setProgressTimer); -cc.defineGetterSetter(_proto, "thumbSprite", _proto.getThumbSprite, _proto.setThumbSprite); -cc.defineGetterSetter(_proto, "prevLocation", _proto.getPreviousLocation, _proto.setPreviousLocation); - -_proto = cc.ControlSaturationBrightnessPicker.prototype; -cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); -cc.defineGetterSetter(_proto, "saturation", _proto.getSaturation); -cc.defineGetterSetter(_proto, "brightness", _proto.getBrightness); -cc.defineGetterSetter(_proto, "background", _proto.getBackground); -cc.defineGetterSetter(_proto, "overlay", _proto.getOverlay); -cc.defineGetterSetter(_proto, "shadow", _proto.getShadow); -cc.defineGetterSetter(_proto, "slider", _proto.getSlider); -cc.defineGetterSetter(_proto, "startPos", _proto.getStartPos); - -_proto = cc.ControlSlider.prototype; -cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); -cc.defineGetterSetter(_proto, "value", _proto.getValue, _proto.setValue); -cc.defineGetterSetter(_proto, "minValue", _proto.getMinimumValue, _proto.setMinimumValue); -cc.defineGetterSetter(_proto, "maxValue", _proto.getMaximumValue, _proto.setMaximumValue); -cc.defineGetterSetter(_proto, "minAllowedValue", _proto.getMinimumAllowedValue, _proto.setMinimumAllowedValue); -cc.defineGetterSetter(_proto, "maxAllowedValue", _proto.getMaximumAllowedValue, _proto.setMaximumAllowedValue); -cc.defineGetterSetter(_proto, "thumbSprite", _proto.getThumbSprite); -cc.defineGetterSetter(_proto, "progressSprite", _proto.getProgressSprite); -cc.defineGetterSetter(_proto, "backgroundSprite", _proto.getBackgroundSprite); - -_proto = cc.ControlSwitch.prototype; -cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); - -_proto = cc.ScrollView.prototype; -cc.defineGetterSetter(_proto, "width", _proto._getWidth, _proto._setWidth); -cc.defineGetterSetter(_proto, "height", _proto._getHeight, _proto._setHeight); -cc.defineGetterSetter(_proto, "direction", _proto.getDirection, _proto.setDirection); - -_proto = cc.ControlStepper.prototype; -cc.defineGetterSetter(_proto, "wraps", _proto.getWraps, _proto.setWraps); -cc.defineGetterSetter(_proto, "value", _proto.getValue, _proto.setValue); -cc.defineGetterSetter(_proto, "minValue", _proto.getMinimumValue, _proto.setMinimumValue); -cc.defineGetterSetter(_proto, "maxValue", _proto.getMaximumValue, _proto.setMaximumValue); -cc.defineGetterSetter(_proto, "stepValue", _proto.getStepValue, _proto.setStepValue); -cc.defineGetterSetter(_proto, "continuous", _proto.isContinuous); -cc.defineGetterSetter(_proto, "minusSprite", _proto.getMinusSprite, _proto.setMinusSprite); -cc.defineGetterSetter(_proto, "plusSprite", _proto.getPlusSprite, _proto.setPlusSprite); -cc.defineGetterSetter(_proto, "minusLabel", _proto.getMinusLabel, _proto.setMinusLabel); -cc.defineGetterSetter(_proto, "plusSLabel", _proto.getPlusSLabel, _proto.setPlusSLabel); - -_proto = cc.TableViewCell.prototype; -cc.defineGetterSetter(_proto, "objectId", _proto.getObjectID, _proto.setObjectID); diff --git a/frameworks/js-bindings/bindings/script/jsb.js b/frameworks/js-bindings/bindings/script/jsb.js index 1ae745a3c5..c39bcf65ef 100644 --- a/frameworks/js-bindings/bindings/script/jsb.js +++ b/frameworks/js-bindings/bindings/script/jsb.js @@ -96,11 +96,7 @@ if (window.ccui) { require('script/ccui/jsb_ccui_deprecated.js'); } -if (cc.ControlButton) { - require('script/extension/jsb_cocos2d_extension.js'); - require('script/extension/jsb_ext_property_apis.js'); - require('script/extension/jsb_ext_create_apis.js'); -} +require('script/extension/jsb_cocos2d_extension.js'); if (cc.PhysicsSprite) { cc.PhysicsSprite.extend = cc.Class.extend;// move from jsb_cocos2d.js From 0398f670e7aa3663fad4ca3980fb942f4b09d63e Mon Sep 17 00:00:00 2001 From: jianglong0156 Date: Fri, 17 Apr 2015 16:22:01 +0800 Subject: [PATCH 2/2] move the "{ " --- .../script/extension/jsb_cocos2d_extension.js | 45 +++++++------------ 1 file changed, 15 insertions(+), 30 deletions(-) diff --git a/frameworks/js-bindings/bindings/script/extension/jsb_cocos2d_extension.js b/frameworks/js-bindings/bindings/script/extension/jsb_cocos2d_extension.js index 83e75d7b80..1c75e1a473 100644 --- a/frameworks/js-bindings/bindings/script/extension/jsb_cocos2d_extension.js +++ b/frameworks/js-bindings/bindings/script/extension/jsb_cocos2d_extension.js @@ -180,8 +180,7 @@ cc.AUTOREPEAT_DELTATIME = 0.15; cc.AUTOREPEAT_INCREASETIME_INCREMENT = 12; var _proto = null; -if (cc.AssetsManager) -{ +if (cc.AssetsManager){ /** * @type {Object} * @name jsb.AssetsManager @@ -193,8 +192,7 @@ if (cc.AssetsManager) delete cc.AssetsManager; } -if (cc.EventListenerAssetsManager) -{ +if (cc.EventListenerAssetsManager){ /** * @type {Object} * @name jsb.EventListenerAssetsManager @@ -210,8 +208,7 @@ if (cc.EventListenerAssetsManager) }; } -if (cc.EventAssetsManager) -{ +if (cc.EventAssetsManager){ /** * @type {Object} * @name jsb.EventAssetsManager @@ -235,8 +232,7 @@ if (cc.EventAssetsManager) jsb.EventAssetsManager.ERROR_DECOMPRESS = 10; } -if (cc.Control) -{ +if (cc.Control){ _proto = cc.Control.prototype; cc.defineGetterSetter(_proto, "opacityModifyRGB", _proto.isOpacityModifyRGB, _proto.setOpacityModifyRGB); cc.defineGetterSetter(_proto, "state", _proto.getState); @@ -245,8 +241,7 @@ if (cc.Control) cc.defineGetterSetter(_proto, "highlighted", _proto.isHighlighted, _proto.setHighlighted); } -if (cc.ControlButton) -{ +if (cc.ControlButton){ cc.ControlButton.extend = cc.Class.extend; _proto = cc.ControlButton.prototype; @@ -270,8 +265,7 @@ if (cc.ControlButton) } -if (cc.ControlColourPicker) -{ +if (cc.ControlColourPicker){ cc.ControlColourPicker.extend = cc.Class.extend; _proto = cc.ControlColourPicker.prototype; @@ -285,8 +279,7 @@ if (cc.ControlColourPicker) } -if (cc.ControlHuePicker) -{ +if (cc.ControlHuePicker){ _proto = cc.ControlHuePicker.prototype; cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); cc.defineGetterSetter(_proto, "hue", _proto.getHue, _proto.setHue); @@ -296,8 +289,7 @@ if (cc.ControlHuePicker) cc.defineGetterSetter(_proto, "startPos", _proto.getStartPos); } -if (cc.ControlSaturationBrightnessPicker) -{ +if (cc.ControlSaturationBrightnessPicker){ _proto = cc.ControlSaturationBrightnessPicker.prototype; cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled); cc.defineGetterSetter(_proto, "saturation", _proto.getSaturation); @@ -309,8 +301,7 @@ if (cc.ControlSaturationBrightnessPicker) cc.defineGetterSetter(_proto, "startPos", _proto.getStartPos); } -if (cc.ControlPotentiometer) -{ +if (cc.ControlPotentiometer){ cc.ControlPotentiometer.extend = cc.Class.extend; _proto = cc.ControlPotentiometer.prototype; @@ -337,8 +328,7 @@ if (cc.ControlPotentiometer) }; } -if (cc.ControlSlider) -{ +if (cc.ControlSlider){ cc.ControlSlider.extend = cc.Class.extend; _proto = cc.ControlSlider.prototype; @@ -368,8 +358,7 @@ if (cc.ControlSlider) }; } -if (cc.ControlStepper) -{ +if (cc.ControlStepper){ cc.ControlStepper.extend = cc.Class.extend; _proto = cc.ControlStepper.prototype; @@ -389,8 +378,7 @@ if (cc.ControlStepper) }; } -if (cc.ControlSwitch) -{ +if (cc.ControlSwitch){ cc.ControlSwitch.extend = cc.Class.extend; _proto = cc.ControlSwitch.prototype; @@ -401,8 +389,7 @@ if (cc.ControlSwitch) }; } -if (cc.ScrollView) -{ +if (cc.ScrollView){ cc.ScrollView.extend = cc.Class.extend; _proto = cc.ScrollView.prototype; @@ -415,8 +402,7 @@ if (cc.ScrollView) }; } -if (cc.TableView) -{ +if (cc.TableView){ cc.TableView.extend = cc.Class.extend; cc.TableView.prototype._ctor = function(dataSouurce, size, container){ @@ -424,8 +410,7 @@ if (cc.TableView) }; } -if (cc.TableViewCell) -{ +if (cc.TableViewCell){ cc.TableViewCell.extend = cc.Class.extend; _proto = cc.TableViewCell.prototype;