Merge pull request #545 from pandamicro/v1.4

Fix JSB memory leak and reduce overall memory usage
This commit is contained in:
pandamicro
2017-02-26 23:04:27 +08:00
committed by GitHub
39 changed files with 117 additions and 10872 deletions
+8
View File
@@ -130,6 +130,14 @@ void Ref::release()
CCASSERT(false, "The reference shouldn't be 0 because it is still in autorelease pool.");
}
#endif
#if CC_ENABLE_SCRIPT_BINDING
ScriptEngineProtocol* pEngine = ScriptEngineManager::getInstance()->getScriptEngine();
if (pEngine != nullptr && pEngine->getScriptType() == kScriptTypeJavascript)
{
pEngine->removeObjectProxy(this);
}
#endif // CC_ENABLE_SCRIPT_BINDING
#if CC_REF_LEAK_DETECTION
untrackRef(this);
+4
View File
@@ -798,6 +798,10 @@ public:
It tells the Garbage Collector that the associated Scripting object can be collected
*/
virtual void unrootObject(Ref* obj) {}
/** Remove proxy for a native object
*/
virtual void removeObjectProxy(Ref* obj) {}
/** Triggers the garbage collector */
virtual void garbageCollect() {}
@@ -1473,12 +1473,6 @@ bool ScriptingCore::handleTouchesEvent(void* nativeObj, cocos2d::EventTouch::Eve
ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), funcName.c_str(), 2, dataVal, jsvalRet);
}
for (auto& touch : touches)
{
removeJSObject(_cx, touch);
}
removeJSObject(_cx, event);
return ret;
}
@@ -1508,9 +1502,6 @@ bool ScriptingCore::handleTouchEvent(void* nativeObj, cocos2d::EventTouch::Event
ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), funcName.c_str(), 2, dataVal, jsvalRet);
}
removeJSObject(_cx, touch);
removeJSObject(_cx, event);
return ret;
}
@@ -1533,8 +1524,6 @@ bool ScriptingCore::handleMouseEvent(void* nativeObj, cocos2d::EventMouse::Mouse
js_type_class_t *typeClass = js_get_type_from_native<cocos2d::EventMouse>((cocos2d::EventMouse*)event);
jsval dataVal = OBJECT_TO_JSVAL(jsb_get_or_create_weak_jsobject(_cx, event, typeClass));
ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), funcName.c_str(), 1, &dataVal, jsvalRet);
removeJSObject(_cx, event);
}
else CCLOG("ScriptingCore::handleMouseEvent native proxy NOT found");
@@ -1639,8 +1628,6 @@ bool ScriptingCore::handleKeyboardEvent(void* nativeObj, cocos2d::EventKeyboard:
ret = executeFunctionWithOwner(OBJECT_TO_JSVAL(p->obj), "_onKeyReleased", 2, args);
}
removeJSObject(_cx, event);
return ret;
}
@@ -1689,11 +1676,6 @@ int ScriptingCore::executeCustomTouchesEvent(EventTouch::EventCode eventType,
jsval jsretArrVal = OBJECT_TO_JSVAL(jsretArr);
executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), funcName.c_str(), 1, &jsretArrVal);
for (auto& touch : touches)
{
removeJSObject(this->_cx, touch);
}
return 1;
}
@@ -1710,8 +1692,6 @@ int ScriptingCore::executeCustomTouchEvent(EventTouch::EventCode eventType, Touc
executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), funcName.c_str(), 1, &jsTouch, &retval);
removeJSObject(this->_cx, touch);
return 1;
}
@@ -1729,8 +1709,6 @@ int ScriptingCore::executeCustomTouchEvent(EventTouch::EventCode eventType,
executeFunctionWithOwner(OBJECT_TO_JSVAL(obj), funcName.c_str(), 1, &jsTouch, retval);
removeJSObject(this->_cx, touch);
return 1;
}
@@ -1845,6 +1823,21 @@ void ScriptingCore::unrootObject(Ref* ref)
else CCLOG("unrootObject: BUG. native not found: %p (%s)", ref, typeid(*ref).name());
}
void ScriptingCore::removeObjectProxy(Ref* obj)
{
auto proxy = jsb_get_native_proxy(obj);
if (proxy)
{
#if ! CC_ENABLE_GC_FOR_NATIVE_OBJECTS
JS::RemoveObjectRoot(_cx, &proxy->obj);
#endif
// remove the proxy here, since this was a "stack" object, not heap
// when js_finalize will be called, it will fail, but
// the correct solution is to have a new finalize for event
jsb_remove_proxy(proxy);
}
}
void ScriptingCore::garbageCollect()
{
#if CC_TARGET_PLATFORM != CC_PLATFORM_WIN32
@@ -532,6 +532,10 @@ public:
* This function is only called when compiled with CC_ENABLE_GC_FOR_NATIVE_OBJECTS=1
*/
virtual void unrootObject(cocos2d::Ref* ref) override;
/** Remove proxy for a native object
*/
virtual void removeObjectProxy(cocos2d::Ref* obj) override;
/**
* Calls the Garbage Collector
@@ -738,7 +738,6 @@ bool js_cocos2dx_extension_EventListenerAssetsManagerEx_init(JSContext *cx, uint
if (!succeed && JS_IsExceptionPending(cx)) {
JS_ReportPendingException(cx);
}
removeJSObject(cx, larg0);
};
arg1 = lambda;
}
@@ -798,7 +797,6 @@ bool js_cocos2dx_extension_EventListenerAssetsManagerEx_create(JSContext *cx, ui
if (!succeed && JS_IsExceptionPending(cx)) {
JS_ReportPendingException(cx);
}
removeJSObject(cx, larg0);
};
arg1 = lambda;
}
@@ -1056,7 +1054,7 @@ void register_all_cocos2dx_extension_manual(JSContext* cx, JS::HandleObject glob
tmpObj.set(tmpVal.toObjectOrNull());
JS_DefineFunction(cx, tmpObj, "create", js_cocos2dx_CCTableView_create, 3, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsbObj, "loadRemoteImg", js_load_remote_image, 2, JSPROP_READONLY | JSPROP_PERMANENT);
JS_DefineFunction(cx, jsbObj, "__loadRemoteImg", js_load_remote_image, 2, JSPROP_READONLY | JSPROP_PERMANENT);
JS::RootedObject performance(cx);
get_or_create_js_obj(cx, global, "performance", &performance);
@@ -194,7 +194,6 @@ bool js_EventListenerAcceleration_create(JSContext *cx, uint32_t argc, jsval *vp
if (!succeed && JS_IsExceptionPending(cx)) {
JS_ReportPendingException(cx);
}
removeJSObject(cx, event);
};
arg0 = lambda;
}
@@ -267,7 +266,6 @@ bool js_EventListenerCustom_create(JSContext *cx, uint32_t argc, jsval *vp)
if (!succeed && JS_IsExceptionPending(cx)) {
JS_ReportPendingException(cx);
}
removeJSObject(cx, event);
};
arg1 = lambda;
}
@@ -324,7 +322,6 @@ bool js_EventDispatcher_addCustomEventListener(JSContext *cx, uint32_t argc, jsv
if (!succeed && JS_IsExceptionPending(cx)) {
JS_ReportPendingException(cx);
}
removeJSObject(cx, event);
};
arg1 = lambda;
}
@@ -20,6 +20,8 @@
* THE SOFTWARE.
*/
'use strict';
ccui.Widget.prototype.init = ccui.Widget.prototype._init;
ccui.RichText.prototype.init = function(){
ccui.Widget.prototype.init.call(this);
@@ -29,7 +29,6 @@
var ccui = ccui || {};
cc.EditBox = ccui.EditBox;
delete ccui.EditBox;
cc.Scale9Sprite = ccui.Scale9Sprite;
@@ -20,6 +20,8 @@
* THE SOFTWARE.
*/
'use strict';
/**
* @type {Object}
* @name jsb.AssetsManager
@@ -28,7 +30,6 @@
* Only available in JSB
*/
jsb.AssetsManager = cc.AssetsManager;
delete cc.AssetsManager;
/**
* @type {Object}
* @name jsb.Manifest
@@ -36,7 +37,6 @@ delete cc.AssetsManager;
* Only available in JSB
*/
jsb.Manifest = cc.Manifest;
delete cc.Manifest;
/**
* @type {Object}
* @name jsb.EventListenerAssetsManager
@@ -45,7 +45,6 @@ delete cc.Manifest;
* Only available in JSB
*/
jsb.EventListenerAssetsManager = cc.EventListenerAssetsManager;
delete cc.EventListenerAssetsManager;
/**
* @type {Object}
* @name jsb.EventAssetsManager
@@ -54,33 +53,28 @@ delete cc.EventListenerAssetsManager;
* 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------------------------------
jsb.EventListenerAssetsManager.prototype._ctor = function(assetsManager, callback) {
callback !== undefined && this.init(assetsManager, callback);
};
//
// cocos2d constants
//
// This helper file should be required after jsb_cocos2d.js
//
var cc = cc || {};
cc.SCROLLVIEW_DIRECTION_NONE = -1;
cc.SCROLLVIEW_DIRECTION_HORIZONTAL = 0;
cc.SCROLLVIEW_DIRECTION_VERTICAL = 1;
cc.SCROLLVIEW_DIRECTION_BOTH = 2;
cc.TABLEVIEW_FILL_TOPDOWN = 0;
cc.TABLEVIEW_FILL_BOTTOMUP = 1;
jsb.Manifest.DownloadState = {
UNSTARTED: 0,
DOWNLOADING: 1,
SUCCESSED: 2
};
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;
/**
* @constant
@@ -203,54 +197,3 @@ cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_SENTENCE = 3;
*/
cc.EDITBOX_INPUT_FLAG_INITIAL_CAPS_ALL_CHARACTERS = 4;
cc.CONTROL_EVENT_TOTAL_NUMBER = 9;
cc.CONTROL_EVENT_TOUCH_DOWN = 1 << 0; // A touch-down event in the control.
cc.CONTROL_EVENT_TOUCH_DRAG_INSIDE = 1 << 1; // An event where a finger is dragged inside the bounds of the control.
cc.CONTROL_EVENT_TOUCH_DRAG_OUTSIDE = 1 << 2; // An event where a finger is dragged just outside the bounds of the control.
cc.CONTROL_EVENT_TOUCH_DRAG_ENTER = 1 << 3; // An event where a finger is dragged into the bounds of the control.
cc.CONTROL_EVENT_TOUCH_DRAG_EXIT = 1 << 4; // An event where a finger is dragged from within a control to outside its bounds.
cc.CONTROL_EVENT_TOUCH_UP_INSIDE = 1 << 5; // A touch-up event in the control where the finger is inside the bounds of the control.
cc.CONTROL_EVENT_TOUCH_UP_OUTSIDE = 1 << 6; // A touch-up event in the control where the finger is outside the bounds of the control.
cc.CONTROL_EVENT_TOUCH_CANCEL = 1 << 7; // A system event canceling the current touches for the control.
cc.CONTROL_EVENT_VALUECHANGED = 1 << 8; // A touch dragging or otherwise manipulating a control; causing it to emit a series of different values.
cc.CONTROL_STATE_NORMAL = 1 << 0; // The normal; or default state of a control梩hat is; enabled but neither selected nor highlighted.
cc.CONTROL_STATE_HIGHLIGHTED = 1 << 1; // Highlighted state of a control. A control enters this state when a touch down; drag inside or drag enter is performed. You can retrieve and set this value through the highlighted property.
cc.CONTROL_STATE_DISABLED = 1 << 2; // Disabled state of a control. This state indicates that the control is currently disabled. You can retrieve and set this value through the enabled property.
cc.CONTROL_STATE_SELECTED = 1 << 3; // Selected state of a control. This state indicates that the control is currently selected. You can retrieve and set this value through the selected property.
cc.CONTROL_STATE_INITIAL = 1 << 3;
cc.CONTROL_ZOOM_ACTION_TAG = 0xCCCB0001; //CCControlButton.js
cc.CONTROL_STEPPER_PARTMINUS = 0; //CCControlStepper.js
cc.CONTROL_STEPPER_PARTPLUS = 1;
cc.CONTROL_STEPPER_PARTNONE = 2;
cc.CONTROL_STEPPER_LABELCOLOR_ENABLED = cc.color(55, 55, 55);
cc.CONTROL_STEPPER_LABELCOLOR_DISABLED = cc.color(147, 147, 147);
cc.CONTROL_STEPPER_LABELFONT = "CourierNewPSMT";
cc.AUTOREPEAT_DELTATIME = 0.15;
cc.AUTOREPEAT_INCREASETIME_INCREMENT = 12;
jsb.Manifest.DownloadState = {
UNSTARTED: 0,
DOWNLOADING: 1,
SUCCESSED: 2
};
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;
@@ -1,102 +0,0 @@
/*
* Copyright (c) 2014-2016 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.
*/
'use strict';
/************************************************************
*
* 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, fontName, autoSizeWithLabel ){
if (autoSizeWithLabel !== undefined && backgroundSprite) {
this.initWithLabelAndBackgroundSprite(label, backgroundSprite, autoSizeWithLabel);
}
else if(fontName !== undefined && fontSize !== undefined) {
this.initWithTitleAndFontNameAndFontSize(label, fontName, fontSize);
}
else if(backgroundSprite !== undefined) {
this.initWithLabelAndBackgroundSprite(label, backgroundSprite, true);
}
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));
};
@@ -1,102 +0,0 @@
/*
* Copyright (c) 2014-2016 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);
@@ -25,45 +25,18 @@
//
// DO NOT ALTER THE ORDER
require('script/jsb_cocos2d_constants.js');
require('script/jsb_cocos2d.js');
require('script/jsb_common.js');
require('script/jsb_property_impls.js');
require('script/jsb_property_apis.js');
require('script/jsb_create_apis.js');
if (window.ccs) {
require('script/studio/jsb_studio_boot.js');
require('script/studio/jsb_cocos2d_studio.js');
require('script/studio/jsb_studio_property_apis.js');
require('script/studio/jsb_studio_create_apis.js');
require('script/studio/jsb_studio_load.js');
require('script/studio/parsers/action-1.x.js');
require('script/studio/parsers/action-2.x.js');
require('script/studio/parsers/scene-1.x.js');
require('script/studio/parsers/timelineParser-1.x.js');
require('script/studio/parsers/timelineParser-2.x.js');
require('script/studio/parsers/uiParser-1.x.js');
require('script/studio/parsers/compatible.js');
}
require('script/extension/jsb_cocos2d_extension.js');
if (window.ccui) {
require('script/ccui/jsb_cocos2d_ui.js');
require('script/ccui/jsb_ccui_property_impls.js');
require('script/ccui/jsb_ccui_property_apis.js');
require('script/ccui/jsb_ccui_create_apis.js');
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');
}
if (cc.PhysicsSprite) {
require('script/physicsSprite/jsb_physicsSprite.js');
}
if (window.cp) {
@@ -75,31 +48,8 @@ if (window.cp) {
require('script/jsb_opengl_constants.js');
require('script/jsb_opengl.js');
if (cc.BuilderAnimationManager) {
require('script/jsb_cocosbuilder.js');
}
if (jsb.fileUtils.isFileExist('jsb_pluginx.js') || jsb.fileUtils.isFileExist('jsb_pluginx.jsc')) {
if (cc.sys.os == cc.sys.OS_IOS || cc.sys.os == cc.sys.OS_ANDROID) {
require('jsb_pluginx.js');
}
}
if (window.sp) {
require('script/jsb_spine.js');
}
if (window.dragonBones) {
require('script/jsb_dragonbones.js');
}
require("script/jsb_audioengine.js");
require('script/jsb_loaders.js');
require('script/jsb_pool.js');
require('script/jsb_deprecated.js');
if (typeof runtime !== 'undefined') {
require('script/runtime/jsb_runtime.js');
require('script/runtime/jsb_runtime_md5.js');
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -1,141 +0,0 @@
/*
* AUTOGENERATED FILE. DO NOT EDIT IT
* Generated by "generate_jsb.py -c cocos2d_jsb.ini" on 2013-03-10
* Script version: v0.6
*/
var cc = cc || {};
cc.Sprite.INDEX_NOT_INITIALIZED = -1;
cc.TMX_ORIENTATION_HEX = 0x1;
cc.TMX_ORIENTATION_ISO = 0x2;
cc.TMX_ORIENTATION_ORTHO = 0x0;
cc.Z_COMPRESSION_BZIP2 = 0x1;
cc.Z_COMPRESSION_GZIP = 0x2;
cc.Z_COMPRESSION_NONE = 0x3;
cc.Z_COMPRESSION_ZLIB = 0x0;
cc.BLEND_DST = 0x303;
cc.BLEND_SRC = 0x1;
cc.DIRECTOR_IOS_USE_BACKGROUND_THREAD = 0x0;
cc.DIRECTOR_MAC_THREAD = 0x0;
cc.DIRECTOR_STATS_INTERVAL = 0.1;
cc.ENABLE_BOX2_D_INTEGRATION = 0x0;
cc.ENABLE_DEPRECATED = 0x1;
cc.ENABLE_GL_STATE_CACHE = 0x1;
cc.ENABLE_PROFILERS = 0x0;
cc.ENABLE_STACKABLE_ACTIONS = 0x1;
cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0x0;
cc.GL_ALL = 0x0;
cc.LABELATLAS_DEBUG_DRAW = 0x0;
cc.LABELBMFONT_DEBUG_DRAW = 0x0;
cc.MAC_USE_DISPLAY_LINK_THREAD = 0x0;
cc.MAC_USE_MAIN_THREAD = 0x2;
cc.MAC_USE_OWN_THREAD = 0x1;
cc.NODE_RENDER_SUBPIXEL = 0x1;
cc.PVRMIPMAP_MAX = 0x10;
cc.SPRITEBATCHNODE_RENDER_SUBPIXEL = 0x1;
cc.SPRITE_DEBUG_DRAW = 0x0;
cc.TEXTURE_ATLAS_USE_TRIANGLE_STRIP = 0x0;
cc.TEXTURE_ATLAS_USE_VAO = 0x1;
cc.USE_L_A88_LABELS = 0x1;
cc.ACTION_TAG_INVALID = -1;
cc.DEVICE_MAC = 0x6;
cc.DEVICE_MAC_RETINA_DISPLAY = 0x7;
cc.DEVICEI_PAD = 0x4;
cc.DEVICEI_PAD_RETINA_DISPLAY = 0x5;
cc.DEVICEI_PHONE = 0x0;
cc.DEVICEI_PHONE5 = 0x2;
cc.DEVICEI_PHONE5_RETINA_DISPLAY = 0x3;
cc.DEVICEI_PHONE_RETINA_DISPLAY = 0x1;
cc.FILE_UTILS_SEARCH_DIRECTORY_MODE = 0x1;
cc.FILE_UTILS_SEARCH_SUFFIX_MODE = 0x0;
cc.FLIPED_ALL = 0xe0000000;
cc.FLIPPED_MASK = 0x1fffffff;
cc.IMAGE_FORMAT_JPEG = 0x0;
cc.IMAGE_FORMAT_PNG = 0x1;
cc.ITEM_SIZE = 0x20;
cc.LABEL_AUTOMATIC_WIDTH = -1;
cc.LINE_BREAK_MODE_CHARACTER_WRAP = 0x1;
cc.LINE_BREAK_MODE_CLIP = 0x2;
cc.LINE_BREAK_MODE_HEAD_TRUNCATION = 0x3;
cc.LINE_BREAK_MODE_MIDDLE_TRUNCATION = 0x5;
cc.LINE_BREAK_MODE_TAIL_TRUNCATION = 0x4;
cc.LINE_BREAK_MODE_WORD_WRAP = 0x0;
cc.MAC_VERSION_10_6 = 0xa060000;
cc.MAC_VERSION_10_7 = 0xa070000;
cc.MAC_VERSION_10_8 = 0xa080000;
cc.MENU_HANDLER_PRIORITY = -128;
cc.MENU_STATE_TRACKING_TOUCH = 0x1;
cc.MENU_STATE_WAITING = 0x0;
cc.NODE_TAG_INVALID = -1;
cc.ParticleSystem.TYPE_FREE = 0;
cc.ParticleSystem.TYPE_RELATIVE = 1;
cc.ParticleSystem.TYPE_GROUPED = 2;
cc.ParticleSystem.DURATION_INFINITY = -1;
cc.ParticleSystem.MODE_GRAVITY = 0;
cc.ParticleSystem.MODE_RADIUS = 1;
cc.ParticleSystem.START_SIZE_EQUAL_TO_END_SIZE = -1;
cc.ParticleSystem.START_RADIUS_EQUAL_TO_END_RADIUS = -1;
cc.PRIORITY_NON_SYSTEM_MIN = -2147483647;
cc.ProgressTimer.TYPE_BAR = 0x1;
cc.ProgressTimer.TYPE_RADIAL = 0x0;
cc.RESOLUTION_MAC = 0x1;
cc.RESOLUTION_MAC_RETINA_DISPLAY = 0x2;
cc.RESOLUTION_UNKNOWN = 0x0;
cc.TMX_TILE_DIAGONAL_FLAG = 0x20000000;
cc.TMX_TILE_HORIZONTAL_FLAG = 0x80000000;
cc.TMX_TILE_VERTICAL_FLAG = 0x40000000;
cc.TEXT_ALIGNMENT_CENTER = 1;
cc.TEXT_ALIGNMENT_RIGHT = 2;
cc.TEXT_ALIGNMENT_LEFT = 0;
cc.VERTICAL_TEXT_ALIGNMENT_TOP = 0;
cc.VERTICAL_TEXT_ALIGNMENT_CENTER = 1;
cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM = 2;
cc.TOUCHES_ALL_AT_ONCE = 0x0;
cc.TOUCHES_ONE_BY_ONE = 0x1;
cc.TRANSITION_ORIENTATION_DOWN_OVER = 0x1;
cc.TRANSITION_ORIENTATION_LEFT_OVER = 0x0;
cc.TRANSITION_ORIENTATION_RIGHT_OVER = 0x1;
cc.TRANSITION_ORIENTATION_UP_OVER = 0x0;
cc.UNIFORM_COS_TIME = 0x5;
cc.UNIFORM_MV_MATRIX = 0x1;
cc.UNIFORM_MVP_MATRIX = 0x2;
cc.UNIFORM_P_MATRIX = 0x0;
cc.UNIFORM_RANDOM01 = 0x6;
cc.UNIFORM_SAMPLER = 0x7;
cc.UNIFORM_SIN_TIME = 0x4;
cc.UNIFORM_TIME = 0x3;
cc.UNIFORM_MAX = 0x8;
cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM = 0x2;
cc.VERTICAL_TEXT_ALIGNMENT_CENTER = 0x1;
cc.VERTICAL_TEXT_ALIGNMENT_TOP = 0x0;
cc.OS_VERSION_4_0 = 0x4000000;
cc.OS_VERSION_4_0_1 = 0x4000100;
cc.OS_VERSION_4_1 = 0x4010000;
cc.OS_VERSION_4_2 = 0x4020000;
cc.OS_VERSION_4_2_1 = 0x4020100;
cc.OS_VERSION_4_3 = 0x4030000;
cc.OS_VERSION_4_3_1 = 0x4030100;
cc.OS_VERSION_4_3_2 = 0x4030200;
cc.OS_VERSION_4_3_3 = 0x4030300;
cc.OS_VERSION_4_3_4 = 0x4030400;
cc.OS_VERSION_4_3_5 = 0x4030500;
cc.OS_VERSION_5_0 = 0x5000000;
cc.OS_VERSION_5_0_1 = 0x5000100;
cc.OS_VERSION_5_1_0 = 0x5010000;
cc.OS_VERSION_6_0_0 = 0x6000000;
cc.ANIMATION_FRAME_DISPLAYED_NOTIFICATION = 'CCAnimationFrameDisplayedNotification';
cc.CHIPMUNK_IMPORT = 'chipmunk.h';
cc.ATTRIBUTE_NAME_COLOR = 'a_color';
cc.ATTRIBUTE_NAME_POSITION = 'a_position';
cc.ATTRIBUTE_NAME_TEX_COORD = 'a_texCoord';
cc.ATTRIBUTE_NAME_TEX_COORD1 = "a_texCoord1";
cc.ATTRIBUTE_NAME_TEX_COORD2 = "a_texCoord2";
cc.ATTRIBUTE_NAME_TEX_COORD3 = "a_texCoord3";
cc.ATTRIBUTE_NAME_NORMAL = "a_normal";
cc.ATTRIBUTE_NAME_BLEND_WEIGHT = "a_blendWeight";
cc.ATTRIBUTE_NAME_BLEND_INDEX = "a_blendIndex";
@@ -1,208 +0,0 @@
/*
* Copyright (c) 2013-2016 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.
*/
//
// CocosBuilder definitions
//
cc.BuilderReader = cc.BuilderReader || {};
cc.BuilderReader._resourcePath = "";
cc.BuilderReader._controllerClassCache = {};
cc.BuilderReader.registerController = function(controllerName, controller){
cc.BuilderReader._controllerClassCache[controllerName] = cc.Class.extend(controller);
};
cc.BuilderReader.setResourcePath = function (rootPath) {
cc.BuilderReader._resourcePath = rootPath;
};
cc.BuilderReader.load = function(file, owner, parentSize)
{
// Load the node graph using the correct function
var reader = cc._Reader.create();
reader.setCCBRootPath(cc.BuilderReader._resourcePath);
var node;
if (parentSize)
{
node = reader.load(file, null, parentSize);
}
else
{
node = reader.load(file);
}
// Assign owner callbacks & member variables
if (owner)
{
// Callbacks
var ownerCallbackNames = reader.getOwnerCallbackNames();
var ownerCallbackNodes = reader.getOwnerCallbackNodes();
for (var i = 0; i < ownerCallbackNames.length; i++)
{
var callbackName = ownerCallbackNames[i];
var callbackNode = ownerCallbackNodes[i];
if (owner[callbackName] === undefined)
{
cc.log("Warning: " + "owner." + callbackName + " is undefined.");
}
else
{
if(callbackNode instanceof cc.ControlButton)
{
var ownerCallbackControlEvents = reader.getOwnerCallbackControlEvents();
callbackNode.addTargetWithActionForControlEvents(owner, owner[callbackName], ownerCallbackControlEvents[i]);
}
else
{
callbackNode.setCallback(owner[callbackName], owner);
}
}
}
// Variables
var ownerOutletNames = reader.getOwnerOutletNames();
var ownerOutletNodes = reader.getOwnerOutletNodes();
for (var i = 0; i < ownerOutletNames.length; i++)
{
var outletName = ownerOutletNames[i];
var outletNode = ownerOutletNodes[i];
owner[outletName] = outletNode;
}
}
var nodesWithAnimationManagers = reader.getNodesWithAnimationManagers();
node._nodesWithAnimationManagers = nodesWithAnimationManagers;
var animationManagersForNodes = reader.getAnimationManagersForNodes();
var controllerClassCache = cc.BuilderReader._controllerClassCache;
// Attach animation managers to nodes and assign root node callbacks and member variables
for (var i = 0; i < nodesWithAnimationManagers.length; i++)
{
var innerNode = nodesWithAnimationManagers[i];
var animationManager = animationManagersForNodes[i];
innerNode.animationManager = animationManager;
var controllerName = animationManager.getDocumentControllerName();
if (!controllerName) continue;
// Create a controller
var controllerClass = controllerClassCache[controllerName];
if(!controllerClass) throw "Can not find controller : " + controllerName;
var controller = new controllerClass();
controller.controllerName = controllerName;
innerNode.controller = controller;
controller.rootNode = innerNode;
// Callbacks
var documentCallbackNames = animationManager.getDocumentCallbackNames();
var documentCallbackNodes = animationManager.getDocumentCallbackNodes();
innerNode._documentCallbackNodes = documentCallbackNodes;
for (var j = 0; j < documentCallbackNames.length; j++)
{
var callbackName = documentCallbackNames[j];
var callbackNode = documentCallbackNodes[j];
if (controller[callbackName] === undefined)
{
cc.log("Warning: " + controllerName + "." + callbackName + " is undefined.");
}
else
{
if(callbackNode instanceof cc.ControlButton)
{
var documentCallbackControlEvents = animationManager.getDocumentCallbackControlEvents();
callbackNode.addTargetWithActionForControlEvents(controller, controller[callbackName], documentCallbackControlEvents[j]);
}
else
{
callbackNode.setCallback(controller[callbackName], controller);
}
}
}
// Variables
var documentOutletNames = animationManager.getDocumentOutletNames();
var documentOutletNodes = animationManager.getDocumentOutletNodes();
for (var j = 0; j < documentOutletNames.length; j++)
{
var outletName = documentOutletNames[j];
var outletNode = documentOutletNodes[j];
controller[outletName] = outletNode;
}
if (typeof(controller.onDidLoadFromCCB) == "function")
{
controller.onDidLoadFromCCB();
}
// Setup timeline callbacks
var keyframeCallbacks = animationManager.getKeyframeCallbacks();
for (var j = 0; j < keyframeCallbacks.length; j++)
{
var callbackSplit = keyframeCallbacks[j].split(":");
var callbackType = callbackSplit[0];
var callbackName = callbackSplit[1];
if (callbackType == 1) // Document callback
{
var callfunc = cc.CallFunc.create(controller[callbackName], controller);
animationManager.setCallFunc(callfunc, keyframeCallbacks[j]);
}
else if (callbackType == 2 && owner) // Owner callback
{
var callfunc = cc.CallFunc.create(owner[callbackName], owner);
animationManager.setCallFunc(callfunc, keyframeCallbacks[j]);
}
}
// Start animation
var autoPlaySeqId = animationManager.getAutoPlaySequenceId();
if (autoPlaySeqId != -1)
{
animationManager.runAnimationsForSequenceIdTweenDuration(autoPlaySeqId, 0);
}
}
return node;
};
cc.BuilderReader.loadAsScene = function(file, owner, parentSize)
{
var node = cc.BuilderReader.load(file, owner, parentSize);
var scene = cc.Scene.create();
scene.addChild( node );
return scene;
};
@@ -20,6 +20,8 @@
* THE SOFTWARE.
*/
'use strict';
/************************************************************
*
* Constructors with built in init function
@@ -64,19 +66,6 @@ _p._ctor = function(start, end, v, colorStops) {
};
_p = cc.LayerMultiplex.prototype;
_p._ctor = function(layers) {
if(layers !== undefined){
if (layers instanceof Array)
cc.LayerMultiplex.prototype.initWithArray.call(this, layers);
else
cc.LayerMultiplex.prototype.initWithArray.call(this, Array.prototype.slice.call(arguments));
}else{
cc.LayerMultiplex.prototype.init.call(this);
}
};
/************************ Sprite *************************/
_p = cc.Sprite.prototype;
@@ -108,15 +97,6 @@ _p._ctor = function(fileName, rect) {
}
};
_p = cc.SpriteBatchNode.prototype;
_p._ctor = function(fileImage, capacity) {
capacity = capacity || cc.SpriteBatchNode.DEFAULT_CAPACITY;
if (typeof(fileImage) == 'string')
this.initWithFile(fileImage, capacity);
else
this.initWithTexture(fileImage, capacity);
};
_p = cc.SpriteFrame.prototype;
_p._ctor = function(filename, rect, rotated, offset, originalSize){
if(originalSize !== undefined){
@@ -132,168 +112,6 @@ _p._ctor = function(filename, rect, rotated, offset, originalSize){
}
};
/***************************** effect *******************************/
_p = cc.GridBase.prototype;
_p._ctor = function(gridSize, texture, flipped){
if(gridSize !== undefined)
this.initWithSize(gridSize, texture, flipped);
};
_p = cc.Grid3D.prototype;
_p._ctor = function(gridSize, texture, flipped){
if(gridSize !== undefined)
this.initWithSize(gridSize, texture, flipped);
};
_p = cc.TiledGrid3D.prototype;
_p._ctor = function(gridSize, texture, flipped){
if(gridSize !== undefined)
this.initWithSize(gridSize, texture, flipped);
};
/************************ Menu and menu items *************************/
_p = cc.Menu.prototype;
_p._ctor = function(menuItems) {
if((arguments.length > 0) && (arguments[arguments.length-1] == null))
cc.log('parameters should not be ending with null in Javascript');
var argc = arguments.length,
items = [];
if (argc == 1) {
if (menuItems instanceof Array) {
items = menuItems;
}
else{
items.push(arguments[0]);
}
}
else if (argc > 1) {
for (var i = 0; i < argc; i++) {
if (arguments[i])
items.push(arguments[i]);
}
}
if(items && items.length > 0)
this.initWithArray(items);
else
this.init();
};
_p = cc.MenuItem.prototype;
_p._ctor = function(callback, target) {
callback && this.initWithCallback(callback.bind(target));
};
_p = cc.MenuItemLabel.prototype;
_p._ctor = function(label, callback, target) {
callback = callback ? callback.bind(target) : null;
label && this.initWithLabel(label, callback);
};
_p = cc.MenuItemAtlasFont.prototype;
_p._ctor = function(value, charMapFile, itemWidth, itemHeight, startCharMap, callback, target) {
callback = callback ? callback.bind(target) : null;
value !== undefined && this.initWithString(value, charMapFile, itemWidth, itemHeight, startCharMap, callback);
};
_p = cc.MenuItemFont.prototype;
_p._ctor = function(value, callback, target) {
callback = callback ? callback.bind(target) : null;
value !== undefined && this.initWithString(value, callback);
};
_p = cc.MenuItemSprite.prototype;
_p._ctor = function(normalSprite, selectedSprite, three, four, five) {
if (normalSprite) {
normalSprite = normalSprite;
selectedSprite = selectedSprite || null;
var disabledSprite, target, callback;
if (five) {
disabledSprite = three;
callback = four;
target = five;
} else if (four && typeof four === 'function') {
disabledSprite = three;
callback = four;
} else if (four && typeof three === 'function') {
target = four;
callback = three;
disabledSprite = normalSprite;
} else if (three === undefined) {
disabledSprite = normalSprite;
}
callback = callback ? callback.bind(target) : null;
this.initWithNormalSprite(normalSprite, selectedSprite, disabledSprite, callback);
}
};
_p = cc.MenuItemImage.prototype;
_p._ctor = function(normalImage, selectedImage, three, four, five) {
var disabledImage = null,
callback = null,
target = null;
if (normalImage === undefined) {
cc.MenuItemImage.prototype.init.call(this);
}
else {
if (four === undefined) {
callback = three;
}
else if (five === undefined) {
if (typeof three === 'function') {
callback = three;
target = four;
}
else {
disabledImage = three;
callback = four;
}
}
else if (five) {
disabledImage = three;
callback = four;
target = five;
}
callback = callback ? callback.bind(target) : null;
var normalSprite = new cc.Sprite(normalImage);
var selectedSprite = new cc.Sprite(selectedImage);
var disabledSprite = disabledImage ? new cc.Sprite(disabledImage) : new cc.Sprite(normalImage);
this.initWithNormalSprite(normalSprite, selectedSprite, disabledSprite, callback);
}
};
_p = cc.MenuItemToggle.prototype;
_p._ctor = function() {
var argc = arguments.length, callback, target;
// passing callback.
if (typeof arguments[argc-2] === 'function') {
callback = arguments[argc-2];
target = arguments[argc-1];
argc = argc - 2;
} else if(typeof arguments[argc-1] === 'function'){
callback = arguments[argc-1];
argc = argc - 1;
}
if(argc > 0) {
this.initWithItem(arguments[0]);
for (var i = 1; i < argc; i++) {
if (arguments[i])
this.addSubItem(arguments[i]);
}
if (callback)
target ? this.setCallback(callback, target) : this.setCallback(callback);
}
else {
callback = callback ? callback.bind(target) : null;
this.initWithCallback(callback);
}
};
/************************ motion-streak *************************/
_p = cc.MotionStreak.prototype;
_p._ctor = function(fade, minSeg, stroke, color, texture){
@@ -336,31 +154,6 @@ cc.ParticleSmoke.prototype._ctor = dummyCtor;
cc.ParticleRain.prototype._ctor = dummyCtor;
cc.ParticleSnow.prototype._ctor = dummyCtor;
/************************ ProgressTimer *************************/
_p = cc.ProgressTimer.prototype;
_p._ctor = function(sprite){
sprite !== undefined && this.initWithSprite(sprite);
};
/************************ TextFieldTTF *************************/
_p = cc.TextFieldTTF.prototype;
_p._ctor = function(placeholder, dimensions, alignment, fontName, fontSize){
if(fontSize !== undefined){
this.initWithPlaceHolder('', dimensions, alignment, fontName, fontSize);
if(placeholder)
this._placeHolder = placeholder;
}
else if(fontName === undefined && alignment !== undefined){
fontName = arguments[1];
fontSize = arguments[2];
this.initWithString('', fontName, fontSize);
if(placeholder)
this._placeHolder = placeholder;
}
};
/************************ RenderTexture *************************/
_p = cc.RenderTexture.prototype;
_p._ctor = function(width, height, format, depthStencilFormat){
@@ -402,23 +195,6 @@ _p._ctor = function(tmxFile, resourcePath){
}
};
/************************ TransitionScene *************************/
_p = cc.TransitionScene.prototype;
_p._ctor = function(t, scene){
if(t !== undefined && scene !== undefined)
this.initWithDuration(t, scene);
};
_p = cc.TransitionSceneOriented.prototype;
_p._ctor = function(t, scene, orientation){
orientation != undefined && this.initWithDuration(t, scene, orientation);
};
_p = cc.TransitionPageTurn.prototype;
_p._ctor = function(t, scene, backwards){
backwards != undefined && this.initWithDuration(t, scene, backwards);
};
/************************ Actions *************************/
cc.Speed.prototype._ctor = function(action, speed) {
@@ -760,10 +536,6 @@ cc.AnimationFrame.prototype._ctor = function(spriteFrame, delayUnits, userInfo)
/************************ Nodes *************************/
cc.AtlasNode.prototype._ctor = function(tile, tileWidth, tileHeight, itemsToRender) {
itemsToRender !== undefined && this.initWithTileFile(tile, tileWidth, tileHeight, itemsToRender);
};
cc.ClippingNode.prototype._ctor = function(stencil) {
if(stencil != undefined)
cc.ClippingNode.prototype.init.call(this, stencil);
@@ -775,16 +547,6 @@ cc.DrawNode.prototype._ctor = function() {
cc.DrawNode.prototype.init.call(this);
};
cc.LabelBMFont.prototype._ctor = function(str, fntFile, width, alignment, imageOffset) {
if( fntFile ) {
str = str || '';
width = width || 0;
alignment = alignment === undefined ? cc.TEXT_ALIGNMENT_LEFT : alignment;
imageOffset = imageOffset || cc.p(0, 0);
cc.LabelBMFont.prototype.initWithString.call(this, str, fntFile, width, alignment, imageOffset);
}
};
cc.LabelTTF.prototype._ctor = function(text, fontName, fontSize, dimensions, hAlignment, vAlignment) {
this._flippedX = false;
this._flippedY = false;
@@ -807,7 +569,6 @@ cc.LabelTTF.prototype._ctor = function(text, fontName, fontSize, dimensions, hAl
}
};
/************************ Other classes *************************/
cc.EventTouch.prototype._ctor = function(touches) {
@@ -824,299 +585,3 @@ cc.GLProgram.prototype._ctor = function(vShaderFileName, fShaderFileName) {
cc.GLProgram.prototype.updateUniforms.call(this);
}
};
/************************************************************
*
* Unified create function
*
************************************************************/
/**
* Create a sprite with image path or frame name or texture or spriteFrame.
* @constructs
* @param {String|cc.Texture2D|cc.SpriteFrame} fileName The string which indicates a path to image file, e.g., 'scene1/monster.png'.
* @param {cc.Rect} rect Only the contents inside rect of pszFileName's texture will be applied for this sprite.
* @return {cc.Sprite} A valid sprite object
* @example
*
* 1.Create a sprite with image path and rect
* var sprite1 = cc.Sprite.create('res/HelloHTML5World.png');
* var sprite2 = cc.Sprite.create('res/HelloHTML5World.png',cc.rect(0,0,480,320));
*
* 2.Create a sprite with a sprite frame name. Must add '#' before frame name.
* var sprite = cc.Sprite.create('#grossini_dance_01.png');
*
* 3.Create a sprite with a sprite frame
* var spriteFrame = cc.spriteFrameCache.getSpriteFrame('grossini_dance_01.png');
* var sprite = cc.Sprite.create(spriteFrame);
*
* 4.Create a sprite with an existing texture contained in a CCTexture2D object
* After creation, the rect will be the size of the texture, and the offset will be (0,0).
* var texture = cc.textureCache.addImage('HelloHTML5World.png');
* var sprite1 = cc.Sprite.create(texture);
* var sprite2 = cc.Sprite.create(texture, cc.rect(0,0,480,320));
*
*/
cc.Sprite.create = function (fileName, rect) {
return new cc.Sprite(fileName, rect);
};
cc.SpriteBatchNode._create = cc.SpriteBatchNode.create;
/**
* <p>
* creates a cc.SpriteBatchNodeCanvas with a file image (.png, .jpg etc) with a default capacity of 29 children.<br/>
* The capacity will be increased in 33% in runtime if it run out of space.<br/>
* The file will be loaded using the TextureMgr.<br/>
* </p>
* @param {String|cc.Texture2D} fileImage
* @param {Number} capacity
* @return {cc.SpriteBatchNode}
* @example
* 1.
* //create a SpriteBatchNode with image path
* var spriteBatchNode = cc.SpriteBatchNode.create('res/animations/grossini.png', 50);
* 2.
* //create a SpriteBatchNode with texture
* var texture = cc.textureCache.addImage('res/animations/grossini.png');
* var spriteBatchNode = cc.SpriteBatchNode.create(texture,50);
*/
cc.SpriteBatchNode.create = function(fileName, capacity){
return new cc.SpriteBatchNode(fileName, capacity);
};
/**
* <p>
* Create a cc.SpriteFrame with a texture filename, rect, rotated, offset and originalSize in pixels.<br/>
* The originalSize is the size in pixels of the frame before being trimmed.
* </p>
* @param {String|cc.Texture2D} filename
* @param {cc.Rect} rect if parameters' length equal 2, rect in points, else rect in pixels
* @param {Boolean} rotated
* @param {cc.Point} offset
* @param {cc.Size} originalSize
* @return {cc.SpriteFrame}
* @example
* 1.
* //Create a cc.SpriteFrame with image path
* var frame1 = cc.SpriteFrame.create('res/grossini_dance.png',cc.rect(0,0,90,128));
* var frame2 = cc.SpriteFrame.create('res/grossini_dance.png',cc.rect(0,0,90,128),false,0,cc.size(90,128));
*
* 2.
* //Create a cc.SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels.
* var texture = cc.textureCache.addImage('res/grossini_dance.png');
* var frame1 = cc.SpriteFrame.create(texture, cc.rect(0,0,90,128));
* var frame2 = cc.SpriteFrame.create(texture, cc.rect(0,0,90,128),false,0,cc.size(90,128));
*/
cc.SpriteFrame.create = function(fileName, rect, rotated, offset, originalSize){
return new cc.SpriteFrame(fileName, rect, rotated, offset, originalSize);
};
cc.ParticleSystem._create = cc.ParticleSystem.create;
/**
* <p> return the string found by key in dict. <br/>
* This plist files can be create manually or with Particle Designer:<br/>
* http://particledesigner.71squared.com/<br/>
* </p>
* @param {String|Number} plistFile
* @return {cc.ParticleSystem}
*/
cc.ParticleSystem.create = function(plistFile){
return new cc.ParticleSystem(plistFile);
};
/**
* initializes the particle system with the name of a file on disk (for a list of supported formats look at the cc.Texture2D class), a capacity of particles
* @param {String|cc.Texture2D} fileImage
* @param {Number} capacity
* @return {cc.ParticleBatchNode}
* @example
* 1.
* //Create a cc.ParticleBatchNode with image path and capacity
* var particleBatchNode = cc.ParticleBatchNode.create('res/grossini_dance.png',30);
*
* 2.
* //Create a cc.ParticleBatchNode with a texture and capacity
* var texture = cc.TextureCache.getInstance().addImage('res/grossini_dance.png');
* var particleBatchNode = cc.ParticleBatchNode.create(texture, 30);
*/
cc.ParticleBatchNode.create = function(fileImage, capacity){
return new cc.ParticleBatchNode(fileImage, capacity);
};
/**
* Creates a TMX Tiled Map with a TMX file or content string.
* Implementation cc.TMXTiledMap
* @param {String} tmxFile tmxFile fileName or content string
* @param {String} resourcePath If tmxFile is a file name ,it is not required.If tmxFile is content string ,it is must required.
* @return {cc.TMXTiledMap|undefined}
* @example
* //example
* 1.
* //create a TMXTiledMap with file name
* var tmxTiledMap = cc.TMXTiledMap.create('res/orthogonal-test1.tmx');
* 2.
* //create a TMXTiledMap with content string and resource path
* var resources = 'res/TileMaps';
* var filePath = 'res/TileMaps/orthogonal-test1.tmx';
* var xmlStr = cc.loader.getRes(filePath);
* var tmxTiledMap = cc.TMXTiledMap.create(xmlStr, resources);
*/
cc.TMXTiledMap.create = function (tmxFile, resourcePath) {
return new cc.TMXTiledMap(tmxFile, resourcePath);
};
// MenuItems
cc.MenuItem.create = function (callback, target) {
return new cc.MenuItem(callback, target);
};
cc.MenuItemLabel.create = function (label, selector, target) {
return new cc.MenuItemLabel(label, selector, target);
};
cc.MenuItemAtlasFont.create = function (value, charMapFile, itemWidth, itemHeight, startCharMap, callback, target) {
return new cc.MenuItemAtlasFont(value, charMapFile, itemWidth, itemHeight, startCharMap, callback, target);
};
cc.MenuItemFont.create = function (value, callback, target) {
return new cc.MenuItemFont(value, callback, target);
};
cc.MenuItemSprite.create = function (normalSprite, selectedSprite, three, four, five) {
return new cc.MenuItemSprite(normalSprite, selectedSprite, three, four, five || undefined);
};
cc.MenuItemImage.create = function(normalImage, selectedImage, three, four, five) {
return new cc.MenuItemImage(normalImage, selectedImage, three, four, five);
};
cc.MenuItemToggle.create = function(/* var args */) {
var n = arguments.length;
if (typeof arguments[n-2] === 'function' || typeof arguments[n-1] === 'function') {
var args = Array.prototype.slice.call(arguments);
var obj = null;
if( typeof arguments[n-2] === 'function' )
obj = args.pop();
var func = args.pop();
// create it with arguments,
var item = cc.MenuItemToggle._create.apply(this, args);
// then set the callback
if( obj !== null )
item.setCallback(func, obj);
else
item.setCallback(func);
return item;
} else {
return cc.MenuItemToggle._create.apply(this, arguments);
}
};
// LayerMultiplex
cc.LayerMultiplex.create = cc.LayerMultiplex.createWithArray = function (layers) {
var result = new cc.LayerMultiplex();
if(layers !== undefined){
if (layers instanceof Array)
cc.LayerMultiplex.prototype.initWithArray.call(result, layers);
else
cc.LayerMultiplex.prototype.initWithArray.call(result, Array.prototype.slice.call(arguments));
}else{
cc.LayerMultiplex.prototype.init.call(result);
}
return result;
};
/**
* Creates an animation.
* @param {Array} frames
* @param {Number} delay
* @param {Number} [loops=1]
* @return {cc.Animation}
* @example
*
* 1.Creates an empty animation
* var animation1 = cc.Animation.create();
*
* 2.Create an animation with sprite frames , delay and loops.
* var spriteFrames = [];
* var frame = cache.getSpriteFrame('grossini_dance_01.png');
* spriteFrames.push(frame);
* var animation1 = cc.Animation.create(spriteFrames);
* var animation2 = cc.Animation.create(spriteFrames, 0.2);
* var animation2 = cc.Animation.create(spriteFrames, 0.2, 2);
*
* 3.Create an animation with animation frames , delay and loops.
* var animationFrames = [];
* var frame = new cc.AnimationFrame();
* animationFrames.push(frame);
* var animation1 = cc.Animation.create(animationFrames);
* var animation2 = cc.Animation.create(animationFrames, 0.2);
* var animation3 = cc.Animation.create(animationFrames, 0.2, 2);
*/
cc.Animation.create = function (frames, delay, loops) {
if(frames === undefined){
return cc.Animation.createWithAnimationFrames();
}
else if(frames[0] && frames[0] instanceof cc.AnimationFrame){
return cc.Animation.createWithAnimationFrames.apply(this, arguments);
}
else if(frames[0] && frames[0] instanceof cc.SpriteFrame){
delay = delay || 0;
return cc.Animation.createWithSpriteFrames.apply(this, arguments);
}
};
cc.Menu.create = function(menuItems) {
if((arguments.length > 0) && (arguments[arguments.length-1] == null))
cc.log('parameters should not be ending with null in Javascript');
var argc = arguments.length,
items = [];
if (argc == 1) {
if (menuItems instanceof Array) {
items = menuItems;
}
else{
items.push(arguments[0]);
}
}
else if (argc > 1) {
for (var i = 0; i < argc; i++) {
if (arguments[i])
items.push(arguments[i]);
}
}
return cc.Menu._create.apply(null, items);
};
cc.GLProgram.create = function (vShaderFileName, fShaderFileName) {
return new cc.GLProgram(vShaderFileName, fShaderFileName);
};
cc.GLProgram.createWithString = function (vShader, fShader) {
var program = new cc.GLProgram();
program.initWithByteArrays(vShader, fShader);
return program;
};
cc.TMXLayer.prototype.tileFlagsAt = cc.TMXLayer.prototype.getTileFlagsAt;
sys.localStorage._setItem = sys.localStorage.setItem;
sys.localStorage.setItem = function(itemKey,itemValue) {
if (typeof itemKey === 'string') {
if(itemValue !== undefined && itemValue !== null)
{
if (typeof itemValue !== 'string') {
cc.log("sys.localStorage.setItem Warning: itemValue[" + itemValue + "] is not string!");
itemValue = '' + itemValue;
}
sys.localStorage._setItem(itemKey, itemValue);
}
}
else
cc.log("sys.localStorage.setItem Warning: itemKey[" + itemKey + "] is not string!");
}
@@ -1,121 +0,0 @@
/*
* Copyright (c) 2013-2016 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.
*/
// Deprecated functions
var cc = cc || {};
(function() {
var logW = function(old_name, new_name) {
cc.log("\n********** \n"+old_name +" was deprecated, please use "+ new_name +" instead.\n**********");
};
// Deprecated static functions
cc.AnimationCache.purgeSharedAnimationCache = function() {
logW("cc.AnimationCache.purgeSharedAnimationCache", "cc.AnimationCache.destroyInstance");
cc.AnimationCache.destroyInstance();
};
cc.TextureCache.getInstance = function() {
return cc.Director.getInstance().getTextureCache();
};
// Deprecated member functions
cc.Action.prototype.copy = function() {
logW("cc.Action.copy", "cc.Action.clone");
return cc.Action.prototype.clone.apply(this, arguments);
};
cc.Animation.prototype.copy = function() {
logW("cc.Animation.copy", "cc.Animation.clone");
return cc.Animation.prototype.clone.apply(this, arguments);
};
cc.Node.prototype.nodeToWorldTransform = function() {
logW("cc.Node.nodeToWorldTransform", "cc.Node.getNodeToWorldTransform");
return cc.Node.prototype.getNodeToWorldTransform.apply(this, arguments);
};
cc.Node.prototype.getZOrder = function() {
logW("cc.Node.getZOrder", "cc.Node.getLocalZOrder");
return cc.Node.prototype.getLocalZOrder.apply(this, arguments);
};
cc.Node.prototype.setZOrder = function() {
logW("cc.Node.setZOrder", "cc.Node.setLocalZOrder");
cc.Node.prototype.setLocalZOrder.apply(this, arguments);
};
// Not deprecated in the web engine yet, so no need to log
cc.Node.prototype.ignoreAnchorPointForPosition = cc.Node.prototype.setIgnoreAnchorPointForPosition;
cc.Node.prototype.nodeToParentTransform = function() {
logW("cc.Node.nodeToParentTransform", "cc.Node.getNodeToParentTransform");
return cc.Node.prototype.getNodeToParentTransform.apply(this, arguments);
};
cc.Node.prototype.worldToNodeTransform = function() {
logW("cc.Node.worldToNodeTransform", "cc.Node.getWorldToNodeTransform");
return cc.Node.prototype.getWorldToNodeTransform.apply(this, arguments);
};
cc.Node.prototype.parentToNodeTransform = function() {
logW("cc.Node.parentToNodeTransform", "cc.Node.getParentToNodeTransform");
return cc.Node.prototype.getParentToNodeTransform.apply(this, arguments);
};
cc.Node.prototype.numberOfRunningActions = function() {
logW("cc.Node.numberOfRunningActions", "cc.Node.getNumberOfRunningActions");
return cc.Node.prototype.getNumberOfRunningActions.apply(this, arguments);
};
cc.Node.prototype.numberOfRunningActionsInTarget = function() {
logW("cc.Node.numberOfRunningActionsInTarget", "cc.Node.getNumberOfRunningActionsInTarget");
return cc.Node.prototype.getNumberOfRunningActionsInTarget.apply(this, arguments);
};
cc.Menu.prototype.setHandlerPriority = function() {
cc.log("cc.Menu.setHandlerPriority was deprecated, 3.0 uses new event dispatcher to dispatch touch event based on draw order, so setHandlerPriority is not needed now.");
};
cc.Layer.prototype.setKeypadEnabled = function() {
logW("cc.Layer.setKeypadEnabled", "cc.Layer.setKeyboardEnabled");
return cc.Layer.prototype.setKeyboardEnabled.apply(this, arguments);
};
cc.Layer.prototype.isKeypadEnabled = function() {
logW("cc.Layer.isKeypadEnabled", "cc.Layer.isKeyboardEnabled");
return cc.Layer.prototype.isKeyboardEnabled.apply(this, arguments);
};
cc.registerTargettedDelegate = function() {
logW("cc.registerTargettedDelegate", "cc.registerTargetedDelegate");
return cc.registerTargetedDelegate.apply(this, arguments);
};
cc.Touch.prototype.getId = function(){
logW("cc.Touch.getId", "cc.Touch.getID");
return this.getID();
};
})();
@@ -1,53 +0,0 @@
/*
* Copyright (c) 2016 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 = dragonBones.CCArmatureDisplay.prototype;
_proto.animation = _proto.getAnimation;
var slotProto = dragonBones.Slot.prototype;
cc.defineGetterSetter(slotProto, 'childArmature', slotProto.getChildArmature, slotProto.setChildArmature);
var armatureProto = dragonBones.Armature.prototype;
cc.defineGetterSetter(armatureProto, 'animation', armatureProto.getAnimation, null);
cc.defineGetterSetter(armatureProto, 'display', armatureProto.getDisplay, null);
cc.defineGetterSetter(armatureProto, 'name', armatureProto.getName, null);
var animationStateProto = dragonBones.AnimationState.prototype;
cc.defineGetterSetter(animationStateProto, 'name', animationStateProto.getName);
var slotProto = dragonBones.Slot.prototype;
cc.defineGetterSetter(slotProto, 'display', slotProto.getDisplay);
dragonBones.EventObject.START = "start";
dragonBones.EventObject.LOOP_COMPLETE = "loopComplete";
dragonBones.EventObject.COMPLETE = "complete";
dragonBones.EventObject.FADE_IN = "fadeIn";
dragonBones.EventObject.FADE_IN_COMPLETE = "fadeInComplete";
dragonBones.EventObject.FADE_OUT = "fadeOut";
dragonBones.EventObject.FADE_OUT_COMPLETE = "fadeOutComplete";
dragonBones.EventObject.FRAME_EVENT = "frameEvent";
dragonBones.EventObject.SOUND_EVENT = "soundEvent";
dragonBones.DragonBones = {
ANGLE_TO_RADIAN : Math.PI / 180,
RADIAN_TO_ANGLE : 180 / Math.PI
};
@@ -1,186 +0,0 @@
/*
* Copyright (c) 2014-2016 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.
*/
//
// cocos2d loader plugins.
//
// This helper file should be required after jsb_cocos2d.js
//
cc._emptyLoader = {
load : function(realUrl, url, res, cb){
cb && cb(null, null);
return null;
}
};
cc.loader.register([
"mp3", "ogg", "wav", "mp4", "m4a",
"font", "eot", "ttf", "woff", "svg", "gaf"
],
cc._emptyLoader);
cc._txtLoader = {
load : function(realUrl, url, res, cb){
var result = jsb.fileUtils.getStringFromFile(realUrl);
cb && cb(null, result);
return result;
}
};
cc.loader.register(["txt", "xml", "vsh", "fsh", "tmx", "tsx"], cc._txtLoader);
cc._jsonLoader = {
load : function(realUrl, url, res, cb){
var data = jsb.fileUtils.getStringFromFile(realUrl), result;
try{
result = JSON.parse(data);
}catch(e){
cc.error(e);
result = null;
}
cb && cb(null, result);
return result;
}
};
cc.loader.register(["json", "ExportJson"], cc._jsonLoader);
cc._imgLoader = {
load : function(realUrl, url, res, cb){
cc.loader.loadImg(realUrl, function(err, img){
if(err) {
cb && cb(err);
return;
}
cc.loader.cache[url] = img;
cb && cb(null, img);
});
}
};
cc.loader.register(["png", "jpg", "bmp","jpeg","gif", "webp"], cc._imgLoader);
cc._plistLoader = {
load : function(realUrl, url, res, cb){
var content = jsb.fileUtils.getStringFromFile(realUrl);
var result = cc.plistParser.parse(content);
cb && cb(null, result);
return result;
}
};
cc.loader.register(["plist"], cc._plistLoader);
cc._binaryLoader = {
load : function(realUrl, url, res, cb){
var result = cc.loader.loadBinarySync(realUrl);
cb && cb(null, result);
return result;
}
};
cc.loader.register(["ccbi"], cc._binaryLoader);
cc._fntLoader = {
INFO_EXP : /info [^\n]*(\n|$)/gi,
COMMON_EXP : /common [^\n]*(\n|$)/gi,
PAGE_EXP : /page [^\n]*(\n|$)/gi,
CHAR_EXP : /char [^\n]*(\n|$)/gi,
KERNING_EXP : /kerning [^\n]*(\n|$)/gi,
ITEM_EXP : /\w+=[^ \r\n]+/gi,
INT_EXP : /^[\-]?\d+$/,
_parseStrToObj : function(str){
var arr = str.match(this.ITEM_EXP);
var obj = {};
if(arr){
for(var i = 0, li = arr.length; i < li; i++){
var tempStr = arr[i];
var index = tempStr.indexOf("=");
var key = tempStr.substring(0, index);
var value = tempStr.substring(index + 1);
if(value.match(this.INT_EXP)) value = parseInt(value);
else if(value[0] == '"') value = value.substring(1, value.length - 1);
obj[key] = value;
}
}
return obj;
},
parseFnt : function(fntStr, url){
var self = this, fnt = {};
//padding
var infoObj = self._parseStrToObj(fntStr.match(self.INFO_EXP)[0]);
var paddingArr = infoObj["padding"].split(",");
var padding = {
left : parseInt(paddingArr[0]),
top : parseInt(paddingArr[1]),
right : parseInt(paddingArr[2]),
bottom : parseInt(paddingArr[3])
};
//common
var commonObj = self._parseStrToObj(fntStr.match(self.COMMON_EXP)[0]);
fnt.commonHeight = commonObj["lineHeight"];
if (cc._renderType === cc._RENDER_TYPE_WEBGL) {
var texSize = cc.configuration.getMaxTextureSize();
if(commonObj["scaleW"] > texSize.width || commonObj["scaleH"] > texSize.height)
cc.log("cc.LabelBMFont._parseCommonArguments(): page can't be larger than supported");
}
if(commonObj["pages"] !== 1) cc.log("cc.LabelBMFont._parseCommonArguments(): only supports 1 page");
//page
var pageObj = self._parseStrToObj(fntStr.match(self.PAGE_EXP)[0]);
if(pageObj["id"] !== 0) cc.log("cc.LabelBMFont._parseImageFileName() : file could not be found");
fnt.atlasName = cc.path.changeBasename(url, pageObj["file"]);
//char
var charLines = fntStr.match(self.CHAR_EXP);
var fontDefDictionary = fnt.fontDefDictionary = {};
for(var i = 0, li = charLines.length; i < li; i++){
var charObj = self._parseStrToObj(charLines[i]);
var charId = charObj["id"];
fontDefDictionary[charId] = {
rect : {x : charObj["x"], y : charObj["y"], width : charObj["width"], height : charObj["height"]},
xOffset : charObj["xoffset"],
yOffset : charObj["yoffset"],
xAdvance : charObj["xadvance"]
};
}
//kerning
var kerningDict = fnt.kerningDict = {};
var kerningLines = fntStr.match(self.KERNING_EXP);
if(kerningLines){
for(var i = 0, li = kerningLines.length; i < li; i++){
var kerningObj = self._parseStrToObj(kerningLines[i]);
kerningDict[(kerningObj["first"] << 16) | (kerningObj["second"] & 0xffff)] = kerningObj["amount"];
}
}
return fnt;
},
load : function(realUrl, url, res, cb){
var data = jsb.fileUtils.getStringFromFile(realUrl), result = null;
if (data)
result = this.parseFnt(data, url);
cb && cb(null, result);
return result;
}
};
cc.loader.register(["fnt"], cc._fntLoader);
@@ -828,45 +828,3 @@ gl.WRITEONLY_RENDERING_QCOM = 0x8823;
gl.WRITE_ONLY_OES = 0x88b9;
gl.Z400_BINARY_AMD = 0x8740;
gl.ZERO = 0x0;
//------------Shader Name---------------
/**
* @constant
* @type {String}
*/
cc.SHADER_POSITION_TEXTURECOLOR = "ShaderPositionTextureColor";
/**
* @constant
* @type {String}
*/
cc.SHADER_POSITION_TEXTURECOLORALPHATEST = "ShaderPositionTextureColorAlphaTest";
/**
* @constant
* @type {String}
*/
cc.SHADER_POSITION_COLOR = "ShaderPositionColor";
/**
* @constant
* @type {String}
*/
cc.SHADER_POSITION_TEXTURE = "ShaderPositionTexture";
/**
* @constant
* @type {String}
*/
cc.SHADER_POSITION_TEXTURE_UCOLOR = "ShaderPositionTexture_uColor";
/**
* @constant
* @type {String}
*/
cc.SHADER_POSITION_TEXTUREA8COLOR = "ShaderPositionTextureA8Color";
/**
* @constant
* @type {String}
*/
cc.SHADER_POSITION_UCOLOR = "ShaderPosition_uColor";
/**
* @constant
* @type {String}
*/
cc.SHADER_POSITION_LENGTHTEXTURECOLOR = "ShaderPositionLengthTextureColor";
@@ -30,12 +30,6 @@ var cc = cc || {};
*/
var jsb = jsb || {};
/**
* The element contains the game canvas
* @type {HTMLDivElement}
*/
cc.container = null;
/**
* Iterate over an object or an array, executing a function for each matched element.
* @param {object|array} obj
@@ -77,69 +71,6 @@ cc.extend = function(target) {
return target;
};
/**
* Check the obj whether is function or not
* @param {*} obj
* @returns {boolean}
*/
cc.isFunction = function(obj) {
return typeof obj == 'function';
};
/**
* Check the obj whether is number or not
* @param {*} obj
* @returns {boolean}
*/
cc.isNumber = function(obj) {
return typeof obj == 'number' || Object.prototype.toString.call(obj) == '[object Number]';
};
/**
* Check the obj whether is string or not
* @param {*} obj
* @returns {boolean}
*/
cc.isString = function(obj) {
return typeof obj == 'string' || Object.prototype.toString.call(obj) == '[object String]';
};
/**
* Check the obj whether is array or not
* @param {*} obj
* @returns {boolean}
*/
cc.isArray = function(obj) {
return Array.isArray(obj) ||
(typeof obj === 'object' && Object.prototype.toString.call(obj) === '[object Array]');
};
/**
* Check the obj whether is undefined or not
* @param {*} obj
* @returns {boolean}
*/
cc.isUndefined = function(obj) {
return typeof obj === 'undefined';
};
/**
* Check the obj whether is object or not
* @param {*} obj
* @returns {boolean}
*/
cc.isObject = function(obj) {
return ( obj !== null && typeof obj === "object" );
};
/**
* Check the url whether cross origin
* @param {String} url
* @returns {boolean}
*/
cc.isCrossOrigin = function (url) {
return false;
};
/**
* Common getter setter configuration function
* @function
@@ -155,14 +86,6 @@ cc.defineGetterSetter = function (proto, prop, getter, setter){
Object.defineProperty(proto, prop, desc);
};
/**
* Associates a base class with a native superclass
* @function
* @param {object} jsobj subclass
* @param {object} klass superclass
*/
cc.associateWithNative = function( jsobj, superclass_or_instance ) {};
//
// JSB supports 2 official ways to create subclasses
//
@@ -38,11 +38,6 @@ var _proto = cc.Action.prototype;
cc.defineGetterSetter(_proto, "tag", _proto.getTag, _proto.setTag);
// Overrides
_proto = cc.AtlasNode.prototype;
cc.defineGetterSetter(_proto, "opacity", _proto.getOpacity, _proto.setOpacity);
cc.defineGetterSetter(_proto, "opacityModifyRGB", _proto.isOpacityModifyRGB, _proto.setOpacityModifyRGB);
cc.defineGetterSetter(_proto, "color", _proto.getColor, _proto.setColor);
_proto = cc.Label.prototype;
cc.defineGetterSetter(_proto, "size", _proto.getContentSize, _proto.setContentSize);
cc.defineGetterSetter(_proto, "width", _proto._getWidth, _proto._setWidth);
@@ -70,32 +65,6 @@ cc.defineGetterSetter(_proto, "height", _proto._getHeight, _proto._setHeight);
_proto = cc.Sprite.prototype;
cc.defineGetterSetter(_proto, "ignoreAnchor", _proto.isIgnoreAnchorPointForPosition, _proto.ignoreAnchorPointForPosition);
_proto = cc.LabelBMFont.prototype;
cc.defineGetterSetter(_proto, "anchorX", _proto._getAnchorX, _proto._setAnchorX);
cc.defineGetterSetter(_proto, "anchorY", _proto._getAnchorY, _proto._setAnchorY);
cc.defineGetterSetter(_proto, "scale", _proto.getScale, _proto.setScale);
cc.defineGetterSetter(_proto, "scaleX", _proto.getScaleX, _proto.setScaleX);
cc.defineGetterSetter(_proto, "scaleY", _proto.getScaleY, _proto.setScaleY);
cc.defineGetterSetter(_proto, "opacityModifyRGB", _proto.isOpacityModifyRGB, _proto.setOpacityModifyRGB);
cc.defineGetterSetter(_proto, "opacity", _proto.getOpacity, _proto.setOpacity);
cc.defineGetterSetter(_proto, "cascadeOpacity", _proto.isCascadeOpacityEnabled, _proto.setCascadeOpacityEnabled);
cc.defineGetterSetter(_proto, "color", _proto.getColor, _proto.setColor);
cc.defineGetterSetter(_proto, "cascadeColor", _proto.isCascadeColorEnabled, _proto.setCascadeColorEnabled);
_proto = cc.Menu.prototype;
cc.defineGetterSetter(_proto, "opacityModifyRGB", _proto.isOpacityModifyRGB, _proto.setOpacityModifyRGB);
cc.defineGetterSetter(_proto, "opacity", _proto.getOpacity, _proto.setOpacity);
cc.defineGetterSetter(_proto, "cascadeOpacity", _proto.isCascadeOpacityEnabled, _proto.setCascadeOpacityEnabled);
cc.defineGetterSetter(_proto, "color", _proto.getColor, _proto.setColor);
cc.defineGetterSetter(_proto, "cascadeColor", _proto.isCascadeColorEnabled, _proto.setCascadeColorEnabled);
_proto = cc.MenuItem.prototype;
cc.defineGetterSetter(_proto, "opacityModifyRGB", _proto.isOpacityModifyRGB, _proto.setOpacityModifyRGB);
cc.defineGetterSetter(_proto, "opacity", _proto.getOpacity, _proto.setOpacity);
cc.defineGetterSetter(_proto, "cascadeOpacity", _proto.isCascadeOpacityEnabled, _proto.setCascadeOpacityEnabled);
cc.defineGetterSetter(_proto, "color", _proto.getColor, _proto.setColor);
cc.defineGetterSetter(_proto, "cascadeColor", _proto.isCascadeColorEnabled, _proto.setCascadeColorEnabled);
_proto = cc.MotionStreak.prototype;
cc.defineGetterSetter(_proto, "x", _proto.getPositionX, _proto.setPositionX);
cc.defineGetterSetter(_proto, "y", _proto.getPositionY, _proto.setPositionY);
@@ -111,25 +80,12 @@ cc.defineGetterSetter(_proto, "scale", _proto.getScale, _proto.setScale);
cc.defineGetterSetter(_proto, "scaleX", _proto.getScaleX, _proto.setScaleX);
cc.defineGetterSetter(_proto, "scaleY", _proto.getScaleY, _proto.setScaleY);
_proto = cc.ProgressTimer.prototype;
cc.defineGetterSetter(_proto, "opacity", _proto.getOpacity, _proto.setOpacity);
cc.defineGetterSetter(_proto, "opacityModifyRGB", _proto.isOpacityModifyRGB, _proto.setOpacityModifyRGB);
cc.defineGetterSetter(_proto, "color", _proto.getColor, _proto.setColor);
_proto = cc.TextFieldTTF.prototype;
cc.defineGetterSetter(_proto, "string", _proto.getString, _proto.setString);
// Extends
var _proto = cc.ClippingNode.prototype;
cc.defineGetterSetter(_proto, "alphaThreshold", _proto.getAlphaThreshold, _proto.setAlphaThreshold);
cc.defineGetterSetter(_proto, "inverted", _proto.getInverted, _proto.setInverted);
cc.defineGetterSetter(_proto, "stencil", _proto.getStencil, _proto.setStencil);
_proto = cc.AtlasNode.prototype;
cc.defineGetterSetter(_proto, "texture", _proto.getTexture, _proto.setTexture);
cc.defineGetterSetter(_proto, "textureAtlas", _proto.getTextureAtlas, _proto.setTextureAtlas);
cc.defineGetterSetter(_proto, "quadsToDraw", _proto.getQuadsToDraw, _proto.setQuadsToDraw);
_proto = cc.Node.prototype;
cc.defineGetterSetter(_proto, "x", _proto.getPositionX, _proto.setPositionX);
cc.defineGetterSetter(_proto, "y", _proto.getPositionY, _proto.setPositionY);
@@ -228,11 +184,6 @@ cc.defineGetterSetter(_proto, "cascadeOpacity", _proto.isCascadeOpacityEnabled,
cc.defineGetterSetter(_proto, "color", _proto.getColor, _proto.setColor);
cc.defineGetterSetter(_proto, "cascadeColor", _proto.isCascadeColorEnabled, _proto.setCascadeColorEnabled);
_proto = cc.SpriteBatchNode.prototype;
cc.defineGetterSetter(_proto, "textureAtlas", _proto.getTextureAtlas, _proto.setTextureAtlas);
cc.defineGetterSetter(_proto, "descendants", _proto.getDescendants);
cc.defineGetterSetter(_proto, "texture", _proto.getTexture, _proto.setTexture);
_proto = cc.Texture2D.prototype;
cc.defineGetterSetter(_proto, "name", _proto.getName);
cc.defineGetterSetter(_proto, "pixelFormat", _proto.getPixelFormat);
@@ -245,32 +196,6 @@ cc.defineGetterSetter(_proto, "maxS", _proto.getMaxS, _proto.setMaxS);
cc.defineGetterSetter(_proto, "maxT", _proto.getMaxT, _proto.setMaxT);
cc.defineGetterSetter(cc.Texture2D, "defaultPixelFormat", cc.Texture2D.getDefaultAlphaPixelFormat, cc.Texture2D.setDefaultAlphaPixelFormat);
_proto = cc.LabelBMFont.prototype;
cc.defineGetterSetter(_proto, "string", _proto.getString, _proto.setString);
cc.defineGetterSetter(_proto, "textAlign", _proto._getAlignment, _proto.setAlignment);
cc.defineGetterSetter(_proto, "boundingWidth", _proto._getBoundingWidth, _proto.setBoundingWidth);
cc.defineGetterSetter(_proto, "boundingHeight", _proto._getBoundingHeight, _proto.setBoundingHeight);
_proto = cc.Menu.prototype;
cc.defineGetterSetter(_proto, "enabled", _proto.getEnabled, _proto.setEnabled);
_proto = cc.MenuItem.prototype;
cc.defineGetterSetter(_proto, "enabled", _proto.isEnabled, _proto.setEnabled);
_proto = cc.MenuItemLabel.prototype;
cc.defineGetterSetter(_proto, "string", _proto.getString, _proto.setString);
cc.defineGetterSetter(_proto, "label", _proto.getLabel, _proto.setLabel);
cc.defineGetterSetter(_proto, "disabledColor", _proto.getDisabledColor, _proto.setDisabledColor);
_proto = cc.MenuItemFont.prototype;
cc.defineGetterSetter(_proto, "fontSize", _proto.fontSize, _proto.setFontSize);
cc.defineGetterSetter(_proto, "fontName", _proto.fontName, _proto.setFontName);
_proto = cc.MenuItemSprite.prototype;
cc.defineGetterSetter(_proto, "normalImage", _proto.getNormalImage, _proto.setNormalImage);
cc.defineGetterSetter(_proto, "selectedImage", _proto.getSelectedImage, _proto.setSelectedImage);
cc.defineGetterSetter(_proto, "disabledImage", _proto.getDisabledImage, _proto.setDisabledImage);
_proto = cc.ParticleBatchNode.prototype;
cc.defineGetterSetter(_proto, "textureAtlas", _proto.getTextureAtlas, _proto.setTextureAtlas);
cc.defineGetterSetter(_proto, "texture", _proto.getTexture, _proto.setTexture);
@@ -322,14 +247,6 @@ cc.defineGetterSetter(_proto, "totalParticles", _proto.getTotalParticles, _proto
cc.defineGetterSetter(_proto, "autoRemoveOnFinish", _proto.getAutoRemoveOnFinish, _proto.setAutoRemoveOnFinish);
cc.defineGetterSetter(_proto, "texture", _proto.getTexture, _proto.setTexture);
_proto = cc.ProgressTimer.prototype;
cc.defineGetterSetter(_proto, "midPoint", _proto.getMidpoint, _proto.setMidpoint);
cc.defineGetterSetter(_proto, "barChangeRate", _proto.getBarChangeRate, _proto.setBarChangeRate);
cc.defineGetterSetter(_proto, "type", _proto.getType, _proto.setType);
cc.defineGetterSetter(_proto, "percentage", _proto.getPercentage, _proto.setPercentage);
cc.defineGetterSetter(_proto, "sprite", _proto.getSprite, _proto.setSprite);
cc.defineGetterSetter(_proto, "reverseDir", _proto.isReverseDirection, _proto.setReverseDirection);
_proto = cc.RenderTexture.prototype;
cc.defineGetterSetter(_proto, "sprite", _proto.getSprite, _proto.setSprite);
cc.defineGetterSetter(_proto, "clearFlags", _proto.getClearFlags, _proto.setClearFlags);
@@ -338,10 +255,6 @@ cc.defineGetterSetter(_proto, "clearStencilVal", _proto.getClearStencilVal, _pro
cc.defineGetterSetter(_proto, "clearColorVal", _proto.getClearColor, _proto.setClearColor);
cc.defineGetterSetter(_proto, "autoDraw", _proto.getAutoDraw, _proto.setAutoDraw);
_proto = cc.NodeGrid.prototype;
cc.defineGetterSetter(_proto, "grid", _proto.getGrid, _proto.setGrid);
cc.defineGetterSetter(_proto, "target", null, _proto.setTarget);
_proto = cc.TMXLayer.prototype;
cc.defineGetterSetter(_proto, "tiles", _proto.getTiles, _proto.setTiles);
cc.defineGetterSetter(_proto, "tileset", _proto.getTileset, _proto.setTileset);
@@ -20,6 +20,8 @@
* THE SOFTWARE.
*/
'use strict';
function _safeExtend(obj, list) {
for (var key in list)
if(!obj[key])
@@ -35,7 +37,7 @@ function _customUndefined(message) {
cc.log("Not implemented yet in JSB");
message && cc.log(message);
return undefined;
}
};
}
var _undefined = {
@@ -45,7 +47,7 @@ var _undefined = {
},
_shadowUndefined: _customUndefined("Please use enableShadow function"),
_strokeUndefined: _customUndefined("Please use enableStroke function")
}
};
_safeExtend(cc.Node.prototype, {
_getWidth: function() {
@@ -134,14 +136,6 @@ _safeExtend(cc.Sprite.prototype, {
}
});
_safeExtend(cc.LabelBMFont.prototype, {
_getAlignment: _undefined._jsbUndefined,
_getBoundingWidth: _undefined._jsbUndefined,
setBoundingWidth: function (width) {
this.setWidth(width);
}
});
_safeExtend(cc.TMXLayer.prototype, {
_getLayerWidth: function() {
return this.getLayerSize().width;
@@ -210,8 +204,6 @@ _safeExtend(cc.TMXTiledMap.prototype, {
}
});
_safeExtend(cc.Texture2D.prototype, {
_getWidth : function(){
return this.getContentSize().width;
@@ -1,154 +0,0 @@
/*
* Copyright (c) 2013-2016 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.
*/
// move from extension
// start
//PhysicsDebugNode
cc.PhysicsDebugNode.create = function( space ) {
var s = space;
if( space.handle !== undefined )
s = space.handle;
return cc.PhysicsDebugNode._create( s );
};
cc.PhysicsDebugNode.prototype._ctor = function(space){
this.init();
var s = space;
if( space.handle !== undefined )
s = space.handle;
this.setSpace(s);
};
cc.PhysicsDebugNode.prototype.setSpace = function( space ) {
var s = space;
if( space.handle !== undefined )
s = space.handle;
return this._setSpace( s );
};
// physicsSprite
cc.PhysicsSprite.prototype.setBody = function( body ) {
var b = body;
if( body.handle !== undefined )
b = body.handle;
return this._setCPBody( b );
};
cc.PhysicsSprite.prototype.getBody = function() {
return this.getCPBody();
};
// end
// move from property_impls
// start
_safeExtend(cc.PhysicsSprite.prototype, {
setPositionX: function(x) {
this.setPosition( cc.p(x, this.getPositionY()) );
},
setPositionY: function(y) {
this.setPosition( cc.p(this.getPositionX(), y) );
}
});
// end
// move from property_apis
// start
var _proto = cc.PhysicsSprite.prototype;
cc.defineGetterSetter(_proto, "body", _proto.getBody, _proto.setBody);
cc.defineGetterSetter(_proto, "x", _proto.getPositionX, _proto.setPositionX);
cc.defineGetterSetter(_proto, "y", _proto.getPositionY, _proto.setPositionY);
cc.defineGetterSetter(_proto, "rotation", _proto.getRotation, _proto.setRotation);
cc.defineGetterSetter(_proto, "dirty", _proto.isDirty, _proto.setDirty);
// end
// move from create_apis
// start
/************************ PhysicsSprite *************************/
var _p = cc.PhysicsSprite.prototype;
_p._ctor = function(fileName, rect){
if (fileName === undefined) {
cc.PhysicsSprite.prototype.init.call(this);
}else if (typeof(fileName) === "string") {
if (fileName[0] === "#") {
//init with a sprite frame name
var frameName = fileName.substr(1, fileName.length - 1);
var spriteFrame = cc.spriteFrameCache.getSpriteFrame(frameName);
this.initWithSpriteFrame(spriteFrame);
} else {
//init with filename and rect
if(rect)
this.initWithFile(fileName, rect);
else
this.initWithFile(fileName);
}
}else if (typeof(fileName) === "object") {
if (fileName instanceof cc.Texture2D) {
//init with texture and rect
this.initWithTexture(fileName, rect);
} else if (fileName instanceof cc.SpriteFrame) {
//init with a sprite frame
this.initWithSpriteFrame(fileName);
}
}
};
cc.PhysicsSprite._create = cc.PhysicsSprite.create;
cc.PhysicsSprite.create = function (fileName, rect) {
var sprite;
if (arguments.length == 0) {
sprite = cc.PhysicsSprite._create();
return sprite;
}
if (typeof(fileName) === "string") {
if (fileName[0] === "#") {
//init with a sprite frame name
var frameName = fileName.substr(1, fileName.length - 1);
var spriteFrame = cc.spriteFrameCache.getSpriteFrame(frameName);
sprite = cc.PhysicsSprite.createWithSpriteFrame(spriteFrame);
} else {
// Create with filename and rect
sprite = rect ? cc.PhysicsSprite._create(fileName, rect) : cc.PhysicsSprite._create(fileName);
}
if (sprite)
return sprite;
else return null;
}
if (typeof(fileName) === "object") {
if (fileName instanceof cc.Texture2D) {
//init with texture and rect
sprite = rect ? cc.PhysicsSprite.createWithTexture(fileName, rect) : cc.PhysicsSprite.createWithTexture(fileName);
} else if (fileName instanceof cc.SpriteFrame) {
//init with a sprite frame
sprite = cc.PhysicsSprite.createWithSpriteFrame(fileName)
}
if (sprite)
return sprite;
else return null;
}
return null;
};
// end
File diff suppressed because it is too large Load Diff
@@ -1,275 +0,0 @@
cc.md5Encode = function(data){
// for test/debug
function fflog(msg) {
try {
console.log(msg);
} catch(e) {}
}
// convert number to (unsigned) 32 bit hex, zero filled string
function to_zerofilled_hex(n) {
var t1 = (n >>> 24).toString(16);
var t2 = (n & 0x00FFFFFF).toString(16);
return "00".substr(0, 2 - t1.length) + t1 +
"000000".substr(0, 6 - t2.length) + t2;
}
// convert array of chars to array of bytes (note: Unicode not supported)
function chars_to_bytes(ac) {
var retval = [];
for (var i = 0; i < ac.length; i++) {
retval = retval.concat(str_to_bytes(ac[i]));
}
return retval;
}
// convert a 64 bit unsigned number to array of bytes. Little endian
function int64_to_bytes(num) {
var retval = [];
for (var i = 0; i < 8; i++) {
retval.push(num & 0xFF);
num = num >>> 8;
}
return retval;
}
// 32 bit left-rotation
function rol(num, places) {
return ((num << places) & 0xFFFFFFFF) | (num >>> (32 - places));
}
// The 4 MD5 functions
function fF(b, c, d) {
return (b & c) | (~b & d);
}
function fG(b, c, d) {
return (d & b) | (~d & c);
}
function fH(b, c, d) {
return b ^ c ^ d;
}
function fI(b, c, d) {
return c ^ (b | ~d);
}
// pick 4 bytes at specified offset. Little-endian is assumed
function bytes_to_int32(arr, off) {
return (arr[off + 3] << 24) | (arr[off + 2] << 16) | (arr[off + 1] << 8) | (arr[off]);
}
/*
Conver string to array of bytes in UTF-8 encoding
See:
http://www.dangrossman.info/2007/05/25/handling-utf-8-in-javascript-php-and-non-utf8-databases/
http://stackoverflow.com/questions/1240408/reading-bytes-from-a-javascript-string
How about a String.getBytes(<ENCODING>) for Javascript!? Isn't it time to add it?
*/
function str_to_bytes(str) {
// alert("got " + str.length + " chars")
var retval = [ ];
for (var i = 0; i < str.length; i++)
if (str.charCodeAt(i) <= 0x7F) {
retval.push(str.charCodeAt(i));
} else {
var tmp = encodeURIComponent(str.charAt(i)).substr(1).split('%');
for (var j = 0; j < tmp.length; j++) {
retval.push(parseInt(tmp[j], 0x10));
}
}
return retval;
};
// convert the 4 32-bit buffers to a 128 bit hex string. (Little-endian is assumed)
function int128le_to_hex(a, b, c, d) {
var ra = "";
var t = 0;
var ta = 0;
for (var i = 3; i >= 0; i--) {
ta = arguments[i];
t = (ta & 0xFF);
ta = ta >>> 8;
t = t << 8;
t = t | (ta & 0xFF);
ta = ta >>> 8;
t = t << 8;
t = t | (ta & 0xFF);
ta = ta >>> 8;
t = t << 8;
t = t | ta;
ra = ra + to_zerofilled_hex(t);
}
return ra;
}
// check input data type and perform conversions if needed
var databytes = null;
// String
if (typeof data == 'string') {
// convert string to array bytes
databytes = str_to_bytes(data);
} else if (data.constructor == Array) {
if (data.length === 0) {
// if it's empty, just assume array of bytes
databytes = data;
} else if (typeof data[0] == 'string') {
databytes = chars_to_bytes(data);
} else if (typeof data[0] == 'number') {
databytes = data;
} else {
fflog("input data type mismatch");
return null;
}
} else {
fflog("input data type mismatch");
return null;
}
// save original length
var org_len = databytes.length;
// first append the "1" + 7x "0"
databytes.push(0x80);
// determine required amount of padding
var tail = databytes.length % 64;
// no room for msg length?
if (tail > 56) {
// pad to next 512 bit block
for (var i = 0; i < (64 - tail); i++) {
databytes.push(0x0);
}
tail = databytes.length % 64;
}
for (i = 0; i < (56 - tail); i++) {
databytes.push(0x0);
}
// message length in bits mod 512 should now be 448
// append 64 bit, little-endian original msg length (in *bits*!)
databytes = databytes.concat(int64_to_bytes(org_len * 8));
// initialize 4x32 bit state
var h0 = 0x67452301;
var h1 = 0xEFCDAB89;
var h2 = 0x98BADCFE;
var h3 = 0x10325476;
// temp buffers
var a = 0,
b = 0,
c = 0,
d = 0;
function _add(n1, n2) {
return 0x0FFFFFFFF & (n1 + n2)
}
// function update partial state for each run
var updateRun = function(nf, sin32, dw32, b32) {
var temp = d;
d = c;
c = b;
//b = b + rol(a + (nf + (sin32 + dw32)), b32);
b = _add(b,
rol(
_add(a,
_add(nf, _add(sin32, dw32))
), b32
)
);
a = temp;
};
// Digest message
for (i = 0; i < databytes.length / 64; i++) {
// initialize run
a = h0;
b = h1;
c = h2;
d = h3;
var ptr = i * 64;
// do 64 runs
updateRun(fF(b, c, d), 0xd76aa478, bytes_to_int32(databytes, ptr), 7);
updateRun(fF(b, c, d), 0xe8c7b756, bytes_to_int32(databytes, ptr + 4), 12);
updateRun(fF(b, c, d), 0x242070db, bytes_to_int32(databytes, ptr + 8), 17);
updateRun(fF(b, c, d), 0xc1bdceee, bytes_to_int32(databytes, ptr + 12), 22);
updateRun(fF(b, c, d), 0xf57c0faf, bytes_to_int32(databytes, ptr + 16), 7);
updateRun(fF(b, c, d), 0x4787c62a, bytes_to_int32(databytes, ptr + 20), 12);
updateRun(fF(b, c, d), 0xa8304613, bytes_to_int32(databytes, ptr + 24), 17);
updateRun(fF(b, c, d), 0xfd469501, bytes_to_int32(databytes, ptr + 28), 22);
updateRun(fF(b, c, d), 0x698098d8, bytes_to_int32(databytes, ptr + 32), 7);
updateRun(fF(b, c, d), 0x8b44f7af, bytes_to_int32(databytes, ptr + 36), 12);
updateRun(fF(b, c, d), 0xffff5bb1, bytes_to_int32(databytes, ptr + 40), 17);
updateRun(fF(b, c, d), 0x895cd7be, bytes_to_int32(databytes, ptr + 44), 22);
updateRun(fF(b, c, d), 0x6b901122, bytes_to_int32(databytes, ptr + 48), 7);
updateRun(fF(b, c, d), 0xfd987193, bytes_to_int32(databytes, ptr + 52), 12);
updateRun(fF(b, c, d), 0xa679438e, bytes_to_int32(databytes, ptr + 56), 17);
updateRun(fF(b, c, d), 0x49b40821, bytes_to_int32(databytes, ptr + 60), 22);
updateRun(fG(b, c, d), 0xf61e2562, bytes_to_int32(databytes, ptr + 4), 5);
updateRun(fG(b, c, d), 0xc040b340, bytes_to_int32(databytes, ptr + 24), 9);
updateRun(fG(b, c, d), 0x265e5a51, bytes_to_int32(databytes, ptr + 44), 14);
updateRun(fG(b, c, d), 0xe9b6c7aa, bytes_to_int32(databytes, ptr), 20);
updateRun(fG(b, c, d), 0xd62f105d, bytes_to_int32(databytes, ptr + 20), 5);
updateRun(fG(b, c, d), 0x2441453, bytes_to_int32(databytes, ptr + 40), 9);
updateRun(fG(b, c, d), 0xd8a1e681, bytes_to_int32(databytes, ptr + 60), 14);
updateRun(fG(b, c, d), 0xe7d3fbc8, bytes_to_int32(databytes, ptr + 16), 20);
updateRun(fG(b, c, d), 0x21e1cde6, bytes_to_int32(databytes, ptr + 36), 5);
updateRun(fG(b, c, d), 0xc33707d6, bytes_to_int32(databytes, ptr + 56), 9);
updateRun(fG(b, c, d), 0xf4d50d87, bytes_to_int32(databytes, ptr + 12), 14);
updateRun(fG(b, c, d), 0x455a14ed, bytes_to_int32(databytes, ptr + 32), 20);
updateRun(fG(b, c, d), 0xa9e3e905, bytes_to_int32(databytes, ptr + 52), 5);
updateRun(fG(b, c, d), 0xfcefa3f8, bytes_to_int32(databytes, ptr + 8), 9);
updateRun(fG(b, c, d), 0x676f02d9, bytes_to_int32(databytes, ptr + 28), 14);
updateRun(fG(b, c, d), 0x8d2a4c8a, bytes_to_int32(databytes, ptr + 48), 20);
updateRun(fH(b, c, d), 0xfffa3942, bytes_to_int32(databytes, ptr + 20), 4);
updateRun(fH(b, c, d), 0x8771f681, bytes_to_int32(databytes, ptr + 32), 11);
updateRun(fH(b, c, d), 0x6d9d6122, bytes_to_int32(databytes, ptr + 44), 16);
updateRun(fH(b, c, d), 0xfde5380c, bytes_to_int32(databytes, ptr + 56), 23);
updateRun(fH(b, c, d), 0xa4beea44, bytes_to_int32(databytes, ptr + 4), 4);
updateRun(fH(b, c, d), 0x4bdecfa9, bytes_to_int32(databytes, ptr + 16), 11);
updateRun(fH(b, c, d), 0xf6bb4b60, bytes_to_int32(databytes, ptr + 28), 16);
updateRun(fH(b, c, d), 0xbebfbc70, bytes_to_int32(databytes, ptr + 40), 23);
updateRun(fH(b, c, d), 0x289b7ec6, bytes_to_int32(databytes, ptr + 52), 4);
updateRun(fH(b, c, d), 0xeaa127fa, bytes_to_int32(databytes, ptr), 11);
updateRun(fH(b, c, d), 0xd4ef3085, bytes_to_int32(databytes, ptr + 12), 16);
updateRun(fH(b, c, d), 0x4881d05, bytes_to_int32(databytes, ptr + 24), 23);
updateRun(fH(b, c, d), 0xd9d4d039, bytes_to_int32(databytes, ptr + 36), 4);
updateRun(fH(b, c, d), 0xe6db99e5, bytes_to_int32(databytes, ptr + 48), 11);
updateRun(fH(b, c, d), 0x1fa27cf8, bytes_to_int32(databytes, ptr + 60), 16);
updateRun(fH(b, c, d), 0xc4ac5665, bytes_to_int32(databytes, ptr + 8), 23);
updateRun(fI(b, c, d), 0xf4292244, bytes_to_int32(databytes, ptr), 6);
updateRun(fI(b, c, d), 0x432aff97, bytes_to_int32(databytes, ptr + 28), 10);
updateRun(fI(b, c, d), 0xab9423a7, bytes_to_int32(databytes, ptr + 56), 15);
updateRun(fI(b, c, d), 0xfc93a039, bytes_to_int32(databytes, ptr + 20), 21);
updateRun(fI(b, c, d), 0x655b59c3, bytes_to_int32(databytes, ptr + 48), 6);
updateRun(fI(b, c, d), 0x8f0ccc92, bytes_to_int32(databytes, ptr + 12), 10);
updateRun(fI(b, c, d), 0xffeff47d, bytes_to_int32(databytes, ptr + 40), 15);
updateRun(fI(b, c, d), 0x85845dd1, bytes_to_int32(databytes, ptr + 4), 21);
updateRun(fI(b, c, d), 0x6fa87e4f, bytes_to_int32(databytes, ptr + 32), 6);
updateRun(fI(b, c, d), 0xfe2ce6e0, bytes_to_int32(databytes, ptr + 60), 10);
updateRun(fI(b, c, d), 0xa3014314, bytes_to_int32(databytes, ptr + 24), 15);
updateRun(fI(b, c, d), 0x4e0811a1, bytes_to_int32(databytes, ptr + 52), 21);
updateRun(fI(b, c, d), 0xf7537e82, bytes_to_int32(databytes, ptr + 16), 6);
updateRun(fI(b, c, d), 0xbd3af235, bytes_to_int32(databytes, ptr + 44), 10);
updateRun(fI(b, c, d), 0x2ad7d2bb, bytes_to_int32(databytes, ptr + 8), 15);
updateRun(fI(b, c, d), 0xeb86d391, bytes_to_int32(databytes, ptr + 36), 21);
// update buffers
h0 = _add(h0, a);
h1 = _add(h1, b);
h2 = _add(h2, c);
h3 = _add(h3, d);
}
// Done! Convert buffers to 128 bit (LE)
return int128le_to_hex(h3, h2, h1, h0).toUpperCase();
};
@@ -1,564 +0,0 @@
/*
* Copyright (c) 2013-2016 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.
*/
//
// cocos2d studio constants
//
// This helper file should be required after jsb_cocos2d.js
//
var ccs = ccs || {};
ccs.Class = ccs.Class || cc.Class || {};
// Movement event type
ccs.MovementEventType = {
start: 0,
complete: 1,
loopComplete: 2
};
// Inner action type
ccs.InnerActionType = {
LoopAction: 0,
NoLoopAction: 1,
SingleFrame: 2
};
ccs.AnimationInfo = function (name, startIndex, endIndex) {
this.name = name || "";
this.startIndex = startIndex != undefined ? startIndex : 0;
this.endIndex = endIndex != undefined ? endIndex : 0;
};
// Armature
if(ccs.Armature){
ccs.Armature.prototype.setBody = function( body ) {
var b = body;
if( body.handle !== undefined )
b = body.handle;
return this._setCPBody( b );
};
ccs.ComController.extend = cc.Class.extend;
ccs.Armature.extend = cc.Class.extend;
}
ccs.Armature.prototype._setBlendFunc = ccs.Armature.prototype.setBlendFunc;
ccs.Armature.prototype.setBlendFunc = templateSetBlendFunc;
ccs.sendEvent = function (event) {
var triggerObjArr = ccs.triggerManager.get(event);
if (triggerObjArr == null) {
return;
}
for (var i = 0; i < triggerObjArr.length; i++) {
var triObj = triggerObjArr[i];
if (triObj != null && triObj.detect()) {
triObj.done();
}
}
};
ccs.objectFactory = {
_typeMap: {},
destroyInstance: function () {
this._sharedFactory = null;
},
createObject: function (className) {
var o = null;
var t = this._typeMap[className];
if (t) {
o = new t._fun();
}
return o;
},
registerType: function (t) {
this._typeMap[t._className] = t;
}
};
ccs.TInfo = ccs.Class.extend({
_className: "",
_fun: null,
/**
*
* @param {String|ccs.TInfo}c
* @param {Function}f
*/
ctor: function (c, f) {
if (f) {
this._className = c;
this._fun = f;
}else{
this._className = c._className;
this._fun = c._fun;
}
ccs.objectFactory.registerType(this);
}
});
ccs.registerTriggerClass = function(className, createFunc) {
new ccs.TInfo(className, createFunc);
}
ccs.BaseTriggerCondition = ccs.Class.extend({
init: function () {
return true;
},
detect: function () {
return true;
},
serialize: function (jsonVal) {
},
removeAll: function () {
}
});
ccs.BaseTriggerAction = ccs.Class.extend({
init: function () {
return true;
},
done: function () {
},
serialize: function (jsonVal) {
},
removeAll: function () {
}
});
ccs.TriggerObj = ccs.Class.extend({
_cons: null,
_acts: null,
_id: 0,
_enable: true,
_vInt: null,
ctor: function () {
this._id = 0;
this._enable = true;
},
init: function () {
this._cons = [];
this._acts = [];
this._vInt = [];
return true;
},
detect: function () {
if (!this._enable || this._cons.length == 0) {
return true;
}
var ret = true;
var obj = null;
for (var i = 0; i < this._cons.length; i++) {
obj = this._cons[i];
if (obj && obj.detect) {
ret = ret && obj.detect();
}
}
return ret;
},
done: function () {
if (!this._enable || this._acts.length == 0) {
return;
}
var obj;
for (var i = 0; i < this._acts.length; i++) {
obj = this._acts[i];
if (obj && obj.done) {
obj.done();
}
}
},
removeAll: function () {
var obj = null;
for (var i = 0; i < this._cons.length; i++) {
obj = this._cons[i];
if (obj)
obj.removeAll();
}
this._cons = [];
for (var i = 0; i < this._acts.length; i++) {
obj = this._acts[i];
if (obj)
obj.removeAll();
}
this._acts = [];
},
serialize: function (jsonVal) {
this._id = jsonVal["id"] || 0;
var conditions = jsonVal["conditions"] || [];
for (var i = 0; i < conditions.length; i++) {
var subDict = conditions[i];
var classname = subDict["classname"];
if (!classname) {
continue;
}
var con = ccs.objectFactory.createObject(classname);
if (!con) {
cc.log("class named classname(" + classname + ") can not implement!");
}
con.serialize(subDict);
con.init();
this._cons.push(con);
}
var actions = jsonVal["actions"] || [];
for (var i = 0; i < actions.length; i++) {
var subDict = actions[i];
var classname = subDict["classname"];
if (!classname) {
continue;
}
var act = ccs.objectFactory.createObject(classname);
if (!act) {
cc.log("class named classname(" + classname + ") can not implement!");
}
act.serialize(subDict);
act.init();
this._acts.push(act);
}
var events = jsonVal["events"] || [];
for (var i = 0; i < events.length; i++) {
var subDict = events[i];
var event = subDict["id"];
if (event < 0) {
continue;
}
this._vInt.push(event);
}
},
getId: function () {
return this._id;
},
setEnable: function (enable) {
this._enable = enable;
},
getEvents: function () {
return this._vInt;
}
});
ccs.TriggerObj.create = function() {
var ret = new ccs.TriggerObj();
if (ret.init())
return ret;
return null;
}
ccs.triggerManager = {
_eventTriggers: {},
_triggerObjs: {},
_movementDispatches: [],
destroyInstance: function () {
this.removeAll();
this._instance = null;
},
parse: function (root) {
var triggers = root;//["Triggers"];
for (var i = 0; i < triggers.length; ++i) {
var subDict = triggers[i];
var triggerObj = ccs.TriggerObj.create();
triggerObj.serialize(subDict);
var events = triggerObj.getEvents();
for (var j = 0; j < events.length; j++) {
var event = events[j];
this.add(event, triggerObj);
}
this._triggerObjs[triggerObj.getId()] = triggerObj;
}
},
get: function (event) {
return this._eventTriggers[event];
},
getTriggerObj: function (id) {
return this._triggerObjs[id];
},
add: function (event, triggerObj) {
var eventTriggers = this._eventTriggers[event];
if (!eventTriggers) {
eventTriggers = [];
}
if (eventTriggers.indexOf(triggerObj) == -1) {
eventTriggers.push(triggerObj);
this._eventTriggers[event] = eventTriggers;
}
},
removeAll: function () {
for (var key in this._eventTriggers) {
var triObjArr = this._eventTriggers[key];
for (var j = 0; j < triObjArr.length; j++) {
var obj = triObjArr[j];
obj.removeAll();
}
}
this._eventTriggers = {};
},
remove: function (event, Obj) {
if (Obj) {
return this._removeObj(event, Obj);
}
var bRet = false;
do
{
var triObjects = this._eventTriggers[event];
if (!triObjects) break;
for (var i = 0; i < triObjects.length; i++) {
var triObject = triObjects[i];
if (triObject) {
triObject.removeAll();
}
}
delete this._eventTriggers[event];
bRet = true;
} while (0);
return bRet;
},
_removeObj: function (event, Obj) {
var bRet = false;
do
{
var triObjects = this._eventTriggers[event];
if (!triObjects) break;
for (var i = 0; i < triObjects.length; i++) {
var triObject = triObjects[i];
if (triObject && triObject == Obj) {
triObject.removeAll();
triObjects.splice(i, 1);
break;
}
}
bRet = true;
} while (0);
return bRet;
},
removeTriggerObj: function (id) {
var obj = this.getTriggerObj(id);
if (!obj) {
return false;
}
var events = obj.getEvents();
for (var i = 0; i < events.length; i++) {
var event = events[i];
this.remove(event, obj);
}
return true;
},
isEmpty: function () {
return !this._eventTriggers || this._eventTriggers.length <= 0;
},
addArmatureMovementCallBack: function (armature, callFunc, target) {
if (armature == null || target == null || callFunc == null) {
return;
}
var locAmd, hasADD = false;
for (var i = 0; i < this._movementDispatches.length; i++) {
locAmd = this._movementDispatches[i];
if (locAmd && locAmd[0] == armature) {
locAmd.addAnimationEventCallBack(callFunc, target);
hasADD = true;
}
}
if (!hasADD) {
var newAmd = new ccs.ArmatureMovementDispatcher();
armature.getAnimation().setMovementEventCallFunc(newAmd.animationEvent, newAmd);
newAmd.addAnimationEventCallBack(callFunc, target);
this._movementDispatches.push([armature, newAmd]);
}
},
removeArmatureMovementCallBack: function (armature, target, callFunc) {
if (armature == null || target == null || callFunc == null) {
return;
}
var locAmd;
for (var i = 0; i < this._movementDispatches.length; i++) {
locAmd = this._movementDispatches[i];
if (locAmd && locAmd[0] == armature) {
locAmd.removeAnimationEventCallBack(callFunc, target);
}
}
},
removeArmatureAllMovementCallBack: function (armature) {
if (armature == null) {
return;
}
var locAmd;
for (var i = 0; i < this._movementDispatches.length; i++) {
locAmd = this._movementDispatches[i];
if (locAmd && locAmd[0] == armature) {
this._movementDispatches.splice(i, 1);
break;
}
}
},
removeAllArmatureMovementCallBack: function () {
this._movementDispatches = [];
},
version: function () {
return "1.2.0.0";
}
};
// Functions don't support binding
ccs.Bone.prototype.getColliderBodyList = function() {
var decoDisplay = this.getDisplayManager().getCurrentDecorativeDisplay();
if (decoDisplay) {
var detector = decoDisplay.getColliderDetector();
if (detector) {
return detector.getColliderBodyList();
}
}
return [];
};
ccs.TweenType = {
CUSTOM_EASING: -1,
LINEAR: 0,
SINE_EASEIN: 1,
SINE_EASEOUT: 2,
SINE_EASEINOUT: 3,
QUAD_EASEIN: 4,
QUAD_EASEOUT: 5,
QUAD_EASEINOUT: 6,
CUBIC_EASEIN: 7,
CUBIC_EASEOUT: 8,
CUBIC_EASEINOUT: 9,
QUART_EASEIN: 10,
QUART_EASEOUT: 11,
QUART_EASEINOUT: 12,
QUINT_EASEIN: 13,
QUINT_EASEOUT: 14,
QUINT_EASEINOUT: 15,
EXPO_EASEIN: 16,
EXPO_EASEOUT: 17,
EXPO_EASEINOUT: 18,
CIRC_EASEIN: 19,
CIRC_EASEOUT: 20,
CIRC_EASEINOUT: 21,
ELASTIC_EASEIN: 22,
ELASTIC_EASEOUT: 23,
ELASTIC_EASEINOUT: 24,
BACK_EASEIN: 25,
BACK_EASEOUT: 26,
BACK_EASEINOUT: 27,
BOUNCE_EASEIN: 28,
BOUNCE_EASEOUT: 29,
BOUNCE_EASEINOUT: 30,
TWEEN_EASING_MAX: 10000
};
ccs.FrameEaseType = {
CUSTOM : -1,
LINEAR : 0,
SINE_EASEIN : 1,
SINE_EASEOUT : 2,
SINE_EASEINOUT : 3,
QUAD_EASEIN : 4,
QUAD_EASEOUT : 5,
QUAD_EASEINOUT : 6,
CUBIC_EASEIN : 7,
CUBIC_EASEOUT : 8,
CUBIC_EASEINOUT : 9,
QUART_EASEIN : 10,
QUART_EASEOUT : 11,
QUART_EASEINOUT : 12,
QUINT_EASEIN : 13,
QUINT_EASEOUT : 14,
QUINT_EASEINOUT : 15,
EXPO_EASEIN : 16,
EXPO_EASEOUT : 17,
EXPO_EASEINOUT : 18,
CIRC_EASEIN : 19,
CIRC_EASEOUT : 20,
CIRC_EASEINOUT : 21,
ELASTIC_EASEIN : 22,
ELASTIC_EASEOUT : 23,
ELASTIC_EASEINOUT : 24,
BACK_EASEIN : 25,
BACK_EASEOUT : 26,
BACK_EASEINOUT : 27,
BOUNCE_EASEIN : 28,
BOUNCE_EASEOUT : 29,
BOUNCE_EASEINOUT : 30,
TWEEN_EASING_MAX: 1000
};
@@ -1,68 +0,0 @@
/*
* Copyright (c) 2014-2016 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.
*/
ccs.armatureDataManager = null;
cc.defineGetterSetter(ccs, "armatureDataManager", function() {
return ccs.ArmatureDataManager.getInstance();
});
ccs.ArmatureDataManager.prototype.clear = function() {
ccs.ArmatureDataManager.destroyInstance();
};
/**
* @type {Object} Base singleton object for ccs.ActionManager
* @name ccs.actionManager
*/
ccs.actionManager = ccs.ActionManager.getInstance();
ccs.ActionManager.prototype.clear = function() {
this.releaseActions();
};
ccs.ActionManager.prototype.initWithDictionary = function(file, dic, node, version) {
ccs.actionManager.initWithDictionaryEx(file, JSON.stringify(dic), node, version);
}
/**
* The same as cc.Node
* @class
* @extends ccs.Class
*/
ccs.Node = ccs.Node || cc.Node;
ccs.Node.extend = ccs.Node.extend || cc.Node.extend;
/**
* The same as cc.Sprite
* @class
* @extends ccs.Class
*/
ccs.Sprite = ccs.Sprite || cc.Sprite;
ccs.Sprite.extend = ccs.Sprite.extend || cc.Sprite.extend;
/**
* The same as cc.Component
* @class
* @extends ccs.Class
*/
ccs.Component = ccs.Component || cc.Component;
ccs.Component.extend = ccs.Component.extend || cc.Component.extend;
ccs.SkinNode = cc.Node;
ccs.BoneNode.extend = cc.Class.extend;
ccs.SkeletonNode.extend = cc.Class.extend;
@@ -1,112 +0,0 @@
/*
* Copyright (c) 2014-2016 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.
*/
/************************ Cocostudio *************************/
ccs.Armature.prototype._ctor = function(name, parentBone) {
// parentBone !== undefined && ccs.Armature.prototype.init.call(this, name, parentBone);
if(parentBone !== undefined)
ccs.Armature.prototype.init.call(this, name, parentBone);
else if(name !== undefined)
ccs.Armature.prototype.init.call(this, name);
};
ccs.Bone.prototype._ctor = function(name) {
name !== undefined && ccs.Bone.prototype.init.call(this, name);
};
ccs.ArmatureAnimation.prototype._ctor = function(armature) {
armature !== undefined && ccs.ArmatureAnimation.prototype.init.call(this, armature);
};
ccs.Tween.prototype._ctor = function(bone) {
bone !== undefined && ccs.Tween.prototype.init.call(this, bone);
};
ccs.BatchNode.prototype._ctor = function() {
ccs.BatchNode.prototype.init.call(this);
};
ccs.DecorativeDisplay.prototype._ctor = function() {
ccs.DecorativeDisplay.prototype.init.call(this);
};
ccs.DisplayManager.prototype._ctor = function(bone) {
bone !== undefined && ccs.DisplayManager.prototype.init.call(this, bone);
};
ccs.Skin.prototype._ctor = function(fileName, rect) {
if (fileName == null || fileName == "") {
ccs.Skin.prototype.init.call(this);
} else {
if(fileName[0] == "#"){
ccs.Skin.prototype.initWithSpriteFrameName.call(this, fileName.substr(1));
} else {
rect ? ccs.Skin.prototype.initWithFile.call(this, fileName, rect)
: ccs.Skin.prototype.initWithFile.call(this, fileName);
}
}
};
ccs.ColliderDetector.prototype._ctor = function(bone) {
bone !== undefined && ccs.ColliderDetector.prototype.init.call(this, bone);
};
ccs.TriggerObj.prototype._ctor = function() {
ccs.TriggerObj.prototype.init.call(this);
};
ccs.ComAttribute.prototype._ctor = function() {
ccs.ComAttribute.prototype.init.call(this);
};
ccs.ComAudio.prototype._ctor = function() {
ccs.ComAudio.prototype.init.call(this);
};
ccs.ComController.prototype._ctor = function() {
ccs.ComController.prototype.init.call(this);
};
ccs.ComRender.prototype._ctor = function() {
ccs.ComRender.prototype.init.call(this);
};
ccs.ActionTimelineData.prototype._ctor = function(actionTag) {
if (actionTag !== undefined)
{
ccs.ActionTimelineData.prototype.init.call(this,actionTag);
}
};
ccs.ComExtensionData.prototype._ctor = function() {
ccs.ComExtensionData.prototype.init.call(this);
};
ccs.BoneNode.prototype._ctor = function (length) {
ccs.BoneNode.prototype.init.call(this);
length !== undefined && this.setDebugDrawLength(length);
};
ccs.SkeletonNode.prototype._ctor = function () {
ccs.SkeletonNode.prototype.init.call(this);
};
@@ -1,245 +0,0 @@
/****************************************************************************
Copyright (c) 2013-2016 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.
****************************************************************************/
ccs._load = (function(){
/**
* load file
* @param {String} file
* @param {String} [type=] - ccui|node|action
* @param {String} [path=] - Resource search path
* @returns {*}
*/
var load = function(file, type, path){
var json = cc.loader.getRes(file);
if(!json)
return cc.log("%s does not exist", file);
var ext = extname(file).toLocaleLowerCase();
if(ext !== "json" && ext !== "exportjson")
return cc.log("%s load error, must be json file", file);
var parse;
if(!type){
if(json["widgetTree"])
parse = parser["ccui"];
else if(json["nodeTree"])
parse = parser["timeline"];
else if(json["Content"] && json["Content"]["Content"])
parse = parser["timeline"];
else if(json["gameobjects"])
parse = parser["scene"];
}else{
parse = parser[type];
}
if(!parse){
cc.log("Can't find the parser : %s", file);
return new cc.Node();
}
var version = json["version"] || json["Version"];
if(!version && json["armature_data"]){
cc.warn("%s is armature. please use:", file);
cc.warn(" ccs.armatureDataManager.addArmatureFileInfoAsync(%s);", file);
cc.warn(" var armature = new ccs.Armature('name');");
return new cc.Node();
}
var currentParser = getParser(parse, version);
if(!currentParser){
cc.log("Can't find the parser : %s", file);
return new cc.Node();
}
return currentParser.parse(file, json, path) || null;
};
var parser = {
"ccui": {},
"timeline": {},
"action": {},
"scene": {}
};
load.registerParser = function(name, version, target){
if(!name || !version || !target)
return cc.log("register parser error");
if(!parser[name])
parser[name] = {};
parser[name][version] = target;
};
load.getParser = function(name, version){
if(name && version)
return parser[name] ? parser[name][version] : undefined;
if(name)
return parser[name];
return parser;
};
//Gets the file extension
var extname = function(fileName){
var arr = fileName.match(extnameReg);
return ( arr && arr[1] ) ? arr[1] : null;
};
var extnameReg = /\.([^\.]+)$/;
var parserReg = /([^\.](\.\*)?)*$/;
var getParser = function(parser, version){
if(parser[version])
return parser[version];
else if(version === "*")
return null;
else
return getParser(parser, version.replace(parserReg, "*"));
};
return load;
})();
ccs._parser = cc.Class.extend({
ctor: function(){
this.parsers = {};
},
_dirnameReg: /\S*\//,
_dirname: function(path){
var arr = path.match(this._dirnameReg);
return (arr && arr[0]) ? arr[0] : "";
},
getClass: function(json){
return json["classname"];
},
getNodeJson: function(json){
return json["widgetTree"];
},
parse: function(file, json, resourcePath){
resourcePath = resourcePath || this._dirname(file);
this.pretreatment(json, resourcePath);
var node = this.parseNode(this.getNodeJson(json), resourcePath, file);
node && this.deferred(json, resourcePath, node, file);
return node;
},
pretreatment: function(json, resourcePath, file){},
deferred: function(json, resourcePath, node, file){},
parseNode: function(json, resourcePath){
var parser = this.parsers[this.getClass(json)];
var widget = null;
if(parser)
widget = parser.call(this, json, resourcePath);
else
cc.log("Can't find the parser : %s", this.getClass(json));
return widget;
},
registerParser: function(widget, parse){
this.parsers[widget] = parse;
}
});
/**
* Analysis of studio JSON file
* The incoming file name, parse out the corresponding object
* Temporary support file list:
* ui 1.*
* node 1.* - 2.*
* action 1.* - 2.*
* scene 0.* - 1.*
* @param {String} file
* @param {String} [path=] Resource path
* @returns {{node: cc.Node, action: cc.Action}}
*/
ccs.load = function(file, path){
var object = {
node: null,
action: null
};
object.node = ccs._load(file, null, path);
object.action = ccs._load(file, "action", path);
if(object.action && object.action.tag === -1 && object.node)
object.action.tag = object.node.tag;
return object;
};
/**
* Analysis of studio JSON file and layout ui widgets by visible size.
* The incoming file name, parse out the corresponding object
* Temporary support file list:
* ui 1.*
* node 1.* - 2.*
* action 1.* - 2.*
* scene 0.* - 1.*
* @param {String} file
* @param {String} [path=] Resource path
* @returns {{node: cc.Node, action: cc.Action}}
*/
ccs.loadWithVisibleSize = function(file, path){
var object = ccs.load(file, path);
var size = cc.director.getVisibleSize();
if(object.node && size){
object.node.setContentSize(size.width, size.height);
ccui.helper.doLayout(object.node);
}
return object;
};
//Forward compatible interface
ccs.actionTimelineCache = {
//@deprecated This function will be deprecated sooner or later please use ccs.load
/**
* Create Timeline Action
* @param file
* @returns {*}
*/
createAction: function(file){
return ccs._load(file, "action");
}
};
ccs.csLoader = {
//@deprecated This function will be deprecated sooner or later please use ccs.load
/**
* Create Timeline Node
* @param file
* @returns {*}
*/
createNode: function(file){
return ccs._load(file);
}
};
@@ -1,59 +0,0 @@
/*
* Copyright (c) 2016 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 = ccs.Bone.prototype;
cc.defineGetterSetter(_proto, "color", _proto.getColor, _proto.setColor);
cc.defineGetterSetter(_proto, "opacity", _proto.getOpacity, _proto.setOpacity);
cc.defineGetterSetter(_proto, "zIndex", _proto.getLocalZOrder, _proto.setLocalZOrder);
cc.defineGetterSetter(_proto, "boneData", _proto.getBoneData, _proto.setBoneData);
cc.defineGetterSetter(_proto, "armature", _proto.getArmature, _proto.setArmature);
cc.defineGetterSetter(_proto, "parentBone", _proto.getParentBone, _proto.setParentBone);
cc.defineGetterSetter(_proto, "childArmature", _proto.getChildArmature, _proto.setChildArmature);
cc.defineGetterSetter(_proto, "childrenBone", _proto.getChildrenBone);
cc.defineGetterSetter(_proto, "tween", _proto.getTween);
cc.defineGetterSetter(_proto, "tweenData", _proto.getTweenData);
cc.defineGetterSetter(_proto, "transformDirty", _proto.getTransformDirty, _proto.setTransformDirty);
cc.defineGetterSetter(_proto, "colliderFilter", _proto.getColliderFilter, _proto.setColliderFilter);
cc.defineGetterSetter(_proto, "displayManager", _proto.getDisplayManager, _proto.setDisplayManager);
cc.defineGetterSetter(_proto, "ignoreMovementBoneData", _proto.getIgnoreMovementBoneData, _proto.setIgnoreMovementBoneData);
cc.defineGetterSetter(_proto, "name", _proto.getName, _proto.setName);
cc.defineGetterSetter(_proto, "blendDirty", _proto.getBlendDirty, _proto.setBlendDirty);
_proto = ccs.Armature.prototype;
cc.defineGetterSetter(_proto, "parentBone", _proto.getParentBone, _proto.setParentBone);
cc.defineGetterSetter(_proto, "animation", _proto.getAnimation, _proto.setAnimation);
cc.defineGetterSetter(_proto, "armatureData", _proto.getArmatureData, _proto.setArmatureData);
cc.defineGetterSetter(_proto, "name", _proto.getName, _proto.setName);
cc.defineGetterSetter(_proto, "batchNode", _proto.getBatchNode, _proto.setBatchNode);
cc.defineGetterSetter(_proto, "version", _proto.getVersion, _proto.setVersion);
cc.defineGetterSetter(_proto, "body", _proto.getBody, _proto.setBody);
cc.defineGetterSetter(_proto, "colliderFilter", _proto.setColliderFilter);
_proto = ccs.Skin.prototype;
cc.defineGetterSetter(_proto, "skinData", _proto.getSkinData, _proto.setSkinData);
cc.defineGetterSetter(_proto, "bone", _proto.getBone, _proto.setBone);
cc.defineGetterSetter(_proto, "displayName", _proto.getDisplayName);
_proto = ccs.ColliderDetector.prototype;
cc.defineGetterSetter(_proto, "colliderFilter", _proto.getColliderFilter, _proto.setColliderFilter);
cc.defineGetterSetter(_proto, "active", _proto.getActive, _proto.setActive);
cc.defineGetterSetter(_proto, "body", _proto.getBody, _proto.setBody);
@@ -1,239 +0,0 @@
/****************************************************************************
Copyright (c) 2013-2016 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.
****************************************************************************/
(function(load, baseParser){
var cache = {};
var Parser = baseParser.extend({
getNodeJson: function(json){
return json["action"];
},
parseNode: function(json, resourcePath, file){
if(!json)
return null;
if(cache[file])
return cache[file].clone();
var self = this,
action = new ccs.ActionTimeline();
action.setDuration(json["duration"]);
action.setTimeSpeed(json["speed"] || 1);
//The process of analysis
var timelines = json["timelines"];
timelines.forEach(function(timeline){
var parser = self.parsers[timeline["frameType"]];
var frame;
if(parser)
frame = parser.call(self, timeline, resourcePath);
else
cc.log("parser does not exist : %s", timeline["frameType"]);
if(frame)
action.addTimeline(frame);
if(timeline["frameType"] === "ColorFrame"){
action.addTimeline(
self.parsers["AlphaFrame"].call(self, timeline, resourcePath)
);
}
});
cache[file] = action;
cache[file].retain();
return action.clone();
}
});
var parser = new Parser();
var frameList = [
{
name: "PositionFrame",
handle: function(options){
var frame = new ccs.PositionFrame();
var x = options["x"];
var y = options["y"];
frame.setPosition(cc.p(x,y));
return frame;
}
},
{
name: "VisibleFrame",
handle: function(options){
var frame = new ccs.VisibleFrame();
var visible = options["value"];
frame.setVisible(visible);
return frame;
}
},
{
name: "ScaleFrame",
handle: function(options){
var frame = new ccs.ScaleFrame();
var scalex = options["x"];
var scaley = options["y"];
frame.setScaleX(scalex);
frame.setScaleY(scaley);
return frame;
}
},
{
name: "RotationFrame",
handle: function(options){
var frame = new ccs.RotationFrame();
var rotation = options["rotation"];
frame.setRotation(rotation);
return frame;
}
},
{
name: "SkewFrame",
handle: function(options){
var frame = new ccs.SkewFrame();
var skewx = options["x"];
var skewy = options["y"];
frame.setSkewX(skewx);
frame.setSkewY(skewy);
return frame;
}
},
{
name: "RotationSkewFrame",
handle: function(options){
var frame = new ccs.RotationSkewFrame();
var skewx = options["x"];
var skewy = options["y"];
frame.setSkewX(skewx);
frame.setSkewY(skewy);
return frame;
}
},
{
name: "AnchorFrame",
handle: function(options){
var frame = new ccs.AnchorPointFrame();
var anchorx = options["x"];
var anchory = options["y"];
frame.setAnchorPoint(cc.p(anchorx, anchory));
return frame;
}
},
{
name: "InnerActionFrame",
handle: function(options){
var frame = new ccs.InnerActionFrame();
var type = options["innerActionType"];
var startFrame = options["startFrame"];
frame.setInnerActionType(type);
frame.setStartFrameIndex(startFrame);
return frame;
}
},
{
name: "ColorFrame",
handle: function(options){
var frame = new ccs.ColorFrame();
var red = options["red"];
var green = options["green"];
var blue = options["blue"];
frame.setColor(cc.color(red, green, blue));
var alphaFrame = new ccs.AlphaFrame();
var alpha = options["alpha"];
alphaFrame.setAlpha(alpha);
return frame;
}
},
{
name: "AlphaFrame",
handle: function(options){
var frame = new ccs.AlphaFrame();
var alpha = options["alpha"];
frame.setAlpha(alpha);
return frame;
}
},
{
name: "TextureFrame",
handle: function(options){
var frame = new ccs.TextureFrame();
var texture = options["value"];
if(texture != null) {
var path = texture;
var spriteFrame = cc.spriteFrameCache.getSpriteFrame(path);
if(spriteFrame == null){
var jsonPath = ccs.csLoader.getJsonPath();
path = jsonPath + texture;
}
frame.setTextureName(path);
}
return frame;
}
},
{
name: "EventFrame",
handle: function(options){
var frame = new ccs.EventFrame();
var evnt = options["value"];
if(evnt != null)
frame.setEvent(evnt);
return frame;
}
},
{
name: "ZOrderFrame",
handle: function(options){
var frame = new ccs.ZOrderFrame();
var zorder = options["value"];
frame.setZOrder(zorder);
return frame;
}
}
];
frameList.forEach(function(item){
parser.registerParser(item.name, function(options, resourcePath){
var timeline = new ccs.Timeline();
timeline.setActionTag(options["actionTag"]);
var frames = options["frames"];
if(frames && frames.length){
frames.forEach(function(frameData){
var frame = item.handle(frameData);
frame.setFrameIndex(frameData["frameIndex"]);
frame.setTween(frameData["tween"]);
timeline.addFrame(frame);
});
}
return timeline;
});
});
load.registerParser("action", "0.*", parser);
load.registerParser("action", "1.*", parser);
})(ccs._load, ccs._parser);
@@ -1,315 +0,0 @@
/****************************************************************************
Copyright (c) 2013-2016 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.
****************************************************************************/
(function(load, baseParser){
var cache = {};
var Parser = baseParser.extend({
getNodeJson: function(json){
return json["Content"]["Content"]["Animation"];
},
parseNode: function(json, resourcePath, file){
if(!json)
return null;
if(cache[file])
return cache[file].clone();
var self = this,
action = new ccs.ActionTimeline();
action.setDuration(json["Duration"]);
action.setTimeSpeed(json["Speed"] || 1);
//The process of analysis
var timelines = json["Timelines"];
timelines.forEach(function(timeline){
var parser = self.parsers[timeline["Property"]];
var frame;
if(parser)
frame = parser.call(self, timeline, resourcePath);
else
cc.log("parser does not exist : %s", timeline["Property"]);
if(frame)
action.addTimeline(frame);
});
cache[file] = action;
cache[file].retain();
return action.clone();
},
deferred: function(json, resourcePath, action, file){
var animationlist = json["Content"]["Content"]["AnimationList"];
var length = animationlist ? animationlist.length : 0;
for (var i = 0; i < length; i++){
var animationdata = animationlist[i];
var info = { name: null, startIndex: null, endIndex: null };
info.name = animationdata["Name"];
info.startIndex = animationdata["StartIndex"];
info.endIndex = animationdata["EndIndex"];
action.addAnimationInfo(info);
}
}
});
var parser = new Parser();
var frameList = [
{
name: "Position",
handle: function(options){
var frame = new ccs.PositionFrame();
var x = options["X"];
var y = options["Y"];
frame.setPosition(cc.p(x,y));
return frame;
}
},
{
name: "VisibleForFrame",
handle: function(options){
var frame = new ccs.VisibleFrame();
var visible = options["Value"];
frame.setVisible(visible);
return frame;
}
},
{
name: "Scale",
handle: function(options){
var frame = new ccs.ScaleFrame();
var scalex = options["X"];
var scaley = options["Y"];
frame.setScaleX(scalex);
frame.setScaleY(scaley);
return frame;
}
},
{
name: "Rotation",
handle: function(options){
var frame = new ccs.RotationFrame();
var rotation = options["Rotation"] || options["Value"] || 0;
frame.setRotation(rotation);
return frame;
}
},
{
name: "Skew",
handle: function(options){
var frame = new ccs.SkewFrame();
var skewx = options["X"];
var skewy = options["Y"];
frame.setSkewX(skewx);
frame.setSkewY(skewy);
return frame;
}
},
{
name: "RotationSkew",
handle: function(options){
var frame = new ccs.RotationSkewFrame();
var skewx = options["X"];
var skewy = options["Y"];
frame.setSkewX(skewx);
frame.setSkewY(skewy);
return frame;
}
},
{
name: "Anchor",
handle: function(options){
var frame = new ccs.AnchorPointFrame();
var anchorx = options["X"];
var anchory = options["Y"];
frame.setAnchorPoint(cc.p(anchorx, anchory));
return frame;
}
},{
name: "AnchorPoint",
handle: function(options){
var frame = new ccs.AnchorPointFrame();
var anchorx = options["X"];
var anchory = options["Y"];
frame.setAnchorPoint(cc.p(anchorx, anchory));
return frame;
}
},{
name: "InnerAction",
handle: function(options){
var frame = new ccs.InnerActionFrame();
var type = options["InnerActionType"];
var startFrame = options["StartFrame"];
frame.setInnerActionType(type);
frame.setStartFrameIndex(startFrame);
return frame;
}
},
{
name: "CColor",
handle: function(options){
var frame = new ccs.ColorFrame();
var color = options["Color"];
if(!color) color = {};
color["R"] = color["R"] === undefined ? 255 : color["R"];
color["G"] = color["G"] === undefined ? 255 : color["G"];
color["B"] = color["B"] === undefined ? 255 : color["B"];
frame.setColor(cc.color(color["R"], color["G"], color["B"]));
return frame;
}
},
{
name: "Alpha",
handle: function(options){
var frame = new ccs.AlphaFrame();
var alpha = options["Value"];
frame.setAlpha(alpha);
return frame;
}
},
{
name: "FileData",
handle: function(options, resourcePath){
var frame, texture, plist, path, spriteFrame;
frame = new ccs.TextureFrame();
texture = options["TextureFile"];
if(texture != null) {
plist = texture["Plist"];
path = texture["Path"];
spriteFrame = cc.spriteFrameCache.getSpriteFrame(path);
if(!spriteFrame && plist){
if(cc.loader.getRes(resourcePath + plist)){
cc.spriteFrameCache.addSpriteFrames(resourcePath + plist);
spriteFrame = cc.spriteFrameCache.getSpriteFrame(path);
}else{
cc.log("%s need to be preloaded", resourcePath + plist);
}
}
if(spriteFrame == null){
path = resourcePath + path;
}
frame.setTextureName(path);
}
return frame;
}
},
{
name: "FrameEvent",
handle: function(options){
var frame = new ccs.EventFrame();
var evnt = options["Value"];
if(evnt != null)
frame.setEvent(evnt);
return frame;
}
},
{
name: "ZOrder",
handle: function(options){
var frame = new ccs.ZOrderFrame();
var zorder = options["Value"];
frame.setZOrder(zorder);
return frame;
}
},
{
name: "ActionValue",
handle: function (options) {
var frame = new ccs.InnerActionFrame();
var innerActionType = options["InnerActionType"];
var currentAnimationFrame = options["CurrentAniamtionName"];
var singleFrameIndex = options["SingleFrameIndex"];
var frameIndex = options["FrameIndex"];
if(frameIndex !== undefined)
frame.setFrameIndex(frameIndex);
frame.setInnerActionType(ccs.InnerActionType[innerActionType]);
frame.setSingleFrameIndex(singleFrameIndex);
frame.setEnterWithName(true);
if (currentAnimationFrame)
frame.setAnimationName(currentAnimationFrame);
return frame;
}
},
{
name: "BlendFunc",
handle: function(options){
var frame = new ccs.BlendFuncFrame();
var blendFunc = options["BlendFunc"];
if(blendFunc && blendFunc["Src"] !== undefined && blendFunc["Dst"] !== undefined)
frame.setBlendFunc(new cc.BlendFunc(blendFunc["Src"], blendFunc["Dst"]));
return frame;
}
}
];
var loadEasingDataWithFlatBuffers = function(frame, options){
var type = options["Type"];
frame.setTweenType(type);
var points = options["Points"];
var result = [];
if(points){
points.forEach(function(p){
result.push(p["X"]);
result.push(p["Y"]);
});
frame.setEasingParams(result);
}
};
frameList.forEach(function(item){
parser.registerParser(item.name, function(options, resourcePath){
var timeline = new ccs.Timeline();
timeline.setActionTag(options["ActionTag"]);
var frames = options["Frames"];
if(frames && frames.length){
frames.forEach(function(frameData){
var frame = item.handle(frameData, resourcePath);
frame.setFrameIndex(frameData["FrameIndex"]);
var tween = frameData["Tween"] != null ? frameData["Tween"] : true;
frame.setTween(tween);
//https://github.com/cocos2d/cocos2d-x/pull/11388/files
var easingData = frameData["EasingData"];
if(easingData)
loadEasingDataWithFlatBuffers(frame, easingData);
timeline.addFrame(frame);
});
}
return timeline;
});
});
load.registerParser("action", "*", parser);
})(ccs._load, ccs._parser);
@@ -1,255 +0,0 @@
/****************************************************************************
Copyright (c) 2013-2016 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.
****************************************************************************/
/*
This file is for compatibility compatibility with older versions of GUIReader and SceneReader
todo: deprecated all
*/
(function(){
ccs.uiReader = {
_fileDesignSizes: {},
//@deprecated This function will be deprecated sooner or later please use ccs.load
/**
* Create CCUI Node
* @param file
* @returns {*}
*/
widgetFromJsonFile: function(file){
var json = cc.loader.getRes(cc.path.join(cc.loader.resPath, file));
if(json) {
this._fileDesignSizes[file] = cc.size(json["designWidth"]||0, json["designHeight"]||0);
}
else {
return null;
}
var version = json["Version"] || json["version"];
var versionNum = ccs.uiReader.getVersionInteger(version);
if(!version || versionNum >= 1700){
cc.warn("Not supported file types, Please try use the ccs.load");
return null;
}
return ccs._load(file, "ccui");
},
//@deprecated This function will be deprecated sooner or later please use parser.registerParser
/**
* Register a custom Widget reader
* @param classType
* @param ins
* @param object
* @param callback
* @deprecated This function will be deprecated sooner or later please use parser.registerParser
*/
registerTypeAndCallBack: function(classType, ins, object, callback){
var parser = ccs._load.getParser("ccui")["*"];
var func = callback.bind(object);
parser.registerParser(classType, function(options, resourcePath){
var widget = new ins();
var uiOptions = options["options"];
object.setPropsFromJsonDictionary && object.setPropsFromJsonDictionary(widget, uiOptions);
this.generalAttributes(widget, uiOptions);
var customProperty = uiOptions["customProperty"];
if(customProperty)
customProperty = JSON.parse(customProperty);
else
customProperty = {};
func(classType, widget, customProperty);
this.colorAttributes(widget, uiOptions);
this.anchorPointAttributes(widget, uiOptions);
this.parseChild.call(this, widget, options, resourcePath);
return widget;
});
},
//@deprecated This function will be deprecated sooner or later
/**
* Gets the version number by version string.
* @param {String} version version string.
* @returns {Number}
*/
getVersionInteger: function(version){
if(!version || typeof version !== "string") return 0;
var arr = version.split(".");
if (arr.length !== 4)
return 0;
var num = 0;
arr.forEach(function(n, i){
num += n * Math.pow(10, 3 - i);
});
return num;
},
//@deprecated This function will be deprecated sooner or later
/**
* stores the designSize of UI file.
* @param {String} fileName
* @param {cc.Size} size
*/
storeFileDesignSize: function (fileName, size) {
this._fileDesignSizes[fileName] = size;
},
//@deprecated This function will be deprecated sooner or later
/**
* Gets the design size by filename.
* @param {String} fileName
* @returns {cc.Size}
*/
getFileDesignSize: function (fileName) {
return this._fileDesignSizes[fileName];
},
//@deprecated This function will be deprecated sooner or later
/**
* Returns the file path
* @returns {string}
*/
getFilePath: function(){
return this._filePath;
},
//@deprecated This function will be deprecated sooner or later
setFilePath: function(path){
this._filePath = path;
},
//@deprecated This function will be deprecated sooner or later
/**
* Returns the parsed object map. (analytic function)
* @returns {Object}
*/
getParseObjectMap: function(){
return ccs._load.getParser("ccui")["*"]["parsers"];
},
//@deprecated This function will be deprecated sooner or later
/**
* Returns the parsed callback map. (analytic function)
* @returns {*}
*/
getParseCallBackMap: function(){
return ccs._load.getParser("ccui")["*"]["parsers"];
},
//@deprecated This function will be deprecated sooner or later
clear: function(){}
};
var parser = ccs._load.getParser("ccui")["*"];
ccs.imageViewReader = {setPropsFromJsonDictionary: parser.ImageViewAttributes};
ccs.buttonReader = {setPropsFromJsonDictionary: parser.ButtonAttributes};
ccs.checkBoxReader = {setPropsFromJsonDictionary: parser.CheckBoxAttributes};
ccs.labelAtlasReader = {setPropsFromJsonDictionary: parser.TextAtlasAttributes};
ccs.labelBMFontReader= {setPropsFromJsonDictionary: parser.TextBMFontAttributes};
ccs.labelReader = {setPropsFromJsonDictionary: parser.TextAttributes};
ccs.layoutReader = {setPropsFromJsonDictionary: parser.LayoutAttributes};
ccs.listViewReader = {setPropsFromJsonDictionary: parser.ListViewAttributes};
ccs.loadingBarReader = {setPropsFromJsonDictionary: parser.LoadingBarAttributes};
ccs.pageViewReader = {setPropsFromJsonDictionary: parser.PageViewAttributes};
ccs.scrollViewReader = {setPropsFromJsonDictionary: parser.ScrollViewAttributes};
ccs.sliderReader = {setPropsFromJsonDictionary: parser.SliderAttributes};
ccs.textFieldReader = {setPropsFromJsonDictionary: parser.TextFieldAttributes};
})();
(function(){
ccs.sceneReader = {
_node: null,
//@deprecated This function will be deprecated sooner or later please use ccs.load
/**
* Create Scene Node
* @param file
* @returns {*}
*/
createNodeWithSceneFile: function(file){
var node = ccs._load(file, "scene");
this._node = node;
return node;
},
/**
* Get a node by tag.
* @param {Number} tag
* @returns {cc.Node|null}
*/
getNodeByTag: function(tag){
if (this._node == null)
return null;
if (this._node.getTag() === tag)
return this._node;
return this._nodeByTag(this._node, tag);
},
_nodeByTag: function (parent, tag) {
if (parent == null)
return null;
var retNode = null;
var children = parent.getChildren();
for (var i = 0; i < children.length; i++) {
var child = children[i];
if (child && child.getTag() === tag) {
retNode = child;
break;
} else {
retNode = this._nodeByTag(child, tag);
if (retNode)
break;
}
}
return retNode;
},
//@deprecated This function will be deprecated sooner or later
/**
* Returns the version of ccs.SceneReader.
* @returns {string}
*/
version: function(){
return "*";
},
//@deprecated This function will be deprecated sooner or later
/**
* Sets the listener to reader.
* Cannot use
*/
setTarget: function(){},
//@deprecated This function will be deprecated sooner or later
/**
* Clear all triggers and stops all sounds.
*/
clear: function(){
ccs.triggerManager.removeAll();
cc.audioEngine.end();
}
};
})();
@@ -1,262 +0,0 @@
/****************************************************************************
Copyright (c) 2013-2016 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.
****************************************************************************/
(function(load, baseParser){
var Parser = baseParser.extend({
getNodeJson: function(json){
return json;
},
parseNode: function(json, resourcePath){
var parser = this.parsers[this.getClass(json)];
var node = null;
if(parser)
node = parser.call(this, json, resourcePath);
else
cc.log("Can't find the parser : %s", this.getClass(json));
return node;
},
deferred: function(json, resourcePath, node, file){
ccs.triggerManager.parse(json["Triggers"]||[]);
if(ccs.sceneReader)
ccs.sceneReader._node = node;
},
setPropertyFromJsonDict: function(node, json){
var x = json["x"] || 0;
var y = json["y"] || 0;
node.setPosition(x, y);
var bVisible = Boolean(cc.isValidValue(json["visible"]) ? json["visible"] : 1);
node.setVisible(bVisible);
var nTag = cc.isValidValue(json["objecttag"]) ? json["objecttag"] : -1;
node.setTag(nTag);
var nZorder = json["zorder"] || 0;
node.setLocalZOrder(nZorder);
var fScaleX = cc.isValidValue(json["scalex"]) ? json["scalex"] : 1;
var fScaleY = cc.isValidValue(json["scaley"]) ? json["scaley"] : 1;
node.setScaleX(fScaleX);
node.setScaleY(fScaleY);
var fRotationZ = json["rotation"] || 0;
node.setRotation(fRotationZ);
var sName = json["name"] || "";
node.setName(sName);
}
});
var parser = new Parser();
parser.parseChild = function(node, objects, resourcePath){
for (var i = 0; i < objects.length; i++) {
var child,
options = objects[i];
if(options)
child = this.parseNode(options, resourcePath);
if(child)
node.addChild(child);
}
};
var componentsParser = {
"CCSprite": function(node, component, resourcePath){
var child = new cc.Sprite();
loadTexture(component["fileData"], resourcePath, function(path, type){
if(type === 0)
child.setTexture(path);
else if(type === 1){
var spriteFrame = cc.spriteFrameCache.getSpriteFrame(path);
child.setSpriteFrame(spriteFrame);
}
});
var render = new ccs.ComRender(child, "CCSprite");
node.addComponent(render);
return render;
},
"CCTMXTiledMap": function(node, component, resourcePath){
var child = null;
loadTexture(component["fileData"], resourcePath, function(path, type){
if(type === 0)
child = new cc.TMXTiledMap(path);
});
var render = new ccs.ComRender(child, "CCTMXTiledMap");
node.addComponent(render);
return render;
},
"CCParticleSystemQuad": function(node, component, resourcePath){
var child = null;
loadTexture(component["fileData"], resourcePath, function(path, type){
if(type === 0)
child = new cc.ParticleSystem(path);
else
cc.log("unknown resourcetype on CCParticleSystemQuad!");
child.setPosition(0, 0);
});
var render = new ccs.ComRender(child, "CCParticleSystemQuad");
node.addComponent(render);
return render;
},
"CCArmature": function(node, component, resourcePath){
var child = null;
loadTexture(component["fileData"], resourcePath, function(path, type){
if(type === 0){
var jsonDict = cc.loader.getRes(path);
if (!jsonDict) cc.log("Please load the resource [%s] first!", path);
var armature_data = jsonDict["armature_data"];
var subData = armature_data[0];
var name = subData["name"];
ccs.armatureDataManager.addArmatureFileInfo(path);
child = new ccs.Armature(name);
}
});
if(child){
var render = new ccs.ComRender(child, "CCArmature");
node.addComponent(render);
var actionName = component["selectedactionname"];
if (actionName && child.getAnimation())
child.getAnimation().play(actionName);
return render;
}
},
"CCComAudio": function(node, component, resourcePath){
var audio = null;
loadTexture(component["fileData"], resourcePath, function(path, type){
if(type === 0){
audio = new ccs.ComAudio();
audio.preloadEffect(path);
var name = component["name"];
if(name)
audio.setName(name);
node.addComponent(audio);
}
});
},
"CCComAttribute": function(node, component, resourcePath){
var attribute = null;
loadTexture(component["fileData"], resourcePath, function(path, type){
if(type === 0){
attribute = new ccs.ComAttribute();
if (path !== "")
attribute.parse(path);
node.addComponent(attribute);
}else
cc.log("unknown resourcetype on CCComAttribute!");
});
return attribute;
},
"CCBackgroundAudio": function(node, component, resourcePath){
var audio = null;
loadTexture(component["fileData"], resourcePath, function(path, type){
if(type === 0){
audio = new ccs.ComAudio();
audio.preloadBackgroundMusic(path);
audio.setFile(path);var bLoop = Boolean(component["loop"] || 0);
audio.setLoop(bLoop);
var name = component["name"];
if(name)
audio.setName(name);
node.addComponent(audio);
audio.playBackgroundMusic(path, bLoop);
}
});
},
"GUIComponent": function(node, component, resourcePath){
var widget = null;
loadTexture(component["fileData"], resourcePath, function(path, type){
widget = ccs._load(path, "ccui");
});
var render = new ccs.ComRender(widget, "GUIComponent");
node.addComponent(render);
return render;
},
"CCScene": function(){}
};
var loadedPlist = {};
var loadTexture = function(json, resourcePath, cb){
if(json != null){
var path = json["path"];
var type = json["resourceType"];
var plist = json["plist"];
if(!path)
return;
if(plist){
if(cc.loader.getRes(resourcePath + plist)){
loadedPlist[resourcePath + plist] = true;
cc.spriteFrameCache.addSpriteFrames(resourcePath + plist);
}else{
if(!loadedPlist[resourcePath + plist])
cc.log("%s need to be preloaded", resourcePath + plist);
}
}
if(type !== 0)
cb(path, type);
else
cb(resourcePath + path, type);
}
};
parser.parseComponents = function(node, json, resourcePath){
if(!node || !json)
return;
json.forEach(function(component){
var parser = componentsParser[component["classname"]];
var render = null;
if(parser)
render = parser(node, component, resourcePath);
else
cc.log("Can't find the component parser : %s", component["classname"]);
var name = component["name"];
if(render && name){
render.setName(name);
}
});
};
parser.registerParser("CCNode", function(options, resourcePath){
var node = new cc.Node();
this.setPropertyFromJsonDict(node, options);
this.parseChild.call(this, node, options["gameobjects"], resourcePath);
this.parseComponents(node, options["components"], resourcePath);
var size = options["CanvasSize"];
if (size)
node.setContentSize(cc.size(size["_width"], size["_height"]));
return node;
});
load.registerParser("scene", "*", parser);
})(ccs._load, ccs._parser);
@@ -1,293 +0,0 @@
/****************************************************************************
Copyright (c) 2013-2016 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.
****************************************************************************/
(function(load, baseParser){
var loadedPlist = {};
var Parser = baseParser.extend({
getNodeJson: function(json){
return json["nodeTree"];
},
addSpriteFrame: function(plists, pngs, resourcePath){
if(!plists || !pngs || plists.length !== pngs.length)
return;
for (var i = 0; i < plists.length; i++) {
var plist = resourcePath + plists[i];
if(!cc.loader.getRes(plist) && !loadedPlist[plist])
cc.log("%s need to be preloaded", plist);
else
loadedPlist[plist] = true;
cc.spriteFrameCache.addSpriteFrames(
plist,
resourcePath + pngs[i]
);
}
},
pretreatment: function(json, resourcePath, file){
this.addSpriteFrame(json["textures"], json["texturesPng"], resourcePath);
}
});
var parser = new Parser();
parser.generalAttributes = function(node, options){
var width = options["width"] !=null ? options["width"] : 0;
var height = options["height"] !=null ? options["height"] : 0;
var x = options["x"] !=null ? options["x"] : 0;
var y = options["y"] !=null ? options["y"] : 0;
var scalex = options["scaleX"] !=null ? options["scaleX"] : 1;
var scaley = options["scaleY"] !=null ? options["scaleY"] : 1;
var rotation = options["rotation"] !=null ? options["rotation"] : 0;
var rotationSkewX = options["rotationSkewX"]!=null ? options["rotationSkewX"] : 0;
var rotationSkewY = options["rotationSkewY"]!=null ? options["rotationSkewY"] : 0;
var skewx = options["skewX"] !=null ? options["skewX"] : 0;
var skewy = options["skewY"] !=null ? options["skewY"] : 0;
var anchorx = options["anchorPointX"] !=null ? options["anchorPointX"] : 0.5;
var anchory = options["anchorPointY"] !=null ? options["anchorPointY"] : 0.5;
var alpha = options["opacity"] !=null ? options["opacity"] : 255;
var red = options["colorR"] !=null ? options["colorR"] : 255;
var green = options["colorG"] !=null ? options["colorG"] : 255;
var blue = options["colorB"] !=null ? options["colorB"] : 255;
var zorder = options["colorR"] !=null ? options["colorR"] : 0;
var tag = options["tag"] !=null ? options["tag"] : 0;
var actionTag = options["actionTag"] !=null ? options["actionTag"] : 0;
var visible = options["visible"] !=null ? options["visible"] : true;
if(x != 0 || y != 0)
node.setPosition(cc.p(x, y));
if(scalex != 1)
node.setScaleX(scalex);
if(scaley != 1)
node.setScaleY(scaley);
if (rotation != 0)
node.setRotation(rotation);
if(rotationSkewX != 0)
node.setRotationX(rotationSkewX);
if(rotationSkewY != 0)
node.setRotationY(rotationSkewY);
if(skewx != 0)
node.setSkewX(skewx);
if(skewy != 0)
node.setSkewY(skewy);
if(anchorx != 0.5 || anchory != 0.5)
node.setAnchorPoint(cc.p(anchorx, anchory));
if(width != 0 || height != 0)
node.setContentSize(cc.size(width, height));
if(zorder != 0)
node.setLocalZOrder(zorder);
if(visible != true)
node.setVisible(visible);
if(alpha != 255)
{
node.setOpacity(alpha);
}
if(red != 255 || green != 255 || blue != 255)
{
node.setColor(cc.color(red, green, blue));
}
node.setTag(tag);
node.setUserObject(new ccs.ActionTimelineData(actionTag));
};
parser.parseComponent = function(node, options){
if(!options) return;
for (var i = 0; i < options.length; ++i){
var dic = options[i];
var component = this.loadComponent(dic);
if (component){
node.addComponent(component);
}
}
};
parser.parseChild = function(parse, widget, options, resourcePath){
var children = options["children"];
for (var i = 0; i < children.length; i++) {
var child = this.parseNode(children[i], resourcePath);
if(child){
if(widget instanceof ccui.PageView){
if(child instanceof ccui.Layout)
widget.addPage(child);
} else {
if(widget instanceof ccui.ListView){
if(child instanceof ccui.Widget)
widget.pushBackCustomItem(child);
} else {
if(!(widget instanceof ccui.Layout) && child instanceof ccui.Widget) {
if(child.getPositionType() === ccui.Widget.POSITION_PERCENT) {
var position = child.getPositionPercent();
var anchor = widget.getAnchorPoint();
child.setPositionPercent(cc.p(position.x + anchor.x, position.y + anchor.y));
}
//To make up for the studio positioning error problem
var AnchorPointIn = widget.getAnchorPointInPoints();
child.setPosition(cc.p(child.getPositionX() + AnchorPointIn.x, child.getPositionY() + AnchorPointIn.y));
}
widget.addChild(child);
}
}
}
}
};
parser.initNode = function(options){
var node = new cc.Node();
this.generalAttributes(node, options);
return node;
};
parser.initSubGraph = function(options){
var filePath = options["fileName"];
var node;
if (filePath && "" !== filePath){
node = this.createNode(filePath);
}else{
node = new ccs.Node();
}
this.generalAttributes(node, options);
return node;
};
parser.initSprite = function(options, resourcePath){
var path = options["fileName"];
var sprite;
if(path != null){
var spriteFrame = cc.spriteFrameCache.getSpriteFrame(path);
if(!spriteFrame){
path = resourcePath + path;
sprite = new ccs.Sprite(path);
}else{
sprite = ccs.Sprite.createWithSpriteFrame(spriteFrame);
}
if(!sprite){
sprite = new cc.Sprite();
cc.log("filePath is empty. Create a sprite with no texture");
}
}else{
sprite = new ccs.Sprite();
}
this.generalAttributes(sprite, options);
var flipX = options["flipX"];
var flipY = options["flipY"];
if(flipX != false)
sprite.setFlippedX(flipX);
if(flipY != false)
sprite.setFlippedY(flipY);
return sprite;
};
parser.initParticle = function(options, resourcePath){
var filePath = options["plistFile"];
var num = options["tmxFile"];
var particle = new cc.ParticleSystemQuad(filePath);
particle.setTotalParticles(num);
this.generalAttributes(particle, options);
return particle;
};
parser.initTMXTiledMap = function(options, resourcePath){
var tmxFile = options["tmxFile"];
var tmxString = options["tmxString"];
//todo check path and resourcePath
var path = options["resourcePath"];
var tmx = null;
if (tmxFile && "" !== tmxFile){
tmx = new cc.TMXTiledMap(tmxFile);
}else if (tmxString && "" !== tmxString && path && "" !== path){
tmx = new cc.TMXTiledMap(tmxString, path);
}
return tmx;
};
var uiParser = load.getParser("ccui")["*"];
parser.initWidget = function(options, resourcePath){
var type = options["classname"];
var parser = uiParser.parsers[type];
if(!parser)
return cc.log("%s parser is not found", type);
var node = parser.call(uiParser, options, resourcePath);
if(node){
var rotationSkewX = options["rotationSkewX"];
var rotationSkewY = options["rotationSkewY"];
var skewx = options["skewX"];
var skewy = options["skewY"];
if(rotationSkewX != 0)
node.setRotationX(rotationSkewX);
if(rotationSkewY != 0)
node.setRotationY(rotationSkewY);
if(skewx != 0)
node.setSkewX(skewx);
if(skewy != 0)
node.setSkewY(skewy);
var actionTag = options["actionTag"];
node.setUserObject(new ccs.ActionTimelineData(actionTag));
}
return node;
};
var register = [
{name: "Node", handle: parser.initNode},
{name: "SubGraph", handle: parser.initSubGraph},
{name: "Sprite", handle: parser.initSprite},
{name: "Particle", handle: parser.initParticle},
{name: "TMXTiledMap", handle: parser.initTMXTiledMap},
{name: "Widget", handle: parser.initWidget},
{name: "Panel", handle: parser.initWidget},
{name: "Button", handle: parser.initWidget},
{name: "CheckBox", handle: parser.initWidget},
{name: "ImageView", handle: parser.initWidget},
{name: "LabelAtlas", handle: parser.initWidget},
{name: "LabelBMFont", handle: parser.initWidget},
{name: "Label", handle: parser.initWidget},
{name: "ListView", handle: parser.initWidget},
{name: "LoadingBar", handle: parser.initWidget},
{name: "PageView", handle: parser.initWidget},
{name: "ScrollView", handle: parser.initWidget},
{name: "Slider", handle: parser.initWidget},
{name: "TextField", handle: parser.initWidget}
];
register.forEach(function(item){
parser.registerParser(item.name, function(options, parse, resourcePath){
var node = item.handle.call(this, options["options"]);
this.parseComponent(node, options["components"]);
this.parseChild(parse, node, options, resourcePath);
return node;
});
});
load.registerParser("timeline", "0.*", parser);
load.registerParser("timeline", "1.*", parser);
})(ccs._load, ccs._parser);
File diff suppressed because it is too large Load Diff
@@ -1,708 +0,0 @@
/****************************************************************************
Copyright (c) 2013-2016 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.
****************************************************************************/
(function(load, baseParser){
var Parser = baseParser.extend({
addSpriteFrame: function(textures, resourcePath){
if(!textures) return;
for (var i = 0; i < textures.length; i++) {
cc.spriteFrameCache.addSpriteFrames(resourcePath + textures[i]);
}
},
pretreatment: function(json, resourcePath){
this.addSpriteFrame(json["textures"], resourcePath);
},
deferred: function(json, resourcePath, node, file){
if(node){
var version = json["Version"] || json["version"];
var versionNum = ccs.uiReader.getVersionInteger(version);
ccs.actionManager.initWithDictionary(file, json["animation"], node, versionNum);
node.setContentSize(cc.size(json["designWidth"], json["designHeight"]));
}
}
});
var parser = new Parser();
parser.generalAttributes = function(widget, options){
var ignoreSizeExsit = options["ignoreSize"];
if(ignoreSizeExsit != null)
widget.ignoreContentAdaptWithSize(ignoreSizeExsit);
if (options["sizeType"])
{
widget.setSizeType(options["sizeType"]);
}
if (options["positionType"])
{
widget.setPositionType(options["positionType"]);
}
widget.setSizePercent(cc.p(options["sizePercentX"], options["sizePercentY"]));
widget.setPositionPercent(cc.p(options["positionPercentX"], options["positionPercentY"]));
/* adapt screen */
var w = 0, h = 0;
var adaptScreen = options["adaptScreen"];
if (adaptScreen) {
var screenSize = cc.director.getWinSize();
w = screenSize.width;
h = screenSize.height;
} else {
w = options["width"];
h = options["height"];
}
widget.setContentSize(w, h);
widget.setTag(options["tag"]);
widget.setActionTag(options["actiontag"]);
widget.setTouchEnabled(options["touchAble"]);
var name = options["name"];
var widgetName = name ? name : "default";
widget.setName(widgetName);
var x = options["x"];
var y = options["y"];
widget.setPosition(x, y);
var sx = options["scaleX"]!=null ? options["scaleX"] : 1;
widget.setScaleX(sx);
var sy = options["scaleY"]!=null ? options["scaleY"] : 1;
widget.setScaleY(sy);
var rt = options["rotation"] || 0;
widget.setRotation(rt);
var vb = options["visible"] || false;
if(vb != null)
widget.setVisible(vb);
widget.setLocalZOrder(options["ZOrder"]);
var layout = options["layoutParameter"];
if(layout != null){
var layoutParameterDic = options["layoutParameter"];
var paramType = layoutParameterDic["type"];
var parameter = null;
switch(paramType){
case 0:
break;
case 1:
parameter = new ccui.LinearLayoutParameter();
var gravity = layoutParameterDic["gravity"];
parameter.setGravity(gravity);
break;
case 2:
parameter = new ccui.RelativeLayoutParameter();
var rParameter = parameter;
var relativeName = layoutParameterDic["relativeName"];
rParameter.setRelativeName(relativeName);
var relativeToName = layoutParameterDic["relativeToName"];
rParameter.setRelativeToWidgetName(relativeToName);
var align = layoutParameterDic["align"];
rParameter.setAlign(align);
break;
default:
break;
}
if(parameter != null){
var mgl = layoutParameterDic["marginLeft"]||0;
var mgt = layoutParameterDic["marginTop"]||0;
var mgr = layoutParameterDic["marginRight"]||0;
var mgb = layoutParameterDic["marginDown"]||0;
parameter.setMargin(mgl, mgt, mgr, mgb);
widget.setLayoutParameter(parameter);
}
}
};
parser.colorAttributes = function(widget, options){
var op = options["opacity"];
if(op != null)
widget.setOpacity(op);
var colorR = options["colorR"];
var colorG = options["colorG"];
var colorB = options["colorB"];
widget.setColor(cc.color((colorR == null) ? 255 : colorR, (colorG == null) ? 255 : colorG, (colorB == null) ? 255 : colorB));
widget.setFlippedX(options["flipX"]);
widget.setFlippedY(options["flipY"]);
};
parser.anchorPointAttributes = function(widget, options){
var isAnchorPointXExists = options["anchorPointX"];
var anchorPointXInFile;
if (isAnchorPointXExists != null)
anchorPointXInFile = options["anchorPointX"];
else
anchorPointXInFile = widget.getAnchorPoint().x;
var isAnchorPointYExists = options["anchorPointY"];
var anchorPointYInFile;
if (isAnchorPointYExists != null)
anchorPointYInFile = options["anchorPointY"];
else
anchorPointYInFile = widget.getAnchorPoint().y;
if (isAnchorPointXExists != null || isAnchorPointYExists != null)
widget.setAnchorPoint(cc.p(anchorPointXInFile, anchorPointYInFile));
};
parser.parseChild = function(widget, options, resourcePath){
var children = options["children"];
for (var i = 0; i < children.length; i++) {
var child = this.parseNode(children[i], resourcePath);
if(child){
if(widget instanceof ccui.PageView)
widget.addPage(child);
else {
if(widget instanceof ccui.ListView){
widget.pushBackCustomItem(child);
} else {
if(!(widget instanceof ccui.Layout)) {
if(child.getPositionType() === ccui.Widget.POSITION_PERCENT) {
var position = child.getPositionPercent();
var anchor = widget.getAnchorPoint();
child.setPositionPercent(cc.p(position.x + anchor.x, position.y + anchor.y));
}
var AnchorPointIn = widget.getAnchorPointInPoints();
child.setPosition(cc.p(child.getPositionX() + AnchorPointIn.x, child.getPositionY() + AnchorPointIn.y));
}
widget.addChild(child);
}
}
}
}
};
var getPath = function(res, type, path, cb){
if(path){
if(type === 0)
cb(res + path, type);
else
cb(path, type);
}
};
/**
* Panel parser (UILayout)
*/
parser.LayoutAttributes = function(widget, options, resourcePath){
var w = 0, h = 0;
var adaptScreen = options["adaptScreen"];
if (adaptScreen){
var screenSize = cc.director.getWinSize();
w = screenSize.width;
h = screenSize.height;
}else{
w = options["width"];
h = options["height"];
}
widget.setSize(cc.size(w, h));
widget.setClippingEnabled(options["clipAble"]);
var backGroundScale9Enable = options["backGroundScale9Enable"];
widget.setBackGroundImageScale9Enabled(backGroundScale9Enable);
var cr = options["bgColorR"];
var cg = options["bgColorG"];
var cb = options["bgColorB"];
var scr = options["bgStartColorR"];
var scg = options["bgStartColorG"];
var scb = options["bgStartColorB"];
var ecr = options["bgEndColorR"];
var ecg = options["bgEndColorG"];
var ecb = options["bgEndColorB"];
var bgcv1 = options["vectorX"];
var bgcv2 = options["vectorY"];
widget.setBackGroundColorVector(cc.p(bgcv1, bgcv2));
var co = options["bgColorOpacity"];
var colorType = options["colorType"];
widget.setBackGroundColorType(colorType/*ui.LayoutBackGroundColorType(colorType)*/);
widget.setBackGroundColor(cc.color(scr, scg, scb), cc.color(ecr, ecg, ecb));
widget.setBackGroundColor(cc.color(cr, cg, cb));
widget.setBackGroundColorOpacity(co);
var imageFileNameDic = options["backGroundImageData"];
if(imageFileNameDic){
getPath(resourcePath, imageFileNameDic["resourceType"], imageFileNameDic["path"], function(path, type){
widget.setBackGroundImage(path, type);
});
}
if (backGroundScale9Enable){
var cx = options["capInsetsX"];
var cy = options["capInsetsY"];
var cw = options["capInsetsWidth"];
var ch = options["capInsetsHeight"];
widget.setBackGroundImageCapInsets(cc.rect(cx, cy, cw, ch));
}
if (options["layoutType"])
{
widget.setLayoutType(options["layoutType"]);
}
};
/**
* Button parser (UIButton)
*/
parser.ButtonAttributes = function(widget, options, resourcePath){
var button = widget;
var scale9Enable = options["scale9Enable"];
button.setScale9Enabled(scale9Enable);
var normalDic = options["normalData"];
getPath(resourcePath, normalDic["resourceType"], normalDic["path"], function(path, type){
button.loadTextureNormal(path, type);
});
var pressedDic = options["pressedData"];
getPath(resourcePath, pressedDic["resourceType"], pressedDic["path"], function(path, type){
button.loadTexturePressed(path, type);
});
var disabledDic = options["disabledData"];
getPath(resourcePath, disabledDic["resourceType"], disabledDic["path"], function(path, type){
button.loadTextureDisabled(path, type);
});
if (scale9Enable) {
var cx = options["capInsetsX"];
var cy = options["capInsetsY"];
var cw = options["capInsetsWidth"];
var ch = options["capInsetsHeight"];
button.setCapInsets(cc.rect(cx, cy, cw, ch));
var sw = options["scale9Width"];
var sh = options["scale9Height"];
if (sw != null && sh != null)
button.setSize(cc.size(sw, sh));
}
var text = options["text"];
if (text != null)
button.setTitleText(text);
var cr = options["textColorR"];
var cg = options["textColorG"];
var cb = options["textColorB"];
var cri = cr!==null?options["textColorR"]:255;
var cgi = cg!==null?options["textColorG"]:255;
var cbi = cb!==null?options["textColorB"]:255;
button.setTitleColor(cc.color(cri,cgi,cbi));
var fs = options["fontSize"];
if (fs != null)
button.setTitleFontSize(options["fontSize"]);
var fn = options["fontName"];
if (fn)
button.setTitleFontName(options["fontName"]);
};
/**
* CheckBox parser (UICheckBox)
*/
parser.CheckBoxAttributes = function(widget, options, resourcePath){
//load background image
var backGroundDic = options["backGroundBoxData"];
getPath(resourcePath, backGroundDic["resourceType"], backGroundDic["path"], function(path, type){
widget.loadTextureBackGround(path, type);
});
//load background selected image
var backGroundSelectedDic = options["backGroundBoxSelectedData"];
getPath(
resourcePath,
backGroundSelectedDic["resourceType"] || backGroundDic["resourceType"],
backGroundSelectedDic["path"] || backGroundDic["path"],
function(path, type){
widget.loadTextureBackGroundSelected(path, type);
});
//load frontCross image
var frontCrossDic = options["frontCrossData"];
getPath(resourcePath, frontCrossDic["resourceType"], frontCrossDic["path"], function(path, type){
widget.loadTextureFrontCross(path, type);
});
//load backGroundBoxDisabledData
var backGroundDisabledDic = options["backGroundBoxDisabledData"];
getPath(
resourcePath,
backGroundDisabledDic["resourceType"] || frontCrossDic["resourceType"],
backGroundDisabledDic["path"] || frontCrossDic["path"],
function(path, type){
widget.loadTextureBackGroundDisabled(path, type);
});
///load frontCrossDisabledData
var frontCrossDisabledDic = options["frontCrossDisabledData"];
getPath(resourcePath, frontCrossDisabledDic["resourceType"], frontCrossDisabledDic["path"], function(path, type){
widget.loadTextureFrontCrossDisabled(path, type);
});
if (options["selectedState"])
widget.setSelected(options["selectedState"]);
};
/**
* ImageView parser (UIImageView)
*/
parser.ImageViewAttributes = function(widget, options, resourcePath){
var imageFileNameDic = options["fileNameData"]
getPath(resourcePath, imageFileNameDic["resourceType"], imageFileNameDic["path"], function(path, type){
widget.loadTexture(path, type);
});
var scale9EnableExist = options["scale9Enable"];
var scale9Enable = false;
if (scale9EnableExist){
scale9Enable = options["scale9Enable"];
}
widget.setScale9Enabled(scale9Enable);
if (scale9Enable){
var sw = options["scale9Width"];
var sh = options["scale9Height"];
if (sw && sh)
{
var swf = options["scale9Width"];
var shf = options["scale9Height"];
widget.setSize(cc.size(swf, shf));
}
var cx = options["capInsetsX"];
var cy = options["capInsetsY"];
var cw = options["capInsetsWidth"];
var ch = options["capInsetsHeight"];
widget.setCapInsets(cc.rect(cx, cy, cw, ch));
}
};
/**
* TextAtlas parser (UITextAtlas)
*/
parser.TextAtlasAttributes = function(widget, options, resourcePath){
var sv = options["stringValue"];
var cmf = options["charMapFileData"]; // || options["charMapFile"];
var iw = options["itemWidth"];
var ih = options["itemHeight"];
var scm = options["startCharMap"];
if (sv != null && cmf && iw != null && ih != null && scm != null){
var cmftDic = options["charMapFileData"];
var cmfType = cmftDic["resourceType"];
switch (cmfType){
case 0:
var tp_c = resourcePath;
var cmfPath = cmftDic["path"];
var cmf_tp = tp_c + cmfPath;
widget.setProperty(sv, cmf_tp, iw, ih, scm);
break;
case 1:
cc.log("Wrong res type of LabelAtlas!");
break;
default:
break;
}
}
};
/**
* TextBMFont parser (UITextBMFont)
*/
parser.TextBMFontAttributes = function(widget, options, resourcePath){
var cmftDic = options["fileNameData"];
var cmfType = cmftDic["resourceType"];
switch (cmfType) {
case 0:
var tp_c = resourcePath;
var cmfPath = cmftDic["path"];
var cmf_tp = tp_c + cmfPath;
widget.setFntFile(cmf_tp);
break;
case 1:
cc.log("Wrong res type of LabelAtlas!");
break;
default:
break;
}
var text = options["text"];
widget.setString(text);
};
/**
* Text parser (UIText)
*/
var regTTF = /\.ttf$/;
parser.TextAttributes = function(widget, options, resourcePath){
var touchScaleChangeAble = options["touchScaleEnable"];
widget.setTouchScaleChangeEnabled(touchScaleChangeAble);
var text = options["text"];
widget.setString(text);
var fs = options["fontSize"];
if (fs != null){
widget.setFontSize(options["fontSize"]);
}
var fn = options["fontName"];
if (fn != null){
if(cc.sys.isNative){
if(regTTF.test(fn)){
widget.setFontName(cc.path.join(cc.loader.resPath, resourcePath, fn));
}else{
widget.setFontName(fn);
}
}else{
widget.setFontName(fn.replace(regTTF, ''));
}
}
var aw = options["areaWidth"];
var ah = options["areaHeight"];
if (aw != null && ah != null){
var size = cc.size(options["areaWidth"], options["areaHeight"]);
widget.setTextAreaSize(size);
}
var ha = options["hAlignment"];
if (ha != null){
widget.setTextHorizontalAlignment(options["hAlignment"]);
}
var va = options["vAlignment"];
if (va != null){
widget.setTextVerticalAlignment(options["vAlignment"]);
}
};
/**
* ListView parser (UIListView)
*/
parser.ListViewAttributes = function(widget, options, resoutcePath){
parser.ScrollViewAttributes(widget, options,resoutcePath);
var direction = options["direction"];
widget.setDirection(direction);
var gravity = options["gravity"];
widget.setGravity(gravity);
var itemMargin = options["itemMargin"];
widget.setItemsMargin(itemMargin);
};
/**
* LoadingBar parser (UILoadingBar)
*/
parser.LoadingBarAttributes = function(widget, options, resourcePath){
var imageFileNameDic = options["textureData"];
getPath(resourcePath, imageFileNameDic["resourceType"], imageFileNameDic["path"], function(path, type){
widget.loadTexture(path, type);
});
var scale9Enable = options["scale9Enable"];
widget.setScale9Enabled(scale9Enable);
if (scale9Enable){
var cx = options["capInsetsX"];
var cy = options["capInsetsY"];
var cw = options["capInsetsWidth"];
var ch = options["capInsetsHeight"];
widget.setCapInsets(cc.rect(cx, cy, cw, ch));
var width = options["width"];
var height = options["height"];
widget.setSize(cc.size(width, height));
}
widget.setDirection(options["direction"]);
widget.setPercent(options["percent"]);
};
/**
* PageView parser (UIPageView)
*/
parser.PageViewAttributes = parser.LayoutAttributes;
/**
* ScrollView parser (UIScrollView)
*/
parser.ScrollViewAttributes = function(widget, options, resoutcePath){
parser.LayoutAttributes(widget, options,resoutcePath);
var innerWidth = options["innerWidth"]!=null ? options["innerWidth"] : 200;
var innerHeight = options["innerHeight"]!=null ? options["innerHeight"] : 200;
widget.setInnerContainerSize(cc.size(innerWidth, innerHeight));
var direction = options["direction"]!=null ? options["direction"] : 1;
widget.setDirection(direction);
widget.setBounceEnabled(options["bounceEnable"]);
};
/**
* Slider parser (UISlider)
*/
parser.SliderAttributes = function(widget, options, resourcePath){
var slider = widget;
var barTextureScale9Enable = options["scale9Enable"];
slider.setScale9Enabled(barTextureScale9Enable);
var bt = options["barFileName"];
var barLength = options["length"];
var imageFileNameDic = options["barFileNameData"];
var imageFileType = imageFileNameDic["resourceType"];
var imageFileName = imageFileNameDic["path"];
if(bt != null){
if(barTextureScale9Enable){
getPath(resourcePath, imageFileType, imageFileName, function(path, type){
slider.loadBarTexture(path, type);
});
slider.setSize(cc.size(barLength, slider.getContentSize().height));
}
}else{
getPath(resourcePath, imageFileType, imageFileName, function(path, type){
slider.loadBarTexture(path, type);
});
}
var normalDic = options["ballNormalData"];
getPath(resourcePath, normalDic["resourceType"], normalDic["path"], function(path, type){
slider.loadSlidBallTextureNormal(path, type);
});
var pressedDic = options["ballPressedData"];
getPath(
resourcePath,
pressedDic["resourceType"] || normalDic["resourceType"],
pressedDic["path"] || normalDic["path"],
function(path, type){
slider.loadSlidBallTexturePressed(path, type);
});
var disabledDic = options["ballDisabledData"];
getPath(resourcePath, disabledDic["resourceType"], disabledDic["path"], function(path, type){
slider.loadSlidBallTextureDisabled(path, type);
});
var progressBarDic = options["progressBarData"];
getPath(resourcePath, progressBarDic["resourceType"], progressBarDic["path"], function(path, type){
slider.loadProgressBarTexture(path, type);
});
};
/**
* TextField parser (UITextField)
*/
parser.TextFieldAttributes = function(widget, options, resourcePath){
var ph = options["placeHolder"];
if(ph)
widget.setPlaceHolder(ph);
widget.setString(options["text"]||"");
var fs = options["fontSize1"];
if(fs)
widget.setFontSize(fs);
var fn = options["fontName"];
if (fn != null){
if(cc.sys.isNative){
if(regTTF.test(fn)){
widget.setFontName(cc.path.join(cc.loader.resPath, resourcePath, fn));
}else{
widget.setFontName(fn);
}
}else{
widget.setFontName(fn.replace(regTTF, ''));
}
}
var tsw = options["touchSizeWidth"];
var tsh = options["touchSizeHeight"];
if(tsw!=null && tsh!=null)
widget.setTouchSize(tsw, tsh);
var dw = options["width"];
var dh = options["height"];
if(dw > 0 || dh > 0){
//textField.setSize(cc.size(dw, dh));
}
var maxLengthEnable = options["maxLengthEnable"];
widget.setMaxLengthEnabled(maxLengthEnable);
if(maxLengthEnable){
var maxLength = options["maxLength"];
widget.setMaxLength(maxLength);
}
var passwordEnable = options["passwordEnable"];
widget.setPasswordEnabled(passwordEnable);
if(passwordEnable)
widget.setPasswordStyleText(options["passwordStyleText"]);
var aw = options["areaWidth"];
var ah = options["areaHeight"];
if(aw && ah){
var size = cc.size(aw, ah);
widget.setTextAreaSize(size);
}
var ha = options["hAlignment"];
if(ha)
widget.setTextHorizontalAlignment(ha);
var va = options["vAlignment"];
if(va)
widget.setTextVerticalAlignment(va);
var r = options["colorR"];
var g = options["colorG"];
var b = options["colorB"];
if (r !== undefined && g !== undefined && b !== undefined) {
widget.setTextColor(cc.color(r, g, b));
}
};
var register = [
{name: "Panel", object: ccui.Layout, handle: parser.LayoutAttributes},
{name: "Button", object: ccui.Button, handle: parser.ButtonAttributes},
{name: "CheckBox", object: ccui.CheckBox, handle: parser.CheckBoxAttributes},
{name: "ImageView", object: ccui.ImageView, handle: parser.ImageViewAttributes},
{name: "LabelAtlas", object: ccui.TextAtlas, handle: parser.TextAtlasAttributes},
{name: "LabelBMFont", object: ccui.TextBMFont, handle: parser.TextBMFontAttributes},
{name: "Label", object: ccui.Text, handle: parser.TextAttributes},
{name: "ListView", object: ccui.ListView, handle: parser.ListViewAttributes},
{name: "LoadingBar", object: ccui.LoadingBar, handle: parser.LoadingBarAttributes},
{name: "PageView", object: ccui.PageView, handle: parser.PageViewAttributes},
{name: "ScrollView", object: ccui.ScrollView, handle: parser.ScrollViewAttributes},
{name: "Slider", object: ccui.Slider, handle: parser.SliderAttributes},
{name: "TextField", object: ccui.TextField, handle: parser.TextFieldAttributes}
];
register.forEach(function(item){
parser.registerParser(item.name, function(options, resourcePath){
var widget = new item.object;
var uiOptions = options["options"];
parser.generalAttributes(widget, uiOptions);
item.handle(widget, uiOptions, resourcePath);
parser.colorAttributes(widget, uiOptions);
parser.anchorPointAttributes(widget, uiOptions);
parser.parseChild.call(this, widget, options, resourcePath);
return widget;
});
});
load.registerParser("ccui", "*", parser);
})(ccs._load, ccs._parser);