diff --git a/cocos2d/core/CCScene.js b/cocos2d/core/CCScene.js index 6160bc2003..66c951d44f 100644 --- a/cocos2d/core/CCScene.js +++ b/cocos2d/core/CCScene.js @@ -37,6 +37,7 @@ cc.Scene = cc.Class({ ctor: function () { var sgNode = this._sgNode = new _ccsg.Scene(); + sgNode.retain(); sgNode.setAnchorPoint(0.0, 0.0); this._anchorPoint.x = 0.0; this._anchorPoint.y = 0.0; @@ -49,6 +50,8 @@ cc.Scene = cc.Class({ var children = this._children; var DontDestroy = cc.Object.Flags.DontDestroy; + this._sgNode.release(); + for (var i = 0, len = children.length; i < len; ++i) { var child = children[i]; if (child.isValid) { diff --git a/cocos2d/core/components/CCCanvas.js b/cocos2d/core/components/CCCanvas.js index 43e69bf397..14c5107897 100644 --- a/cocos2d/core/components/CCCanvas.js +++ b/cocos2d/core/components/CCCanvas.js @@ -145,7 +145,7 @@ var Canvas = cc.Class({ if (CC_EDITOR) { cc.engine.on('design-resolution-changed', this._thisOnResized); } - else { + else if (!cc.sys.isNative) { if (cc.sys.isMobile) { window.addEventListener('resize', this._thisOnResized); } @@ -168,7 +168,7 @@ var Canvas = cc.Class({ if (CC_EDITOR) { cc.engine.off('design-resolution-changed', this._thisOnResized); } - else { + else if (!cc.sys.isNative) { if (cc.sys.isMobile) { window.removeEventListener('resize', this._thisOnResized); } diff --git a/cocos2d/core/components/CCComponentInSG.js b/cocos2d/core/components/CCComponentInSG.js index 91ccf7e3bf..211dbb3a56 100644 --- a/cocos2d/core/components/CCComponentInSG.js +++ b/cocos2d/core/components/CCComponentInSG.js @@ -80,6 +80,7 @@ var ComponentInSG = cc.Class({ sgParent.addChild(sgNode); // retain immediately + // will be released in SceneGraphHelper.removeSgNode sgNode.retain(); this._sgNode = sgNode; } diff --git a/cocos2d/core/components/CCSpriteRenderer.js b/cocos2d/core/components/CCSpriteRenderer.js index 9d5232eb6c..1d5466e455 100644 --- a/cocos2d/core/components/CCSpriteRenderer.js +++ b/cocos2d/core/components/CCSpriteRenderer.js @@ -459,18 +459,16 @@ var SpriteRenderer = cc.Class({ } }, - _applySprite: function (node, oldSprite) { - if (oldSprite) { + _applySprite: function (sgNode, oldSprite) { + if (oldSprite && oldSprite.off) { oldSprite.off('load', this._applyCapInset, this); } if (!this._sprite) { return; } - node._spriteRect = cc.rect(0, 0); - node._originalSize = cc.size(0, 0); - node.initWithSpriteFrame(this._sprite); + sgNode.initWithSpriteFrame(this._sprite, cc.rect(0, 0, 0, 0)); var locLoaded = this._sprite.textureLoaded(); if (!locLoaded) { if ( !this._useOriginalSize ) { - node.setPreferredSize(this.node.getContentSize(true)); + sgNode.setPreferredSize(this.node.getContentSize(true)); } this._sprite.once('load', function () { this._applyCapInset(); @@ -478,8 +476,8 @@ var SpriteRenderer = cc.Class({ }, this); } else { - this._applyCapInset(node); - this._applySpriteSize(node); + this._applyCapInset(sgNode); + this._applySpriteSize(sgNode); } }, diff --git a/cocos2d/core/platform/CCAssetLibrary.js b/cocos2d/core/platform/CCAssetLibrary.js index 3be5c8113d..8907d96766 100644 --- a/cocos2d/core/platform/CCAssetLibrary.js +++ b/cocos2d/core/platform/CCAssetLibrary.js @@ -356,7 +356,7 @@ var AssetLibrary = { */ // load depends assets - for (var i = 0, len = _tdInfo.uuidList.length; i < len; i++) { + for (var i = 0; i < _tdInfo.uuidList.length; i++) { var dependsUuid = _tdInfo.uuidList[i]; (function (dependsUuid, obj, prop) { AssetLibrary.queryAssetInfo(dependsUuid, function (err, dependsUrl, isRawAsset) { diff --git a/cocos2d/core/platform/deserialize.js b/cocos2d/core/platform/deserialize.js index 79b36b30b3..0d605f6422 100644 --- a/cocos2d/core/platform/deserialize.js +++ b/cocos2d/core/platform/deserialize.js @@ -414,6 +414,10 @@ var _Deserializer = (function () { else { // instantiate a new object obj = new klass(); + // Temporary solution + if (cc.sys.isNative && klass === cc.SpriteFrame) { + obj.retain(); + } } if (obj._deserialize) { diff --git a/cocos2d/core/utils/base-node.js b/cocos2d/core/utils/base-node.js index c951d0bdc9..17f363becd 100644 --- a/cocos2d/core/utils/base-node.js +++ b/cocos2d/core/utils/base-node.js @@ -24,7 +24,6 @@ var JS = cc.js; var SceneGraphHelper = require('./scene-graph-helper'); -var SGProto = _ccsg.Node.prototype; var Destroying = require('../platform/CCObject').Flags.Destroying; var DirtyFlags = require('./misc').DirtyFlags; @@ -176,7 +175,9 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{ * @type {Number} */ skewX: { - get: SGProto.getSkewX, + get: function () { + return this._skewX; + }, set: function (value) { this._skewX = value; this._sgNode.skewX = value; @@ -189,10 +190,12 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{ * @type {Number} */ skewY: { - get: SGProto.getSkewY, + get: function () { + return this._skewY; + }, set: function (value) { this._skewY = value; - this._sgNode._skewY = value; + this._sgNode.skewY = value; } }, @@ -202,7 +205,9 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{ * @type {Number} */ zIndex: { - get: SGProto.getLocalZOrder, + get: function () { + return this._localZOrder; + }, set: function (value) { this._localZOrder = value; this._sgNode.zIndex = value; @@ -215,7 +220,11 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{ * @type {Number} */ rotation: { - get: SGProto.getRotation, + get: function () { + if (this._rotationX !== this._rotationY) + cc.log(cc._LogInfos.Node.getRotation); + return this._rotationX; + }, set: function (value) { this._rotationX = this._rotationY = value; this._sgNode.rotation = value; @@ -229,7 +238,9 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{ * @type {Number} */ rotationX: { - get: SGProto.getRotationX, + get: function () { + return this._rotationX; + }, set: function (value) { this._rotationX = value; this._sgNode.rotationX = value; @@ -242,7 +253,9 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{ * @type {Number} */ rotationY: { - get: SGProto.getRotationY, + get: function () { + return this._rotationY; + }, set: function (value) { this._rotationY = value; this._sgNode.rotationY = value; @@ -255,7 +268,9 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{ * @type {Number} */ scaleX: { - get: SGProto.getScaleX, + get: function () { + return this._scaleX; + }, set: function (value) { this._scaleX = value; this._sgNode.scaleX = value; @@ -268,7 +283,9 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{ * @type {Number} */ scaleY: { - get: SGProto.getScaleY, + get: function () { + return this._scaleY; + }, set: function (value) { this._scaleY = value; this._sgNode.scaleY = value; @@ -281,7 +298,9 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{ * @type {Number} */ x: { - get: SGProto.getPositionX, + get: function () { + return this._position.x; + }, set: function (value) { this._position.x = value; this._sgNode.x = value; @@ -294,7 +313,9 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{ * @type {Number} */ y: { - get: SGProto.getPositionY, + get: function () { + return this._position.y; + }, set: function (value) { this._position.y = value; this._sgNode.y = value; @@ -331,7 +352,9 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{ * @type {Number} */ anchorX: { - get: SGProto._getAnchorX, + get: function () { + return this._anchorPoint.x; + }, set: function (value) { this._anchorPoint.x = value; this._onAnchorChanged(); @@ -344,7 +367,9 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{ * @type {Number} */ anchorY: { - get: SGProto._getAnchorY, + get: function () { + return this._anchorPoint.y; + }, set: function (value) { this._anchorPoint.y = value; this._onAnchorChanged(); @@ -370,7 +395,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{ set: function (value) { if (value !== this._contentSize.width) { if (this._sizeProvider) { - this._sizeProvider.setContentSize(new cc.Size(value, this._sizeProvider._getHeight())); + this._sizeProvider.setContentSize(value, this._sizeProvider._getHeight()); } this._contentSize.width = value; this.emit(SIZE_CHANGED); @@ -397,7 +422,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{ set: function (value) { if (value !== this._contentSize.height) { if (this._sizeProvider) { - this._sizeProvider.setContentSize(new cc.Size(this._sizeProvider._getWidth(), value)); + this._sizeProvider.setContentSize(this._sizeProvider._getWidth(), value); } this._contentSize.height = value; this.emit(SIZE_CHANGED); @@ -406,7 +431,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{ }, //running: { - // get: SGProto.isRunning + // get: //}, /** @@ -415,7 +440,9 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{ * @type {Boolean} */ ignoreAnchor: { - get: SGProto.isIgnoreAnchorPointForPosition, + get: function () { + return this._ignoreAnchorPointForPosition; + }, set: function (value) { this._ignoreAnchorPointForPosition = value; this._sgNode.ignoreAnchor = value; @@ -461,7 +488,9 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{ * @type {Boolean} */ cascadeOpacity: { - get: SGProto.isCascadeOpacityEnabled, + get: function () { + return this._cascadeOpacityEnabled; + }, set: function (value) { if (this._cascadeOpacityEnabled !== value) { this._cascadeOpacityEnabled = value; @@ -503,6 +532,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{ }); var sgNode = this._sgNode = new _ccsg.Node(); + sgNode.retain(); if (!cc.game._isCloning) { sgNode.cascadeOpacity = true; } @@ -519,6 +549,11 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{ this._sizeProvider = null; }, + destroy: function () { + this._sgNode.release(); + this._super(); + }, + // ABSTRACT INTERFACES // called when the node's parent changed @@ -552,12 +587,10 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{ * @method attr * @param {Object} attrs - Properties to be set to node */ - attr: SGProto.attr, - - //Helper function used by `setLocalZOrder`. Don't use it unless you know what you are doing. - _setLocalZOrder: function (localZOrder) { - this._localZOrder = localZOrder; - this._sgNode._localZOrder = localZOrder; + attr: function (attrs) { + for (var key in attrs) { + this[key] = attrs[key]; + } }, /** @@ -586,7 +619,9 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{ * @method getGlobalZOrder * @returns {number} The node's global Z order */ - getGlobalZOrder: SGProto.getGlobalZOrder, + getGlobalZOrder: function () { + return this._globalZOrder; + }, /** * Returns the scale factor of the node. @@ -594,7 +629,11 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{ * @method getScale * @return {Number} The scale factor */ - getScale: SGProto.getScale, + getScale: function () { + if (this._scaleX !== this._scaleY) + cc.log(cc._LogInfos.Node.getScale); + return this._scaleX; + }, /** * Sets the scale factor of the node. 1.0 is the default scale factor. This function can modify the X and Y scale at the same time. @@ -618,7 +657,9 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{ * @method getPosition * @return {Vec2} The position (x,y) of the node in OpenGL coordinates */ - getPosition: SGProto.getPosition, + getPosition: function () { + return cc.p(this._position); + }, /** *
@@ -658,7 +699,9 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{ * @method getAnchorPoint * @return {Vec2} The anchor point of node. */ - getAnchorPoint: SGProto.getAnchorPoint, + getAnchorPoint: function () { + return cc.p(this._anchorPoint); + }, /** *
@@ -773,7 +816,12 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
//cc.eventManager.removeListeners(this);
// children
- SGProto._arrayMakeObjectsPerformSelector(this._children, _ccsg.Node._stateCallbackType.cleanup);
+ var i, len = this._children.length, node;
+ for (i = 0; i < len; ++i) {
+ node = this._children[i];
+ if (node)
+ node.cleanup();
+ }
},
// composition: GET
@@ -784,7 +832,17 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
* @param {Number} aTag - An identifier to find the child node.
* @return {Node} a CCNode object whose tag equals to the input parameter
*/
- getChildByTag: SGProto.getChildByTag,
+ getChildByTag: function (aTag) {
+ var children = this._children;
+ if (children !== null) {
+ for (var i = 0; i < children.length; i++) {
+ var node = children[i];
+ if (node && node.tag === aTag)
+ return node;
+ }
+ }
+ return null;
+ },
/**
* Returns a child from the container given its name
@@ -792,7 +850,19 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
* @param {String} name - A name to find the child node.
* @return {Node} a CCNode object whose name equals to the input parameter
*/
- getChildByName: SGProto.getChildByName,
+ getChildByName: function(name){
+ if(!name){
+ cc.log("Invalid name");
+ return null;
+ }
+
+ var locChildren = this._children;
+ for(var i = 0, len = locChildren.length; i < len; i++){
+ if(locChildren[i]._name === name)
+ return locChildren[i];
+ }
+ return null;
+ },
// composition: ADD
@@ -1015,9 +1085,9 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
return this._sgNode.convertToWorldSpaceAR(nodePoint);
},
- _convertToWindowSpace: function (nodePoint) {
- return this._sgNode._convertToWindowSpace(nodePoint);
- },
+ // _convertToWindowSpace: function (nodePoint) {
+ // return this._sgNode._convertToWindowSpace(nodePoint);
+ // },
/**
* convenience methods which take a cc.Touch instead of cc.Vec2
@@ -1058,10 +1128,6 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
return this._sgNode.getBoundingBoxToWorld();
},
- _getBoundingBoxToCurrentNode: function (parentTransform) {
- return this._sgNode._getBoundingBoxToCurrentNode(parentTransform);
- },
-
/**
* Returns the displayed opacity of Node,
* the difference between displayed opacity and opacity is that displayed opacity is calculated based on opacity and parent node's opacity when cascade opacity enabled.
@@ -1091,15 +1157,6 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
return this._sgNode.getDisplayedColor();
},
- /**
- * Update the displayed color of Node
- * @method
- * @param {Color} parentColor
- */
- _updateDisplayedColor: function (parentColor) {
- this._sgNode._updateDisplayedColor(parentColor);
- },
-
/**
* Set whether color should be changed with the opacity value,
* useless in ccsg.Node, but this function is override in some class to have such behavior.
diff --git a/cocos2d/core/utils/scene-graph-helper.js b/cocos2d/core/utils/scene-graph-helper.js
index 592517e1d2..fbdfdeb11e 100644
--- a/cocos2d/core/utils/scene-graph-helper.js
+++ b/cocos2d/core/utils/scene-graph-helper.js
@@ -5,6 +5,7 @@ var SceneGraphUtils = {
removeSgNode: function () {
var node = this._sgNode;
if (node) {
+ node.release();
if (node._parent) {
node._parent.removeChild(node);
}
diff --git a/gulpfile.js b/gulpfile.js
index d07147dcb6..c5d310c741 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -20,7 +20,9 @@ paths = {
JSBSkipModules: [
'../../cocos2d/core/CCGame',
'../../cocos2d/core/textures/CCTexture2D',
- '../../cocos2d/core/sprites/CCSpriteFrame'
+ '../../cocos2d/core/sprites/CCSpriteFrame',
+ '../../cocos2d/core/platform/CCLoader',
+ '../../cocos2d/core/platform/CCLoaders'
],
test: {
diff --git a/jsb_polyfill.js b/jsb_polyfill.js
new file mode 100644
index 0000000000..f6ec83772b
--- /dev/null
+++ b/jsb_polyfill.js
@@ -0,0 +1,389 @@
+'use strict';
+
+cc.ParticleSystem.Mode = cc.Enum({
+ /** The gravity mode (A mode) */
+ GRAVITY: 0,
+ /** The radius mode (B mode) */
+ RADIUS: 1
+});
+
+cc.ParticleSystem.Type = cc.Enum({
+ /**
+ * Living particles are attached to the world and are unaffected by emitter repositioning.
+ */
+ FREE: 0,
+
+ /**
+ * Living particles are attached to the world but will follow the emitter repositioning.
+ * Use case: Attach an emitter to an sprite, and you want that the emitter follows the sprite.
+ */
+ RELATIVE: 1,
+
+ /**
+ * Living particles are attached to the emitter and are translated along with it.
+ */
+ GROUPED: 2
+});
+
+cc.ProgressTimer.Type = cc.Enum({
+ /**
+ * Radial Counter-Clockwise
+ */
+ RADIAL: 0,
+ BAR: 1
+});
+
+
+cc.EditBox.InputMode = cc.Enum({
+
+ ANY: 0,
+
+ /**
+ * The user is allowed to enter an e-mail address.
+ */
+ EMAILADDR: 1,
+
+ /**
+ * The user is allowed to enter an integer value.
+ */
+ NUMERIC: 2,
+
+ /**
+ * The user is allowed to enter a phone number.
+ */
+ PHONENUMBER: 3,
+
+ /**
+ * The user is allowed to enter a URL.
+ */
+ URL: 4,
+
+ /**
+ * The user is allowed to enter a real number value.
+ * This extends kEditBoxInputModeNumeric by allowing a decimal point.
+ */
+ DECIMAL: 5,
+
+ /**
+ * The user is allowed to enter any text, except for line breaks.
+ */
+ SINGLELINE: 6
+});
+
+/**
+ * Enum for the EditBox's input flags
+ * @readonly
+ * @enum {number}
+ * @memberof cc.EditBox
+ */
+cc.EditBox.InputFlag = cc.Enum({
+ /**
+ * Indicates that the text entered is confidential data that should be
+ * obscured whenever possible. This implies EDIT_BOX_INPUT_FLAG_SENSITIVE.
+ */
+ PASSWORD: 0,
+
+ /**
+ * Indicates that the text entered is sensitive data that the
+ * implementation must never store into a dictionary or table for use
+ * in predictive, auto-completing, or other accelerated input schemes.
+ * A credit card number is an example of sensitive data.
+ */
+ SENSITIVE: 1,
+
+ /**
+ * This flag is a hint to the implementation that during text editing,
+ * the initial letter of each word should be capitalized.
+ */
+ INITIAL_CAPS_WORD: 2,
+
+ /**
+ * This flag is a hint to the implementation that during text editing,
+ * the initial letter of each sentence should be capitalized.
+ */
+ INITIAL_CAPS_SENTENCE: 3,
+
+ /**
+ * Capitalize all characters automatically.
+ */
+ INITIAL_CAPS_ALL_CHARACTERS: 4
+});
+
+/**
+ * Enum for keyboard return types
+ * @readonly
+ * @enum {number}
+ */
+cc.KeyboardReturnType = cc.Enum({
+ DEFAULT: 0,
+ DONE: 1,
+ SEND: 2,
+ SEARCH: 3,
+ GO: 4
+});
+
+/**
+ * Enum for text alignment
+ * @readonly
+ * @enum {number}
+ */
+cc.TextAlignment = cc.Enum({
+ LEFT: 0,
+ CENTER: 1,
+ RIGHT: 2
+});
+
+/**
+ * Enum for vertical text alignment
+ * @readonly
+ * @enum {number}
+ */
+cc.VerticalTextAlignment = cc.Enum({
+ TOP: 0,
+ CENTER: 1,
+ BOTTOM: 2
+});
+
+/**
+ * Enum for Relative layout parameter RelativeAlign
+ * @readonly
+ * @enum {number}
+ */
+ccui.RelativeLayoutParameter.Type = cc.Enum({
+ /**
+ * The none of ccui.RelativeLayoutParameter's relative align.
+ */
+ NONE: 0,
+ /**
+ * The parent's top left of ccui.RelativeLayoutParameter's relative align.
+ */
+ PARENT_TOP_LEFT: 1,
+ /**
+ * The parent's top center horizontal of ccui.RelativeLayoutParameter's relative align.
+ */
+ PARENT_TOP_CENTER_HORIZONTAL: 2,
+ /**
+ * The parent's top right of ccui.RelativeLayoutParameter's relative align.
+ */
+ PARENT_TOP_RIGHT: 3,
+ /**
+ * The parent's left center vertical of ccui.RelativeLayoutParameter's relative align.
+ */
+ PARENT_LEFT_CENTER_VERTICAL: 4,
+
+ /**
+ * The center in parent of ccui.RelativeLayoutParameter's relative align.
+ */
+ CENTER_IN_PARENT: 5,
+
+ /**
+ * The parent's right center vertical of ccui.RelativeLayoutParameter's relative align.
+ */
+ PARENT_RIGHT_CENTER_VERTICAL: 6,
+ /**
+ * The parent's left bottom of ccui.RelativeLayoutParameter's relative align.
+ */
+ PARENT_LEFT_BOTTOM: 7,
+ /**
+ * The parent's bottom center horizontal of ccui.RelativeLayoutParameter's relative align.
+ */
+ PARENT_BOTTOM_CENTER_HORIZONTAL: 8,
+ /**
+ * The parent's right bottom of ccui.RelativeLayoutParameter's relative align.
+ */
+ PARENT_RIGHT_BOTTOM: 9,
+
+ /**
+ * The location above left align of ccui.RelativeLayoutParameter's relative align.
+ */
+ LOCATION_ABOVE_LEFTALIGN: 10,
+ /**
+ * The location above center of ccui.RelativeLayoutParameter's relative align.
+ */
+ LOCATION_ABOVE_CENTER: 11,
+ /**
+ * The location above right align of ccui.RelativeLayoutParameter's relative align.
+ */
+ LOCATION_ABOVE_RIGHTALIGN: 12,
+ /**
+ * The location left of top align of ccui.RelativeLayoutParameter's relative align.
+ */
+ LOCATION_LEFT_OF_TOPALIGN: 13,
+ /**
+ * The location left of center of ccui.RelativeLayoutParameter's relative align.
+ */
+ LOCATION_LEFT_OF_CENTER: 14,
+ /**
+ * The location left of bottom align of ccui.RelativeLayoutParameter's relative align.
+ */
+ LOCATION_LEFT_OF_BOTTOMALIGN: 15,
+ /**
+ * The location right of top align of ccui.RelativeLayoutParameter's relative align.
+ */
+ LOCATION_RIGHT_OF_TOPALIGN: 16,
+ /**
+ * The location right of center of ccui.RelativeLayoutParameter's relative align.
+ */
+ LOCATION_RIGHT_OF_CENTER: 17,
+ /**
+ * The location right of bottom align of ccui.RelativeLayoutParameter's relative align.
+ */
+ LOCATION_RIGHT_OF_BOTTOMALIGN: 18,
+ /**
+ * The location below left align of ccui.RelativeLayoutParameter's relative align.
+ */
+ LOCATION_BELOW_LEFTALIGN: 19,
+ /**
+ * The location below center of ccui.RelativeLayoutParameter's relative align.
+ */
+ LOCATION_BELOW_CENTER: 20,
+ /**
+ * The location below right align of ccui.RelativeLayoutParameter's relative align.
+ */
+ LOCATION_BELOW_RIGHTALIGN: 21
+});
+
+
+/**
+ * Enum for layout type
+ * @readonly
+ * @enum {number}
+ */
+ccui.Layout.Type = cc.Enum({
+ /**
+ * The absolute of ccui.Layout's layout type.
+ */
+ ABSOLUTE: 0,
+ /**
+ * The vertical of ccui.Layout's layout type.
+ */
+ LINEAR_VERTICAL: 1,
+ /**
+ * The horizontal of ccui.Layout's layout type.
+ */
+ LINEAR_HORIZONTAL: 2,
+ /**
+ * The relative of ccui.Layout's layout type.
+ */
+ RELATIVE: 3
+});
+
+/**
+ * Enum for loadingBar Type
+ * @readonly
+ * @enum {number}
+ */
+ccui.LoadingBar.Type = cc.Enum({
+ /**
+ * The left direction of ccui.LoadingBar.
+ */
+ LEFT: 0,
+ /**
+ * The right direction of ccui.LoadingBar.
+ */
+ RIGHT: 1
+});
+
+/**
+ * Enum for ScrollView direction
+ * @readonly
+ * @enum {number}
+ */
+ccui.ScrollView.Dir = cc.Enum({
+ /**
+ * The none flag of ccui.ScrollView's direction.
+ */
+ NONE: 0,
+ /**
+ * The vertical flag of ccui.ScrollView's direction.
+ */
+ VERTICAL: 1,
+ /**
+ * The horizontal flag of ccui.ScrollView's direction.
+ */
+ HORIZONTAL: 2,
+ /**
+ * The both flag of ccui.ScrollView's direction.
+ */
+ BOTH: 3
+});
+
+
+
+cc.js.mixin(cc.path, {
+ //todo make public after verification
+ _normalize: function(url){
+ var oldUrl = url = String(url);
+
+ //removing all ../
+ do {
+ oldUrl = url;
+ url = url.replace(this.normalizeRE, '');
+ } while(oldUrl.length !== url.length);
+ return url;
+ },
+
+ // The platform-specific file separator. '\\' or '/'.
+ sep: (cc.sys.os === cc.sys.OS_WINDOWS ? '\\' : '/'),
+
+ // @param {string} path
+ // @param {boolean|string} [endsWithSep = true]
+ // @returns {string}
+ _setEndWithSep: function (path, endsWithSep) {
+ var sep = cc.path.sep;
+ if (typeof endsWithSep === 'undefined') {
+ endsWithSep = true;
+ }
+ else if (typeof endsWithSep === 'string') {
+ sep = endsWithSep;
+ endsWithSep = !!endsWithSep;
+ }
+
+ var endChar = path[path.length - 1];
+ var oldEndWithSep = (endChar === '\\' || endChar === '/');
+ if (!oldEndWithSep && endsWithSep) {
+ path += sep;
+ }
+ else if (oldEndWithSep && !endsWithSep) {
+ path = path.slice(0, -1);
+ }
+ return path;
+ }
+});
+
+cc.EventTarget.call(cc.game);
+cc.js.addon(cc.game, cc.EventTarget.prototype);
+cc.EventTarget.call(cc.director);
+cc.js.addon(cc.director, cc.EventTarget.prototype);
+
+// cc.Label
+cc._Label = cc.Label;
+cc.Label = function (string, fontHandle, type) {
+ var label;
+ if (type === cc.Label.Type.TTF) {
+ label = cc._Label.createWithSystemFont(string, fontHandle, 40);
+ }
+ else if (type === cc.Label.Type.BMFont) {
+ label = cc._Label.createWithBMFont(fontHandle, string);
+ }
+ return label;
+};
+cc.Label.Type = cc.Enum({
+ TTF: 0,
+ BMFont: 1
+});
+cc.Label.Overflow = cc.Enum({
+ CLAMP: 0,
+ SHRINK: 1,
+ RESIZE: 2
+});
+
+
+// Assets
+cc.js.setClassName('cc.SpriteFrame', cc.SpriteFrame);
+
+// ccsg
+window._ccsg = {
+ Node: cc.Node,
+ Scene: cc.Scene
+};