diff --git a/CCBoot.js b/CCBoot.js
index 1b3eaaf497..e5af2c5291 100644
--- a/CCBoot.js
+++ b/CCBoot.js
@@ -58,7 +58,7 @@ _p = null;
* @name cc.ENGINE_VERSION
*/
var engineVersion;
-engineVersion = '1.2.0-rc.2';
+engineVersion = '1.2.1-beta.4';
window['CocosEngine'] = cc.ENGINE_VERSION = engineVersion;
/**
diff --git a/CCDebugger.js b/CCDebugger.js
index 62c1669203..73f672db61 100644
--- a/CCDebugger.js
+++ b/CCDebugger.js
@@ -451,8 +451,8 @@ cc._initDebugSetting = function (mode) {
* - 在 Chrome 中,错误信息有红色的图标以及红色的消息文本。
*
* @method error
- * @param {Any} obj - A JavaScript string containing zero or more substitution strings.
- * @param {Any} ...subst - JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
+ * @param {any} obj - A JavaScript string containing zero or more substitution strings.
+ * @param {any} ...subst - JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
*/
if (CC_EDITOR) {
cc.error = Editor.error;
@@ -484,8 +484,8 @@ cc._initDebugSetting = function (mode) {
* - 在 Cocos Creator 中,警告信息显示是黄色的。
* - 在 Chrome 中,警告信息有着黄色的图标以及黄色的消息文本。
* @method warn
- * @param {Any} obj - A JavaScript string containing zero or more substitution strings.
- * @param {Any} ...subst - JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
+ * @param {any} obj - A JavaScript string containing zero or more substitution strings.
+ * @param {any} ...subst - JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
*/
if (CC_EDITOR) {
cc.warn = Editor.warn;
@@ -509,8 +509,8 @@ cc._initDebugSetting = function (mode) {
* !#en Outputs a message to the Cocos Creator Console (editor) or Web Console (runtime).
* !#zh 输出一条消息到 Cocos Creator 编辑器的 Console 或运行时 Web 端的 Console 中。
* @method log
- * @param {Any} obj - A JavaScript string containing zero or more substitution strings.
- * @param {Any} ...subst - JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
+ * @param {any} obj - A JavaScript string containing zero or more substitution strings.
+ * @param {any} ...subst - JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
*/
if (CC_JSB) {
cc.log = jsbLog;
@@ -543,7 +543,13 @@ cc._initDebugSetting = function (mode) {
}
}
cc._throw = CC_EDITOR ? Editor.error : function (error) {
- cc.error(error.stack || error);
+ var stack = error.stack;
+ if (stack) {
+ cc.error(CC_JSB ? (error + '\n' + stack) : stack);
+ }
+ else {
+ cc.error(error);
+ }
};
};
//+++++++++++++++++++++++++something about log end+++++++++++++++++++++++++++++
diff --git a/cocos2d/actions/CCActionCatmullRom.js b/cocos2d/actions/CCActionCatmullRom.js
index 123f62a528..22ea1adff3 100644
--- a/cocos2d/actions/CCActionCatmullRom.js
+++ b/cocos2d/actions/CCActionCatmullRom.js
@@ -69,36 +69,6 @@ cc.cardinalSplineAt = function (p0, p1, p2, p3, tension, t) {
return cc.p(x, y);
};
-/*
- * returns a new copy of the array reversed.
- * @method reverseControlPoints
- * @param {Array} controlPoints
- * @return {Array}
- */
-cc.reverseControlPoints = function (controlPoints) {
- var newArray = [];
- for (var i = controlPoints.length - 1; i >= 0; i--) {
- newArray.push(cc.p(controlPoints[i].x, controlPoints[i].y));
- }
- return newArray;
-};
-
-
-/*
- * returns a new clone of the controlPoints
- * @method cloneControlPoints
- * @param {Array} controlPoints
- * @returns {Array}
- */
-cc.cloneControlPoints = function (controlPoints) {
- var newArray = [];
- for (var i = 0; i < controlPoints.length; i++)
- newArray.push(cc.p(controlPoints[i].x, controlPoints[i].y));
- return newArray;
-};
-
-cc.copyControlPoints = cc.cloneControlPoints;
-
/*
* returns a point from the array
* @method getControlPointAt
@@ -111,20 +81,20 @@ cc.getControlPointAt = function (controlPoints, pos) {
return controlPoints[p];
};
-/*
- * reverse the current control point array inline, without generating a new one
- * @method reverseControlPointsInline
- * @param {Array} controlPoints
- */
-cc.reverseControlPointsInline = function (controlPoints) {
- var len = controlPoints.length;
- var mid = 0 | (len / 2);
- for (var i = 0; i < mid; ++i) {
- var temp = controlPoints[i];
- controlPoints[i] = controlPoints[len - i - 1];
- controlPoints[len - i - 1] = temp;
+function reverseControlPoints (controlPoints) {
+ var newArray = [];
+ for (var i = controlPoints.length - 1; i >= 0; i--) {
+ newArray.push(cc.p(controlPoints[i].x, controlPoints[i].y));
}
-};
+ return newArray;
+}
+
+function cloneControlPoints (controlPoints) {
+ var newArray = [];
+ for (var i = 0; i < controlPoints.length; i++)
+ newArray.push(cc.p(controlPoints[i].x, controlPoints[i].y));
+ return newArray;
+}
/*
@@ -157,15 +127,6 @@ cc.CardinalSplineTo = cc.ActionInterval.extend({
tension !== undefined && this.initWithDuration(duration, points, tension);
},
- /*
- * initializes the action with a duration and an array of points
- * @method initWithDuration
- * @param {Number} duration
- * @param {Array} points array of control points
- * @param {Number} tension
- *
- * @return {Boolean}
- */
initWithDuration:function (duration, points, tension) {
if(!points || points.length === 0)
throw new Error("Invalid configuration. It must at least have one control point");
@@ -180,7 +141,7 @@ cc.CardinalSplineTo = cc.ActionInterval.extend({
clone:function () {
var action = new cc.CardinalSplineTo();
- action.initWithDuration(this._duration, cc.copyControlPoints(this._points), this._tension);
+ action.initWithDuration(this._duration, cloneControlPoints(this._points), this._tension);
return action;
},
@@ -234,7 +195,7 @@ cc.CardinalSplineTo = cc.ActionInterval.extend({
},
reverse:function () {
- var reversePoints = cc.reverseControlPoints(this._points);
+ var reversePoints = reverseControlPoints(this._points);
return cc.cardinalSplineTo(this._duration, reversePoints, this._tension);
},
@@ -257,7 +218,7 @@ cc.CardinalSplineTo = cc.ActionInterval.extend({
return this._points;
},
- /*
+ /**
* Points setter
* @method setPoints
* @param {Array} points
@@ -329,7 +290,7 @@ cc.CardinalSplineBy = cc.CardinalSplineTo.extend({
}
// convert to "diffs" to "reverse absolute"
- var reverseArray = cc.reverseControlPoints(copyConfig);
+ var reverseArray = reverseControlPoints(copyConfig);
// 1st element (which should be 0,0) should be here too
p = reverseArray[ reverseArray.length - 1 ];
@@ -351,7 +312,7 @@ cc.CardinalSplineBy = cc.CardinalSplineTo.extend({
return cc.cardinalSplineBy(this._duration, reverseArray, this._tension);
},
- /*
+ /**
* update position of target
* @method updatePosition
* @param {Vec2} newPos
@@ -365,14 +326,9 @@ cc.CardinalSplineBy = cc.CardinalSplineTo.extend({
this.target.setPosition(posX, posY);
},
- /*
- * returns a new clone of the action
- * @method clone
- * @returns {CardinalSplineBy}
- */
clone:function () {
var a = new cc.CardinalSplineBy();
- a.initWithDuration(this._duration, cc.copyControlPoints(this._points), this._tension);
+ a.initWithDuration(this._duration, cloneControlPoints(this._points), this._tension);
return a;
}
});
@@ -412,19 +368,13 @@ cc.CatmullRomTo = cc.CardinalSplineTo.extend({
points && this.initWithDuration(dt, points);
},
- /*
- * Initializes the action with a duration and an array of points
- * @method initWithDuration
- * @param {Number} dt
- * @param {Array} points
- */
initWithDuration:function (dt, points) {
return cc.CardinalSplineTo.prototype.initWithDuration.call(this, dt, points, 0.5);
},
clone:function () {
var action = new cc.CatmullRomTo();
- action.initWithDuration(this._duration, cc.copyControlPoints(this._points));
+ action.initWithDuration(this._duration, cloneControlPoints(this._points));
return action;
}
});
@@ -466,20 +416,13 @@ cc.CatmullRomBy = cc.CardinalSplineBy.extend({
points && this.initWithDuration(dt, points);
},
- /*
- * initializes the action with a duration and an array of points
- *
- * @method initWithDuration
- * @param {Number} dt
- * @param {Array} points
- */
initWithDuration:function (dt, points) {
return cc.CardinalSplineTo.prototype.initWithDuration.call(this, dt, points, 0.5);
},
clone:function () {
var action = new cc.CatmullRomBy();
- action.initWithDuration(this._duration, cc.copyControlPoints(this._points));
+ action.initWithDuration(this._duration, cloneControlPoints(this._points));
return action;
}
});
diff --git a/cocos2d/actions/CCActionTween.js b/cocos2d/actions/CCActionTween.js
deleted file mode 100644
index 530d4b091f..0000000000
--- a/cocos2d/actions/CCActionTween.js
+++ /dev/null
@@ -1,166 +0,0 @@
-/****************************************************************************
- Copyright (c) 2008-2010 Ricardo Quesada
- Copyright (c) 2011-2012 cocos2d-x.org
- Copyright (c) 2013-2014 Chukong Technologies Inc.
-
- http://www.cocos2d-x.org
-
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
-
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
- ****************************************************************************/
-
-/**
- *
- * @class ActionTweenDelegate
- * @extends _Class
- */
-cc.ActionTweenDelegate = cc._Class.extend(/** @lends cc.ActionTweenDelegate */{
-
- /**
- * Update Tween Action.
- * @param value
- * @param key
- */
- updateTweenAction:function(value, key){}
-});
-
-/**
- * cc.ActionTween
- * cc.ActionTween is an action that lets you update any property of an object.
- *
- * @class
- * @extends ActionInterval
- * @example
- * //For example, if you want to modify the "width" property of a target from 200 to 300 in 2 seconds, then:
- * var modifyWidth = cc.actionTween(2,"width",200,300)
- * target.runAction(modifyWidth);
- *
- * //Another example: cc.ScaleTo action could be rewriten using cc.PropertyAction:
- * // scaleA and scaleB are equivalents
- * var scaleA = cc.scaleTo(2,3);
- * var scaleB = cc.actionTween(2,"scale",1,3);
- * @param {Number} duration
- * @param {String} key
- * @param {Number} from
- * @param {Number} to
- */
-cc.ActionTween = cc.ActionInterval.extend(/** @lends cc.ActionTween */{
- key:"",
- from:0,
- to:0,
- delta:0,
-
- /**
- * Constructor function, override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
- * Creates an initializes the action with the property name (key), and the from and to parameters.
- * @param {Number} duration
- * @param {String} key
- * @param {Number} from
- * @param {Number} to
- */
- ctor:function(duration, key, from, to){
- cc.ActionInterval.prototype.ctor.call(this);
- this.key = "";
-
- to !== undefined && this.initWithDuration(duration, key, from, to);
- },
-
- /**
- * initializes the action with the property name (key), and the from and to parameters.
- * @param {Number} duration
- * @param {String} key
- * @param {Number} from
- * @param {Number} to
- * @return {Boolean}
- */
- initWithDuration:function (duration, key, from, to) {
- if (cc.ActionInterval.prototype.initWithDuration.call(this, duration)) {
- this.key = key;
- this.to = to;
- this.from = from;
- return true;
- }
- return false;
- },
-
- /**
- * Start this tween with target.
- * @param {ActionTweenDelegate} target
- */
- startWithTarget:function (target) {
- if(!target || !target.updateTweenAction)
- throw new Error("cc.ActionTween.startWithTarget(): target must be non-null, and target must implement updateTweenAction function");
- cc.ActionInterval.prototype.startWithTarget.call(this, target);
- this.delta = this.to - this.from;
- },
-
- /**
- * Called once per frame. Time is the number of seconds of a frame interval.
- *
- * @param {Number} dt
- */
- update:function (dt) {
- this.target.updateTweenAction(this.to - this.delta * (1 - dt), this.key);
- },
-
- /**
- * returns a reversed action.
- * @return {ActionTween}
- */
- reverse:function () {
- return new cc.ActionTween(this.duration, this.key, this.to, this.from);
- },
-
- /**
- * to copy object with deep copy.
- * returns a clone of action.
- *
- * @return {ActionTween}
- */
- clone:function(){
- var action = new cc.ActionTween();
- action.initWithDuration(this._duration, this.key, this.from, this.to);
- return action;
- }
-});
-
-/**
- * Creates an initializes the action with the property name (key), and the from and to parameters.
- * @method
- * @param {Number} duration
- * @param {String} key
- * @param {Number} from
- * @param {Number} to
- * @return {ActionTween}
- */
-cc.actionTween = function (duration, key, from, to) {
- return new cc.ActionTween(duration, key, from, to);
-};
-
-/**
- * Please use cc.actionTween instead.
- * Creates an initializes the action with the property name (key), and the from and to parameters.
- * @static
- * @deprecated since v3.0
Please use cc.actionTween instead.
- * @param {Number} duration
- * @param {String} key
- * @param {Number} from
- * @param {Number} to
- * @return {ActionTween}
- */
-cc.ActionTween.create = cc.actionTween;
\ No newline at end of file
diff --git a/cocos2d/actions/index.js b/cocos2d/actions/index.js
index beed958d32..31b45fdcf8 100644
--- a/cocos2d/actions/index.js
+++ b/cocos2d/actions/index.js
@@ -1,4 +1,5 @@
require('./CCAction.js');
require('./CCActionInterval.js');
require('./CCActionInstant.js');
-require('./CCActionEase.js');
\ No newline at end of file
+require('./CCActionEase.js');
+require('./CCActionCatmullRom.js');
\ No newline at end of file
diff --git a/cocos2d/animation/animation-clip.js b/cocos2d/animation/animation-clip.js
index 1fcbf8caf3..a7e4928972 100644
--- a/cocos2d/animation/animation-clip.js
+++ b/cocos2d/animation/animation-clip.js
@@ -86,7 +86,7 @@ var AnimationClip = cc.Class({
* !#en Crate clip with a set of sprite frames
* !#zh 使用一组序列帧图片来创建动画剪辑
* @method createWithSpriteFrames
- * @param {[cc.SpriteFrame]} spriteFrames
+ * @param {[SpriteFrame]} spriteFrames
* @param {Number} sample
* @return {AnimationClip}
* @example
diff --git a/cocos2d/core/CCDirector.js b/cocos2d/core/CCDirector.js
index 4ef8ead898..bc9b1039c0 100644
--- a/cocos2d/core/CCDirector.js
+++ b/cocos2d/core/CCDirector.js
@@ -26,6 +26,7 @@
var EventTarget = require('./event/event-target');
var Class = require('./platform/_CCClass');
+var AutoReleaseUtils = require('./load-pipeline/auto-release-utils');
cc.g_NumberOfDraws = 0;
@@ -389,8 +390,12 @@ cc.Director = Class.extend(/** @lends cc.Director# */{
getZEye: null,
/**
- * !#en Pause the director's ticker.
- * !#zh 暂停正在运行的场景,该暂停只会停止 Scheduler,但是不会停止渲染和 UI 响应。
+ * !#en Pause the director's ticker, only involve the game logic execution.
+ * It won't pause the rendering process nor the event manager.
+ * If you want to pause the entier game including rendering, audio and event,
+ * please use {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}}
+ * !#zh 暂停正在运行的场景,该暂停只会停止游戏逻辑执行,但是不会停止渲染和 UI 响应。
+ * 如果想要更彻底得暂停游戏,包含渲染,音频和事件,请使用 {{#crossLink "Game.pause"}}cc.game.pause{{/crossLink}}。
* @method pause
*/
pause: function () {
@@ -536,8 +541,7 @@ cc.Director = Class.extend(/** @lends cc.Director# */{
var persistNodes = game._persistRootNodes;
if (scene instanceof cc.Scene) {
- // ensure scene initialized
- scene._load();
+ scene._load(); // ensure scene initialized
}
// detach persist nodes
@@ -548,8 +552,13 @@ cc.Director = Class.extend(/** @lends cc.Director# */{
game._ignoreRemovePersistNode = null;
}
- // unload scene
var oldScene = this._scene;
+
+ // auto release assets
+ var autoReleaseAssets = oldScene && oldScene.autoReleaseAssets && oldScene.dependAssets;
+ AutoReleaseUtils.autoRelease(cc.loader, autoReleaseAssets, scene.dependAssets);
+
+ // unload scene
if (cc.isValid(oldScene)) {
oldScene.destroy();
}
@@ -818,8 +827,8 @@ cc.Director = Class.extend(/** @lends cc.Director# */{
},
/**
- * !#en Resume director after pause, if the current scene is not paused, nothing will happen.
- * !#zh 恢复暂停场景,恢复 Scheduler,如果当前场景没有暂停将没任何事情发生。
+ * !#en Resume game logic execution after pause, if the current scene is not paused, nothing will happen.
+ * !#zh 恢复暂停场景的游戏逻辑,如果当前场景没有暂停将没任何事情发生。
* @method resume
*/
resume: function () {
diff --git a/cocos2d/core/CCGame.js b/cocos2d/core/CCGame.js
index 1fb87eb3eb..871dbfb303 100644
--- a/cocos2d/core/CCGame.js
+++ b/cocos2d/core/CCGame.js
@@ -29,17 +29,19 @@ if (!(CC_EDITOR && Editor.isMainProcess)) {
View = require('./platform/CCView');
}
+var _isMusicPlaying = false;
+
/**
* !#en An object to boot the game.
* !#zh 包含游戏主体信息并负责驱动游戏的游戏对象。
* @class Game
*/
-var game = /** @lends cc.game# */{
+var game = {
/**
* Event triggered when game hide to background.
* Please note that this event is not 100% guaranteed to be fired.
- * @property
+ * @property EVENT_HIDE
* @type {String}
* @example
* cc.game.on(cc.game.EVENT_HIDE, function () {
@@ -52,21 +54,21 @@ var game = /** @lends cc.game# */{
/**
* Event triggered when game back to foreground
* Please note that this event is not 100% guaranteed to be fired.
- * @property
+ * @property EVENT_SHOW
* @type {String}
*/
EVENT_SHOW: "game_on_show",
/**
* Event triggered after game inited, at this point all engine objects and game scripts are loaded
- * @property
+ * @property EVENT_GAME_INITED
* @type {String}
*/
EVENT_GAME_INITED: "game_inited",
/**
* Event triggered after renderer inited, at this point you will be able to use the render context
- * @property
+ * @property EVENT_RENDERER_INITED
* @type {String}
*/
EVENT_RENDERER_INITED: "renderer_inited",
@@ -80,7 +82,7 @@ var game = /** @lends cc.game# */{
/**
* Key of config
- * @property
+ * @property CONFIG_KEY
* @type {Object}
*/
CONFIG_KEY: {
@@ -241,8 +243,10 @@ var game = /** @lends cc.game# */{
},
/**
- * !#en Pause the game,pause main loop.
- * !#zh 暂停游戏,暂停的是整个主循环。
+ * !#en Pause the game main loop. This will pause:
+ * game logic execution, rendering process, event manager, background music and all audio effects.
+ * This is different with cc.director.pause which only pause the game logic execution.
+ * !#zh 暂停游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。这点和只暂停游戏逻辑的 cc.director.pause 不同。
* @method pause
*/
pause: function () {
@@ -250,6 +254,11 @@ var game = /** @lends cc.game# */{
this._paused = true;
// Pause audio engine
cc.audioEngine && cc.audioEngine.pauseAll();
+ // Pause event
+ var scene = cc.director.getScene() || cc.director.getRunningScene();
+ if (scene) {
+ cc.eventManager.pauseTarget(scene, true);
+ }
// Pause main loop
if (this._intervalId)
window.cancelAnimationFrame(this._intervalId);
@@ -257,8 +266,9 @@ var game = /** @lends cc.game# */{
},
/**
- * !#en Resume the game from pause.
- * !#zh 继续游戏,继续的是整个主循环。
+ * !#en Resume the game from pause. This will resume:
+ * game logic execution, rendering process, event manager, background music and all audio effects.
+ * !#zh 恢复游戏主循环。包含:游戏逻辑,渲染,事件处理,背景音乐和所有音效。
* @method resume
*/
resume: function () {
@@ -266,6 +276,11 @@ var game = /** @lends cc.game# */{
this._paused = false;
// Resume audio engine
cc.audioEngine && cc.audioEngine.resumeAll();
+ // Resume event
+ var scene = cc.director.getScene() || cc.director.getRunningScene();
+ if (scene) {
+ cc.eventManager.resumeTarget(scene, true);
+ }
// Resume main loop
this._runMainLoop();
},
diff --git a/cocos2d/core/CCNode.js b/cocos2d/core/CCNode.js
index 92e4d625c9..828c33bdfe 100644
--- a/cocos2d/core/CCNode.js
+++ b/cocos2d/core/CCNode.js
@@ -527,6 +527,11 @@ var Node = cc.Class({
this.stopAllActions();
this._releaseAllActions();
+ // Remove Node.currentHovered
+ if (currentHovered === this) {
+ currentHovered = null;
+ }
+
// Remove all listeners
if (CC_JSB && this._touchListener) {
this._touchListener.release();
@@ -964,6 +969,12 @@ var Node = cc.Class({
// activate
cc.director.getActionManager().resumeTarget(this);
cc.eventManager.resumeTarget(this);
+ if (this._touchListener) {
+ this._touchListener.mask = _searchMaskParent(this);
+ }
+ if (this._mouseListener) {
+ this._mouseListener.mask = _searchMaskParent(this);
+ }
}
else {
// deactivate
@@ -1264,17 +1275,22 @@ var Node = cc.Class({
/**
* !#en
* Executes an action, and returns the action that is executed.
- * The node becomes the action's target. Refer to cc.Action's getTarget()
- * Calling runAction while the node is not active won't have any effect.
+ * The node becomes the action's target. Refer to cc.Action's getTarget()
+ * Calling runAction while the node is not active won't have any effect.
+ * Note:You shouldn't modify the action after runAction, that won't take any effect.
+ * if you want to modify, when you define action plus.
* !#zh
* 执行并返回该执行的动作。该节点将会变成动作的目标。
- * 调用 runAction 时,节点自身处于不激活状态将不会有任何效果。
+ * 调用 runAction 时,节点自身处于不激活状态将不会有任何效果。
+ * 注意:你不应该修改 runAction 后的动作,将无法发挥作用,如果想进行修改,请在定义 action 时加入。
* @method runAction
* @param {Action} action
* @return {Action} An Action pointer
* @example
* var action = cc.scaleTo(0.2, 1, 0.6);
* node.runAction(action);
+ * node.runAction(action).repeatForever(); // fail
+ * node.runAction(action.repeatForever()); // right
*/
runAction: function (action) {
if (!this.active)
diff --git a/cocos2d/core/CCScene.js b/cocos2d/core/CCScene.js
index d717379369..9f5d73efc2 100644
--- a/cocos2d/core/CCScene.js
+++ b/cocos2d/core/CCScene.js
@@ -38,15 +38,17 @@ cc.Scene = cc.Class({
name: 'cc.Scene',
extends: require('./utils/base-node'),
- //properties: {
- // /**
- // * !#en Indicates the raw assets of this scene can be load after scene launched.
- // * !#zh 指示该场景依赖的资源可否在场景切换后再延迟加载。
- // * @property {Boolean} _asyncLoadAssets
- // * @default false
- // */
- // _asyncLoadAssets: false
- //},
+ properties: {
+
+ /**
+ * !#en Indicates whether all (directly or indirectly) static referenced assets of this scene are releasable by default after scene unloading.
+ * !#zh 指示该场景中直接或间接静态引用到的所有资源是否默认在场景切换后自动释放。
+ * @property {Boolean} autoReleaseAssets
+ * @default false
+ */
+ autoReleaseAssets: undefined,
+
+ },
ctor: function () {
var sgNode = this._sgNode = new _ccsg.Scene();
@@ -59,6 +61,9 @@ cc.Scene = cc.Class({
this._activeInHierarchy = false;
this._inited = !cc.game._isCloning;
+
+ // cache all depend assets for auto release
+ this.dependAssets = null;
},
destroy: function () {
@@ -112,40 +117,3 @@ cc.Scene = cc.Class({
});
module.exports = cc.Scene;
-
-if (CC_DEV) {
- var ERR = '"%s" is not defined in the Scene, it is only defined in child nodes.';
- Object.defineProperties(cc.Scene.prototype, {
- active: {
- get: function () {
- cc.error(ERR, 'active');
- return true;
- },
- set: function () {
- cc.error(ERR, 'active');
- }
- },
- activeInHierarchy: {
- get: function () {
- cc.error(ERR, 'activeInHierarchy');
- return true;
- },
- },
- getComponent: {
- get: function () {
- cc.error(ERR, 'getComponent');
- return function () {
- return null;
- };
- }
- },
- addComponent: {
- get: function () {
- cc.error(ERR, 'addComponent');
- return function () {
- return null;
- };
- }
- },
- });
-}
\ No newline at end of file
diff --git a/cocos2d/core/assets/CCSceneAsset.js b/cocos2d/core/assets/CCSceneAsset.js
index d27b61a3c3..bb6109c6f7 100644
--- a/cocos2d/core/assets/CCSceneAsset.js
+++ b/cocos2d/core/assets/CCSceneAsset.js
@@ -35,14 +35,27 @@ var Scene = cc.Class({
extends: cc.Asset,
properties: {
+
+ /**
+ * @property {cc.Scene} scene
+ * @default null
+ */
scene: null,
+
/**
* !#en Indicates the raw assets of this scene can be load after scene launched.
* !#zh 指示该场景依赖的资源可否在场景切换后再延迟加载。
* @property {Boolean} asyncLoadAssets
- * @default undefined
+ * @default false
*/
- asyncLoadAssets: undefined
+ asyncLoadAssets: undefined,
+
+ //// backup prefab assets in editor
+ //// {string} assetUuid: {cc.Node} rootInPrefab
+ //_prefabDatas: {
+ // default: null,
+ // editorOnly: true
+ //}
},
});
diff --git a/cocos2d/core/assets/CCSpriteAtlas.js b/cocos2d/core/assets/CCSpriteAtlas.js
index 74ad5f065d..ccd36701ba 100644
--- a/cocos2d/core/assets/CCSpriteAtlas.js
+++ b/cocos2d/core/assets/CCSpriteAtlas.js
@@ -59,7 +59,7 @@ var SpriteAtlas = cc.Class({
* Returns the sprite frame correspond to the given key in sprite atlas.
* @method getSpriteFrame
* @param {String} key
- * @returns {cc.SpriteFrame}
+ * @returns {SpriteFrame}
*/
getSpriteFrame: function (key) {
return this._spriteFrames[key];
@@ -68,7 +68,7 @@ var SpriteAtlas = cc.Class({
/**
* Returns the sprite frames in sprite atlas.
* @method getSpriteFrames
- * @returns {[cc.SpriteFrame]}
+ * @returns {[SpriteFrame]}
*/
getSpriteFrames: function () {
var frames = [];
diff --git a/cocos2d/core/base-nodes/CCAtlasNode.js b/cocos2d/core/base-nodes/CCAtlasNode.js
index a1fc727ab8..7d4f37997c 100644
--- a/cocos2d/core/base-nodes/CCAtlasNode.js
+++ b/cocos2d/core/base-nodes/CCAtlasNode.js
@@ -286,7 +286,7 @@ cc.js.addon(_p, EventTarget.prototype);
/**
* Creates a cc.AtlasNode with an Atlas file the width and height of each item and the quantity of items to render
* @deprecated since v3.0, please use new construction instead
- * @function
+ * @method create
* @static
* @param {String} tile
* @param {Number} tileWidth
diff --git a/cocos2d/core/base-nodes/CCSGNodeCanvasRenderCmd.js b/cocos2d/core/base-nodes/CCSGNodeCanvasRenderCmd.js
index 8b39908c18..151cc1facd 100644
--- a/cocos2d/core/base-nodes/CCSGNodeCanvasRenderCmd.js
+++ b/cocos2d/core/base-nodes/CCSGNodeCanvasRenderCmd.js
@@ -208,10 +208,10 @@ _ccsg.Node.RenderCmd.prototype = {
skx = 99999999;
if (sky === Infinity)
sky = 99999999;
- t.a = a + b * sky;
- t.b = b + a * sky;
- t.c = c + d * skx;
- t.d = d + c * skx;
+ t.a = a + c * sky;
+ t.b = b + d * sky;
+ t.c = c + a * skx;
+ t.d = d + b * skx;
}
if (appX || appY) {
@@ -449,21 +449,21 @@ _ccsg.Node.RenderCmd.prototype = {
var colorDirty = locFlag & dirtyFlags.colorDirty,
opacityDirty = locFlag & dirtyFlags.opacityDirty;
- if(locFlag & dirtyFlags.contentDirty) {
+ if (locFlag & dirtyFlags.contentDirty) {
this._notifyRegionStatus && this._notifyRegionStatus(_ccsg.Node.CanvasRenderCmd.RegionStatus.Dirty);
this._dirtyFlag &= ~dirtyFlags.contentDirty;
}
- if(colorDirty)
+ if (colorDirty)
this._updateDisplayColor();
- if(opacityDirty)
+ if (opacityDirty)
this._updateDisplayOpacity();
- if(colorDirty || opacityDirty)
+ if (colorDirty || opacityDirty)
this._updateColor();
- if(locFlag & dirtyFlags.transformDirty){
+ if (locFlag & dirtyFlags.transformDirty) {
//update the transform
this.transform(this.getParentRenderCmd(), true);
this._dirtyFlag &= ~dirtyFlags.transformDirty;
@@ -487,7 +487,7 @@ _ccsg.Node.RenderCmd.prototype = {
//update the opacity
this._syncDisplayOpacity();
- if(colorDirty || opacityDirty)
+ if (colorDirty || opacityDirty)
this._updateColor();
if (transformDirty)
diff --git a/cocos2d/core/base-ui/CCWidgetManager.js b/cocos2d/core/base-ui/CCWidgetManager.js
index 5ea2b125b7..ffe8b68f8f 100644
--- a/cocos2d/core/base-ui/CCWidgetManager.js
+++ b/cocos2d/core/base-ui/CCWidgetManager.js
@@ -91,8 +91,9 @@ function alignToParent (node, widget) {
else {
width = node.width * scaleX;
if (widget.isAlignHorizontalCenter) {
- var parentCenter = (0.5 - parentAnchor.x) * parentWidth; // no offset
- x = parentCenter + (anchorX - 0.5) * width;
+ var localHorizontalCenter = widget._isAbsHorizontalCenter ? widget._horizontalCenter : widget._horizontalCenter * parentWidth;
+ var parentCenter = (0.5 - parentAnchor.x) * parentWidth;
+ x = parentCenter + (anchorX - 0.5) * width + localHorizontalCenter;
}
else if (widget.isAlignLeft) {
x = localLeft + anchorX * width;
@@ -137,8 +138,9 @@ function alignToParent (node, widget) {
else {
height = node.height * scaleY;
if (widget.isAlignVerticalCenter) {
- var parentMiddle = (0.5 - parentAnchor.y) * parentHeight; // no offset
- y = parentMiddle + (anchorY - 0.5) * height;
+ var localVerticalCenter = widget._isAbsVerticalCenter ? widget._verticalCenter : widget._verticalCenter * parentHeight;
+ var parentMiddle = (0.5 - parentAnchor.y) * parentHeight;
+ y = parentMiddle + (anchorY - 0.5) * height + localVerticalCenter;
}
else if (widget.isAlignBottom) {
y = localBottom + anchorY * height;
@@ -156,7 +158,7 @@ function visitNode (node) {
var widget = node._widget;
if (widget) {
alignToParent(node, widget);
- if ((!CC_EDITOR || _Scene.AnimUtils.curAnimState) && widget.isAlignOnce) {
+ if ((!CC_EDITOR || animationState.animatedSinceLastFrame) && widget.isAlignOnce) {
widget.enabled = false;
}
else {
@@ -172,7 +174,34 @@ function visitNode (node) {
}
}
+if (CC_EDITOR) {
+ var animationState = {
+ previewing: false,
+ time: 0,
+ animatedSinceLastFrame: false,
+ };
+}
+
function refreshScene () {
+ // check animation editor
+ if (CC_EDITOR && window._Scene && _Scene.AnimUtils) {
+ var nowPreviewing = !!_Scene.AnimUtils.curAnimState;
+ if (nowPreviewing !== animationState.previewing) {
+ animationState.previewing = nowPreviewing;
+ if (nowPreviewing) {
+ animationState.animatedSinceLastFrame = true;
+ animationState.time = _Scene.AnimUtils.curAnimState.time;
+ }
+ else {
+ animationState.animatedSinceLastFrame = false;
+ }
+ }
+ else if (nowPreviewing && animationState.time !== _Scene.AnimUtils.curAnimState.time) {
+ animationState.animatedSinceLastFrame = true;
+ animationState.time = _Scene.AnimUtils.curAnimState.time;
+ }
+ }
+
var scene = cc.director.getScene();
if (scene) {
widgetManager.isAligning = true;
@@ -180,14 +209,15 @@ function refreshScene () {
widgetManager._nodesWithWidget.length = 0;
visitNode(scene);
widgetManager._nodesOrderDirty = false;
- } else {
+ }
+ else {
var i, node, nodes = widgetManager._nodesWithWidget, len = nodes.length;
- if (CC_EDITOR && _Scene.AnimUtils.curAnimState) {
- // always check isAlignOnce because animation mode maybe changed
+ if (CC_EDITOR && window._Scene && _Scene.AnimUtils && _Scene.AnimUtils.curAnimState) {
+ var editingNode = _Scene.AnimUtils.curRootNode;
for (i = len - 1; i >= 0; i--) {
node = nodes[i];
var widget = node._widget;
- if (widget.isAlignOnce) {
+ if (widget.isAlignOnce && animationState.animatedSinceLastFrame && node.isChildOf(editingNode)) {
// widget contains in _nodesWithWidget should aligned at least once
widget.enabled = false;
}
@@ -206,6 +236,10 @@ function refreshScene () {
widgetManager.isAligning = false;
}
+ // check animation editor
+ if (CC_EDITOR) {
+ animationState.animatedSinceLastFrame = false;
+ }
}
var adjustWidgetToAllowMovingInEditor = CC_EDITOR && function (event) {
@@ -237,14 +271,10 @@ var adjustWidgetToAllowMovingInEditor = CC_EDITOR && function (event) {
this.right -= (this.isAbsoluteRight ? delta.x : deltaInPercent.x);
}
if (this.isAlignHorizontalCenter) {
- if (oldPos.x !== newPos.x) {
- this.isAlignHorizontalCenter = false;
- }
+ this.horizontalCenter += (this.isAbsoluteHorizontalCenter ? delta.x : deltaInPercent.x);
}
if (this.isAlignVerticalCenter) {
- if (oldPos.y !== newPos.y) {
- this.isAlignVerticalCenter = false;
- }
+ this.verticalCenter += (this.isAbsoluteVerticalCenter ? delta.y : deltaInPercent.y);
}
};
@@ -280,14 +310,10 @@ var adjustWidgetToAllowResizingInEditor = CC_EDITOR && function (event) {
this.right -= (this.isAbsoluteRight ? delta.x : deltaInPercent.x) * (1 - anchor.x);
}
if (this.isAlignHorizontalCenter) {
- if (delta.x !== 0 && anchor.x !== 0.5) {
- this.isAlignHorizontalCenter = false;
- }
+ this.horizontalCenter -= (this.isAbsoluteHorizontalCenter ? delta.x : deltaInPercent.x);
}
if (this.isAlignVerticalCenter) {
- if (delta.y !== 0 && anchor.y !== 0.5) {
- this.isAlignVerticalCenter = false;
- }
+ this.verticalCenter -= (this.isAbsoluteVerticalCenter ? delta.y : deltaInPercent.y);
}
};
diff --git a/cocos2d/core/collider/CCCollisionManager.js b/cocos2d/core/collider/CCCollisionManager.js
index e24c170593..be35bed8df 100644
--- a/cocos2d/core/collider/CCCollisionManager.js
+++ b/cocos2d/core/collider/CCCollisionManager.js
@@ -400,7 +400,7 @@ cc.js.getset(CollisionManager.prototype, 'enabledDebugDraw',
}
else if (!value && this._enabledDebugDraw) {
this._debugDrawer.clear();
- cc.director.getScene()._sgNode.removeChild(this._debugDrawer);
+ this._debugDrawer.removeFromParent(false);
cc.director.off(cc.Director.EVENT_AFTER_SCENE_LAUNCH, this.onSceneLaunched, this);
}
diff --git a/cocos2d/core/components/CCAnimation.js b/cocos2d/core/components/CCAnimation.js
index 6743b41b2b..fbb01027ff 100644
--- a/cocos2d/core/components/CCAnimation.js
+++ b/cocos2d/core/components/CCAnimation.js
@@ -166,17 +166,16 @@ var Animation = cc.Class({
}
},
- __preload: function () {
- if (CC_EDITOR || !this.enabled) return;
+ onEnable: function () {
+ if (!CC_EDITOR && this.playOnLoad && this._defaultClip) {
+ this.playOnLoad = false;
- if (this.playOnLoad && this._defaultClip) {
var state = this.getAnimationState(this._defaultClip.name);
this._animator.playState(state);
}
- },
-
- onEnable: function () {
- this.resume();
+ else {
+ this.resume();
+ }
},
onDisable: function () {
diff --git a/cocos2d/core/components/CCButton.js b/cocos2d/core/components/CCButton.js
index b9a69d0d17..b1be6c7133 100644
--- a/cocos2d/core/components/CCButton.js
+++ b/cocos2d/core/components/CCButton.js
@@ -448,7 +448,7 @@ var Button = cc.Class({
},
_onMouseMoveIn: function () {
- if (this._pressed || !this.interactable || !this.enabledInHierarchy) return;
+ if (!this.hoverSprite || this._pressed || !this.interactable || !this.enabledInHierarchy) return;
if (!this._hovered) {
this._hovered = true;
diff --git a/cocos2d/core/components/CCComponentEventHandler.js b/cocos2d/core/components/CCComponentEventHandler.js
index 85275a290c..312c968d82 100644
--- a/cocos2d/core/components/CCComponentEventHandler.js
+++ b/cocos2d/core/components/CCComponentEventHandler.js
@@ -80,7 +80,7 @@ cc.Component.EventHandler = cc.Class({
/**
* @method emitEvents
* @param {Component.EventHandler[]} events
- * @param {Any} ...params
+ * @param {any} ...params
* @statics
*/
emitEvents: function(events) {
diff --git a/cocos2d/core/components/CCMask.js b/cocos2d/core/components/CCMask.js
index 3d6f28b019..bc5aaf1cc5 100644
--- a/cocos2d/core/components/CCMask.js
+++ b/cocos2d/core/components/CCMask.js
@@ -23,6 +23,8 @@
THE SOFTWARE.
****************************************************************************/
+var Base = cc._RendererInSG;
+
/**
* @class Mask
* @extends _RendererInSG
@@ -51,7 +53,7 @@ var MaskType = cc.Enum({
var Mask = cc.Class({
name: 'cc.Mask',
- extends: cc._RendererInSG,
+ extends: Base,
editor: CC_EDITOR && {
menu: 'i18n:MAIN_MENU.component.renderers/Mask',
@@ -167,12 +169,6 @@ var Mask = cc.Class({
this.node.off('anchor-changed', this._refreshStencil, this);
},
- onDestroy: CC_JSB && function () {
- this._super();
- this._clippingStencil.release();
- this._clippingStencil = null;
- },
-
_calculateCircle: function(center, radius, segements) {
var polies =[];
var anglePerStep = Math.PI * 2 / segements;
@@ -208,4 +204,14 @@ var Mask = cc.Class({
}
});
+if (CC_JSB) {
+ // override onDestroy
+ Mask.prototype.__superOnDestroy = Base.prototype.onDestroy;
+ Mask.prototype.onDestroy = function () {
+ this.__superOnDestroy();
+ this._clippingStencil.release();
+ this._clippingStencil = null;
+ };
+}
+
cc.Mask = module.exports = Mask;
diff --git a/cocos2d/core/components/CCRendererInSG.js b/cocos2d/core/components/CCRendererInSG.js
index c349c8f6ab..57476afe85 100644
--- a/cocos2d/core/components/CCRendererInSG.js
+++ b/cocos2d/core/components/CCRendererInSG.js
@@ -33,6 +33,7 @@
*/
var RendererInSG = cc.Class({
extends: require('./CCSGComponent'),
+ name: 'cc._RendererInSG',
ctor: function () {
/**
diff --git a/cocos2d/core/components/CCRendererUnderSG.js b/cocos2d/core/components/CCRendererUnderSG.js
index 12c424d248..fbbee4c901 100644
--- a/cocos2d/core/components/CCRendererUnderSG.js
+++ b/cocos2d/core/components/CCRendererUnderSG.js
@@ -32,6 +32,7 @@
*/
var RendererUnderSG = cc.Class({
extends: require('./CCSGComponent'),
+ name: 'cc._RendererUnderSG',
ctor: function () {
/**
diff --git a/cocos2d/core/components/CCSGComponent.js b/cocos2d/core/components/CCSGComponent.js
index 0499d695de..01ca05a92c 100644
--- a/cocos2d/core/components/CCSGComponent.js
+++ b/cocos2d/core/components/CCSGComponent.js
@@ -38,6 +38,7 @@ var SceneGraphHelper = require('../utils/scene-graph-helper');
*/
var SGComponent = cc.Class({
extends: require('./CCComponent'),
+ name: 'cc._SGComponent',
editor: CC_EDITOR && {
executeInEditMode: true,
diff --git a/cocos2d/core/components/CCScrollView.js b/cocos2d/core/components/CCScrollView.js
index e389942140..33b34d1fc6 100644
--- a/cocos2d/core/components/CCScrollView.js
+++ b/cocos2d/core/components/CCScrollView.js
@@ -160,7 +160,7 @@ var ScrollView = cc.Class({
* @property {Node} content
*/
content: {
- default: null,
+ default: undefined,
type: cc.Node,
tooltip: 'i18n:COMPONENT.scrollview.content',
},
@@ -240,7 +240,7 @@ var ScrollView = cc.Class({
* @property {Scrollbar} horizontalScrollBar
*/
horizontalScrollBar: {
- default: null,
+ default: undefined,
type: cc.Scrollbar,
tooltip: 'i18n:COMPONENT.scrollview.horizontal_bar',
notify: function() {
@@ -258,7 +258,7 @@ var ScrollView = cc.Class({
* @property {Scrollbar} verticalScrollBar
*/
verticalScrollBar: {
- default: null,
+ default: undefined,
type: cc.Scrollbar,
tooltip: 'i18n:COMPONENT.scrollview.vertical_bar',
notify: function() {
@@ -278,6 +278,18 @@ var ScrollView = cc.Class({
scrollEvents: {
default: [],
type: cc.Component.EventHandler
+ },
+
+ /**
+ * !#en If cancelInnerEvents is set to true, the scroll behavior will cancel touch events on inner content nodes of the scroll view
+ * It's set to true by default.
+ * !#zh 如果这个属性被设置为 true,那么滚动行为会取消 ScrollView 的子节点上注册的触摸事件,默认被设置为 true。
+ * 注意,子节点上的 touchstart 事件仍然会触发,触点移动距离非常短的情况下 touchmove 和 touchend 也不会受影响。
+ * @property {Boolean} cancelInnerEvents
+ */
+ cancelInnerEvents: {
+ default: true,
+ animatable: false,
}
},
@@ -801,6 +813,7 @@ var ScrollView = cc.Class({
}
this._moveContent(moveDelta);
+ this._adjustContentOutOfBoundary();
},
_calculateBoundary: function() {
@@ -846,17 +859,22 @@ var ScrollView = cc.Class({
if (this.content) {
this._handleMoveLogic(touch);
}
+ // Do not prevent touch events in inner nodes
+ if (!this.cancelInnerEvents) {
+ return;
+ }
+
var deltaMove = cc.pSub(touch.getLocation(), touch.getStartLocation());
//FIXME: touch move delta should be calculated by DPI.
if (cc.pLength(deltaMove) > 7) {
- this._touchMoved = true;
- if (event.target !== this.node) {
+ if (!this._touchMoved && event.target !== this.node) {
// Simulate touch cancel for target node
var cancelEvent = new cc.Event.EventTouch(event.getTouches(), event.bubbles);
cancelEvent.type = cc.Node.EventType.TOUCH_CANCEL;
cancelEvent.touch = event.touch;
cancelEvent.simulate = true;
event.target.dispatchEvent(cancelEvent);
+ this._touchMoved = true;
}
event.stopPropagation();
}
@@ -1307,8 +1325,25 @@ var ScrollView = cc.Class({
}
},
+ _adjustContentOutOfBoundary: function () {
+ this._outOfBoundaryAmountDirty = true;
+ if(this._isOutOfBoundary()) {
+ var outOfBoundary = this._getHowMuchOutOfBoundary(cc.p(0, 0));
+ var newPosition = cc.pAdd(this.getContentPosition(), outOfBoundary);
+ if(this.content) {
+ this.content.setPosition(newPosition);
+ this._updateScrollBar(0);
+ }
+ }
+ },
+
start: function() {
this._calculateBoundary();
+ //Because widget component will adjust content position and scrollview position is correct after visit
+ //So this event could make sure the content is on the correct position after loading.
+ if(this.content) {
+ cc.director.once(cc.Director.EVENT_AFTER_VISIT, this._adjustContentOutOfBoundary, this);
+ }
},
onDestroy: function() {
diff --git a/cocos2d/core/components/CCSprite.js b/cocos2d/core/components/CCSprite.js
index 3dcfef3575..055b2fffbe 100644
--- a/cocos2d/core/components/CCSprite.js
+++ b/cocos2d/core/components/CCSprite.js
@@ -23,6 +23,8 @@
THE SOFTWARE.
****************************************************************************/
+var Base = require('./CCRendererUnderSG');
+
/**
* !#en Enum for sprite type.
* !#zh Sprite 类型
@@ -113,7 +115,7 @@ var SizeMode = cc.Enum({
*/
var Sprite = cc.Class({
name: 'cc.Sprite',
- extends: require('./CCRendererUnderSG'),
+ extends: Base,
editor: CC_EDITOR && {
menu: 'i18n:MAIN_MENU.component.renderers/Sprite',
@@ -379,15 +381,6 @@ var Sprite = cc.Class({
SizeMode: SizeMode,
},
- /**
- * !#en Sets whether the sprite is visible or not.
- * !#zh 设置精灵是否可见
- * @method setVisible
- * @param {Boolean} visible
- * @override
- * @example
- * sprite.setVisible(false);
- */
setVisible: function (visible) {
this.enabled = visible;
},
@@ -492,11 +485,6 @@ var Sprite = cc.Class({
return this._sgNode.getInsetBottom();
},
- __preload: CC_EDITOR && function () {
- this._super();
- this.node.on('size-changed', this._resized, this);
- },
-
onEnable: function () {
if (this._sgNode) {
if (this._spriteFrame && this._spriteFrame.textureLoaded()) {
@@ -505,11 +493,6 @@ var Sprite = cc.Class({
}
},
- onDestroy: CC_EDITOR && function () {
- this._super();
- this.node.off('size-changed', this._resized, this);
- },
-
_applyAtlas: CC_EDITOR && function (spriteFrame) {
// Set atlas
if (spriteFrame && spriteFrame._atlasUuid) {
@@ -632,6 +615,21 @@ var Sprite = cc.Class({
},
});
+if (CC_EDITOR) {
+ // override __preload
+ Sprite.prototype.__superPreload = Base.prototype.__preload;
+ Sprite.prototype.__preload = function () {
+ this.__superPreload();
+ this.node.on('size-changed', this._resized, this);
+ };
+ // override onDestroy
+ Sprite.prototype.__superOnDestroy = Base.prototype.onDestroy;
+ Sprite.prototype.onDestroy = function () {
+ this.__superOnDestroy();
+ this.node.off('size-changed', this._resized, this);
+ };
+}
+
var misc = require('../utils/misc');
var SameNameGetSets = ['atlas', 'capInsets', 'insetLeft', 'insetTop', 'insetRight', 'insetBottom'];
var DiffNameGetSets = {
diff --git a/cocos2d/core/components/CCVideoPlayer.js b/cocos2d/core/components/CCVideoPlayer.js
index 332cad9338..1de87bf61a 100644
--- a/cocos2d/core/components/CCVideoPlayer.js
+++ b/cocos2d/core/components/CCVideoPlayer.js
@@ -147,21 +147,24 @@ var VideoPlayer = cc.Class({
url: cc.RawAsset
},
- _time: 0,
/**
- * !#en The current time when video start to play.
- * !#zh 从当前时间点开始播放视频
- * @property {Float} currentTime
+ * !#en The current playback time of the now playing item in seconds, you could also change the start playback time.
+ * !#zh 指定视频从什么时间点开始播放,单位是秒,也可以用来获取当前视频播放的时间进度。
+ * @property {Number} currentTime
*/
currentTime: {
tooltip: 'i18n:COMPONENT.videoplayer.currentTime',
type: cc.Float,
set: function ( time ) {
- this._time = time;
- this._sgNode.seekTo(time);
+ if(this._sgNode) {
+ this._sgNode.seekTo(time);
+ }
},
get: function () {
- return this._time;
+ if(this._sgNode) {
+ return this._sgNode.currentTime();
+ }
+ return -1;
}
},
@@ -210,7 +213,6 @@ var VideoPlayer = cc.Class({
},
onLoad: function() {
-
if(CC_JSB) {
if (cc.sys.os === cc.sys.OS_OSX || cc.sys.os === cc.sys.OS_WINDOWS) {
this.enabled = false;
@@ -318,6 +320,28 @@ var VideoPlayer = cc.Class({
}
},
+ /**
+ * !#en Gets the duration of the video
+ * !#zh 获取视频文件的播放总时长
+ */
+ getDuration: function() {
+ if(this._sgNode) {
+ return this._sgNode.duration();
+ }
+ return -1;
+ },
+
+ /**
+ * !#en Determine whether video is playing or not.
+ * !#zh 判断当前视频是否处于播放状态
+ */
+ isPlaying: function() {
+ if(this._sgNode) {
+ return this._sgNode.isPlaying();
+ }
+ return false;
+ }
+
});
cc.VideoPlayer = module.exports = VideoPlayer;
diff --git a/cocos2d/core/components/CCWidget.js b/cocos2d/core/components/CCWidget.js
index 4c4c739bcf..37ddc18014 100644
--- a/cocos2d/core/components/CCWidget.js
+++ b/cocos2d/core/components/CCWidget.js
@@ -38,8 +38,10 @@ var LEFT_RIGHT = LEFT | RIGHT;
* !#en
* Stores and manipulate the anchoring based on its parent.
* Widget are used for GUI but can also be used for other things.
+ * Widget will adjust current node's position and size automatically, but the results after adjustment can not be obtained until the next frame.
* !#zh
* Widget 组件,用于设置和适配其相对于父节点的边距,Widget 通常被用于 UI 界面,也可以用于其他地方。
+ * Widget 会自动调整当前节点的坐标和宽高,不过目前调整后的结果要到下一帧才能在脚本里获取到。
* @class Widget
* @extends Component
*/
@@ -301,8 +303,80 @@ var Widget = cc.Class({
tooltip: 'i18n:COMPONENT.widget.right',
},
+ /**
+ * !#en
+ * Horizontal aligns the midpoint offset value,
+ * the value can be negative, Only available in 'isAlignHorizontalCenter' open.
+ * !#zh 水平居中的偏移值,可填写负值,只有在 isAlignHorizontalCenter 开启时才有作用。
+ * @property horizontalCenter
+ * @type {Number}
+ * @default 0
+ */
+ horizontalCenter: {
+ get: function () {
+ return this._horizontalCenter;
+ },
+ set: function (value) {
+ this._horizontalCenter = value;
+ },
+ tooltip: 'i18n:COMPONENT.widget.horizontal_center',
+ },
+
+ /**
+ * !#en
+ * Vertical aligns the midpoint offset value,
+ * the value can be negative, Only available in 'isAlignVerticalCenter' open.
+ * !#zh 垂直居中的偏移值,可填写负值,只有在 isAlignVerticalCenter 开启时才有作用。
+ * @property verticalCenter
+ * @type {Number}
+ * @default 0
+ */
+ verticalCenter: {
+ get: function () {
+ return this._verticalCenter;
+ },
+ set: function (value) {
+ this._verticalCenter = value;
+ },
+ tooltip: 'i18n:COMPONENT.widget.vertical_center',
+ },
+
// PARCENTAGE OR ABSOLUTE
+ /**
+ * !#en If true, horizontalCenter is pixel margin, otherwise is percentage (0 - 1) margin.
+ * !#zh 如果为 true,"horizontalCenter" 将会以像素作为偏移值,反之为百分比(0 到 1)。
+ * @property isAbsoluteHorizontalCenter
+ * @type {Boolean}
+ * @default true
+ */
+ isAbsoluteHorizontalCenter: {
+ get: function () {
+ return this._isAbsHorizontalCenter;
+ },
+ set: function (value) {
+ this._isAbsHorizontalCenter = value;
+ },
+ animatable: false
+ },
+
+ /**
+ * !#en If true, verticalCenter is pixel margin, otherwise is percentage (0 - 1) margin.
+ * !#zh 如果为 true,"verticalCenter" 将会以像素作为偏移值,反之为百分比(0 到 1)。
+ * @property isAbsoluteVerticalCenter
+ * @type {Boolean}
+ * @default true
+ */
+ isAbsoluteVerticalCenter: {
+ get: function () {
+ return this._isAbsVerticalCenter;
+ },
+ set: function (value) {
+ this._isAbsVerticalCenter = value;
+ },
+ animatable: false
+ },
+
/**
* !#en
* If true, top is pixel margin, otherwise is percentage (0 - 1) margin relative to the parent's height.
@@ -411,10 +485,14 @@ var Widget = cc.Class({
_right: 0,
_top: 0,
_bottom: 0,
+ _verticalCenter: 0,
+ _horizontalCenter: 0,
_isAbsLeft: true,
_isAbsRight: true,
_isAbsTop: true,
_isAbsBottom: true,
+ _isAbsHorizontalCenter: true,
+ _isAbsVerticalCenter: true,
// original size before align
_originalWidth: 0,
diff --git a/cocos2d/core/editbox/CCSGEditBox.js b/cocos2d/core/editbox/CCSGEditBox.js
index 4e6f82e24d..caf364f57c 100644
--- a/cocos2d/core/editbox/CCSGEditBox.js
+++ b/cocos2d/core/editbox/CCSGEditBox.js
@@ -581,10 +581,18 @@ _ccsg.EditBox.KeyboardReturnType = KeyboardReturnType;
tmpEdTxt.addEventListener('input', function () {
var editBox = thisPointer._editBox;
+
+
+ if (this.value.length > this.maxLength) {
+ this.value = this.value.slice(0, this.maxLength);
+ }
+
if (editBox._delegate && editBox._delegate.editBoxTextChanged) {
- editBox._text = this.value;
- thisPointer._updateEditBoxContentStyle();
- editBox._delegate.editBoxTextChanged(editBox, editBox._text);
+ if (editBox._text.toLowerCase() !== this.value.toLowerCase()) {
+ editBox._text = this.value;
+ thisPointer._updateEditBoxContentStyle();
+ editBox._delegate.editBoxTextChanged(editBox, editBox._text);
+ }
}
});
tmpEdTxt.addEventListener('keypress', function (e) {
@@ -597,6 +605,7 @@ _ccsg.EditBox.KeyboardReturnType = KeyboardReturnType;
this.style.fontSize = editBox._placeholderFontSize + 'px';
this.style.color = cc.colorToHex(editBox._placeholderColor);
}
+
editBox._text = this.value;
thisPointer._updateEditBoxContentStyle();
thisPointer.hidden();
@@ -670,11 +679,17 @@ _ccsg.EditBox.KeyboardReturnType = KeyboardReturnType;
tmpEdTxt.style.className = "cocosEditBox";
tmpEdTxt.addEventListener('input', function () {
+ if (this.value.length > this.maxLength) {
+ this.value = this.value.slice(0, this.maxLength);
+ }
+
var editBox = thisPointer._editBox;
if (editBox._delegate && editBox._delegate.editBoxTextChanged) {
- editBox._text = this.value;
- thisPointer._updateEditBoxContentStyle();
- editBox._delegate.editBoxTextChanged(editBox, editBox._text);
+ if(editBox._text.toLowerCase() !== this.value.toLowerCase()) {
+ editBox._text = this.value;
+ thisPointer._updateEditBoxContentStyle();
+ editBox._delegate.editBoxTextChanged(editBox, editBox._text);
+ }
}
});
diff --git a/cocos2d/core/event-manager/CCEventListener.js b/cocos2d/core/event-manager/CCEventListener.js
index 12cf653fe4..13092d1656 100644
--- a/cocos2d/core/event-manager/CCEventListener.js
+++ b/cocos2d/core/event-manager/CCEventListener.js
@@ -44,7 +44,7 @@
* @param {Number} type
* @param {Number} listenerID
* @param {Number} callback
- * @return {EventListner}
+ * @return {EventListener}
*/
cc.EventListener = cc._Class.extend(/** @lends cc.EventListener# */{
_onEvent: null, // Event callback function
diff --git a/cocos2d/core/event-manager/CCTouch.js b/cocos2d/core/event-manager/CCTouch.js
index 821f16f342..8261bd1cd8 100644
--- a/cocos2d/core/event-manager/CCTouch.js
+++ b/cocos2d/core/event-manager/CCTouch.js
@@ -163,6 +163,7 @@ cc.Touch = cc._Class.extend(/** @lends cc.Touch# */{
this._id = id;
if(!this._startPointCaptured){
this._startPoint = cc.p(this._point);
+ cc.view._convertPointWithScale(this._startPoint);
this._startPointCaptured = true;
}
},
diff --git a/cocos2d/core/event/event-target.js b/cocos2d/core/event/event-target.js
index dc0b3a82ac..265040f88d 100644
--- a/cocos2d/core/event/event-target.js
+++ b/cocos2d/core/event/event-target.js
@@ -332,7 +332,7 @@ JS.mixin(EventTarget.prototype, {
// Event.AT_TARGET
event.eventPhase = 2;
- event.currentTarget = this;
+ event.target = event.currentTarget = this;
if (caplisteners) {
this._capturingListeners.invoke(event);
}
diff --git a/cocos2d/core/graphics/graphics-canvas-cmd.js b/cocos2d/core/graphics/graphics-canvas-cmd.js
index 2236def510..04ba3e56aa 100644
--- a/cocos2d/core/graphics/graphics-canvas-cmd.js
+++ b/cocos2d/core/graphics/graphics-canvas-cmd.js
@@ -27,16 +27,7 @@ var Js = cc.js;
var LineCap = require('./types').LineCap;
var LineJoin = require('./types').LineJoin;
-var PI = 3.14159265358979323846264338327;
-
-var min = Math.min;
-var max = Math.max;
-var cos = Math.cos;
-var sin = Math.sin;
-var abs = Math.abs;
-var sign = Math.sign;
-
-var KAPPA90 = 0.5522847493;
+var Helper = require('./helper');
var CanvasRenderCmd = function (renderable) {
_ccsg.Node.CanvasRenderCmd.call(this, renderable);
@@ -95,12 +86,12 @@ _p.rendering = function (ctx, scaleX, scaleY) {
// draw api
Js.mixin(_p, {
setStrokeColor: function (v) {
- var fillStyle = "rgba(" + (0 | v.r) + "," + (0 | v.g) + "," + (0 | v.b) + "," + v.a / 255 + ")";
+ var fillStyle = 'rgba(' + (0 | v.r) + ',' + (0 | v.g) + ',' + (0 | v.b) + ',' + v.a / 255 + ')';
this.cmds.push(['strokeStyle', fillStyle]);
},
setFillColor: function (v) {
- var fillStyle = "rgba(" + (0 | v.r) + "," + (0 | v.g) + "," + (0 | v.b) + "," + v.a / 255 + ")";
+ var fillStyle = 'rgba(' + (0 | v.r) + ',' + (0 | v.g) + ',' + (0 | v.b) + ',' + v.a / 255 + ')';
this.cmds.push(['fillStyle', fillStyle]);
},
@@ -158,69 +149,16 @@ Js.mixin(_p, {
},
//
- arc: function (cx, cy, r, a0, a1, counterclockwise) {
- // this.cmds.push(['arc', arguments]);
- var a = 0, da = 0, hda = 0, kappa = 0;
- var dx = 0, dy = 0, x = 0, y = 0, tanx = 0, tany = 0;
- var px = 0, py = 0, ptanx = 0, ptany = 0;
- var i, ndivs;
-
- // Clamp angles
- da = a1 - a0;
- if (!counterclockwise) {
- if (abs(da) >= PI * 2) {
- da = PI * 2;
- } else {
- while (da < 0) da += PI * 2;
- }
- } else {
- if (abs(da) >= PI * 2) {
- da = -PI * 2;
- } else {
- while (da > 0) da -= PI * 2;
- }
- }
-
- // Split arc into max 90 degree segments.
- ndivs = max(1, min(abs(da) / (PI * 0.5) + 0.5, 5)) | 0;
- hda = da / ndivs / 2.0;
- kappa = abs(4.0 / 3.0 * (1 - cos(hda)) / sin(hda));
-
- if (counterclockwise) kappa = -kappa;
-
- for (i = 0; i <= ndivs; i++) {
- a = a0 + da * (i / ndivs);
- dx = cos(a);
- dy = sin(a);
- x = cx + dx * r;
- y = cy + dy * r;
- tanx = -dy * r * kappa;
- tany = dx * r * kappa;
-
- if (i === 0) {
- this.moveTo(x, y);
- } else {
- this.bezierCurveTo(px + ptanx, py + ptany, x - tanx, y - tany, x, y);
- }
- px = x;
- py = y;
- ptanx = tanx;
- ptany = tany;
- }
+ arc: function (cx, cy, r, startAngle, endAngle, counterclockwise) {
+ Helper.arc(this, cx, cy, r, startAngle, endAngle, counterclockwise);
},
ellipse: function (cx, cy, rx, ry) {
- this.moveTo(cx - rx, cy);
- this.bezierCurveTo(cx - rx, cy + ry * KAPPA90, cx - rx * KAPPA90, cy + ry, cx, cy + ry);
- this.bezierCurveTo(cx + rx * KAPPA90, cy + ry, cx + rx, cy + ry * KAPPA90, cx + rx, cy);
- this.bezierCurveTo(cx + rx, cy - ry * KAPPA90, cx + rx * KAPPA90, cy - ry, cx, cy - ry);
- this.bezierCurveTo(cx - rx * KAPPA90, cy - ry, cx - rx, cy - ry * KAPPA90, cx - rx, cy);
- this.close();
+ Helper.ellipse(this, cx, cy, rx, ry);
},
circle: function (cx, cy, r) {
- this.ellipse(cx, cy, r, r);
- this.close();
+ Helper.ellipse(this, cx, cy, r, r);
},
rect: function (x, y, w, h) {
@@ -232,24 +170,7 @@ Js.mixin(_p, {
},
roundRect: function (x, y, w, h, r) {
- if (r < 0.1) {
- this.rect(x, y, w, h);
- return;
- } else {
- var rx = min(r, abs(w) * 0.5) * sign(w),
- ry = min(r, abs(h) * 0.5) * sign(h);
-
- this.moveTo(x, y + ry);
- this.lineTo(x, y + h - ry);
- this.bezierCurveTo(x, y + h - ry * (1 - KAPPA90), x + rx * (1 - KAPPA90), y + h, x + rx, y + h);
- this.lineTo(x + w - rx, y + h);
- this.bezierCurveTo(x + w - rx * (1 - KAPPA90), y + h, x + w, y + h - ry * (1 - KAPPA90), x + w, y + h - ry);
- this.lineTo(x + w, y + ry);
- this.bezierCurveTo(x + w, y + ry * (1 - KAPPA90), x + w - rx * (1 - KAPPA90), y, x + w - rx, y);
- this.lineTo(x + rx, y);
- this.bezierCurveTo(x + rx * (1 - KAPPA90), y, x, y + ry * (1 - KAPPA90), x, y + ry);
- this.close();
- }
+ Helper.roundRect(this, x, y, w, h, r);
},
fillRect: function (x, y, w, h) {
diff --git a/cocos2d/core/graphics/graphics-webgl-cmd.js b/cocos2d/core/graphics/graphics-webgl-cmd.js
index a8f7f4bf0b..18c79e62f8 100644
--- a/cocos2d/core/graphics/graphics-webgl-cmd.js
+++ b/cocos2d/core/graphics/graphics-webgl-cmd.js
@@ -30,18 +30,18 @@ var LineJoin = require('./types').LineJoin;
var Earcut = require('./earcut');
+var Helper = require('./Helper');
+
var Vec2 = cc.Vec2;
var Js = cc.js;
// Math
-var PI = 3.14159265358979323846264338327;
-var PI_2 = PI*2;
var INIT_VERTS_SIZE = 32;
-var KAPPA90 = 0.5522847493;
var VERTS_FLOAT_LENGTH = 2;
var VERTS_BYTE_LENGTH = 8;
+var PI = Math.PI;
var min = Math.min;
var max = Math.max;
var ceil = Math.ceil;
@@ -50,7 +50,6 @@ var cos = Math.cos;
var sin = Math.sin;
var atan2 = Math.atan2;
var abs = Math.abs;
-var sign = Math.sign;
function clamp (v, min, max) {
if (v < min) {
@@ -206,86 +205,17 @@ Js.mixin(_p, {
},
//
- arc: function (cx, cy, r, a0, a1, counterclockwise) {
- var a = 0, da = 0, hda = 0, kappa = 0;
- var dx = 0, dy = 0, x = 0, y = 0, tanx = 0, tany = 0;
- var px = 0, py = 0, ptanx = 0, ptany = 0;
- var i, ndivs;
-
- // Clamp angles
- da = a1 - a0;
- if (!counterclockwise) {
- if (abs(da) >= PI * 2) {
- da = PI * 2;
- } else {
- while (da < 0) da += PI * 2;
- }
- } else {
- if (abs(da) >= PI * 2) {
- da = -PI * 2;
- } else {
- while (da > 0) da -= PI * 2;
- }
- }
-
- // Split arc into max 90 degree segments.
- ndivs = max(1, min(abs(da) / (PI * 0.5) + 0.5, 5)) | 0;
- hda = da / ndivs / 2.0;
- kappa = abs(4.0 / 3.0 * (1 - cos(hda)) / sin(hda));
-
- if (counterclockwise) kappa = -kappa;
-
- for (i = 0; i <= ndivs; i++) {
- a = a0 + da * (i / ndivs);
- dx = cos(a);
- dy = sin(a);
- x = cx + dx * r;
- y = cy + dy * r;
- tanx = -dy * r * kappa;
- tany = dx * r * kappa;
-
- if (i === 0) {
- this.moveTo(x, y);
- } else {
- this.bezierCurveTo(px + ptanx, py + ptany, x - tanx, y - tany, x, y);
- }
- px = x;
- py = y;
- ptanx = tanx;
- ptany = tany;
- }
-
- // this.close();
- // this._curPath.complex = false;
+ arc: function (cx, cy, r, startAngle, endAngle, counterclockwise) {
+ Helper.arc(this, cx, cy, r, startAngle, endAngle, counterclockwise);
},
ellipse: function (cx, cy, rx, ry) {
- this.moveTo(cx - rx, cy);
- this.bezierCurveTo(cx - rx, cy + ry * KAPPA90, cx - rx * KAPPA90, cy + ry, cx, cy + ry);
- this.bezierCurveTo(cx + rx * KAPPA90, cy + ry, cx + rx, cy + ry * KAPPA90, cx + rx, cy);
- this.bezierCurveTo(cx + rx, cy - ry * KAPPA90, cx + rx * KAPPA90, cy - ry, cx, cy - ry);
- this.bezierCurveTo(cx - rx * KAPPA90, cy - ry, cx - rx, cy - ry * KAPPA90, cx - rx, cy);
-
- this.close();
+ Helper.ellipse(this, cx, cy, rx, ry);
this._curPath.complex = false;
},
circle: function (cx, cy, r) {
- // this.ellipse(cx, cy, r, r);
- var divs = this._curveDivs(r, PI_2, this._tessTol);
- var step = PI_2 / divs;
-
- this.moveTo(cx, cy + r);
-
- for (var i = 1; i < divs; i++) {
- var angle = step * i;
- var x = r * sin(angle);
- var y = r * cos(angle);
-
- this.lineTo(cx + x, cy + y);
- }
-
- this.close();
+ Helper.ellipse(this, cx, cy, r, r);
this._curPath.complex = false;
},
@@ -299,25 +229,8 @@ Js.mixin(_p, {
},
roundRect: function (x, y, w, h, r) {
- if (r < 0.1) {
- this.rect(x, y, w, h);
- return;
- } else {
- var rx = min(r, abs(w) * 0.5) * sign(w),
- ry = min(r, abs(h) * 0.5) * sign(h);
-
- this.moveTo(x, y + ry);
- this.lineTo(x, y + h - ry);
- this.bezierCurveTo(x, y + h - ry * (1 - KAPPA90), x + rx * (1 - KAPPA90), y + h, x + rx, y + h);
- this.lineTo(x + w - rx, y + h);
- this.bezierCurveTo(x + w - rx * (1 - KAPPA90), y + h, x + w, y + h - ry * (1 - KAPPA90), x + w, y + h - ry);
- this.lineTo(x + w, y + ry);
- this.bezierCurveTo(x + w, y + ry * (1 - KAPPA90), x + w - rx * (1 - KAPPA90), y, x + w - rx, y);
- this.lineTo(x + rx, y);
- this.bezierCurveTo(x + rx * (1 - KAPPA90), y, x, y + ry * (1 - KAPPA90), x, y + ry);
- this.close();
- this._curPath.complex = false;
- }
+ Helper.roundRect(this, x, y, w, h, r);
+ this._curPath.complex = false;
},
fillRect: function (x, y, w, h) {
diff --git a/cocos2d/core/graphics/helper.js b/cocos2d/core/graphics/helper.js
new file mode 100644
index 0000000000..e21bfd6879
--- /dev/null
+++ b/cocos2d/core/graphics/helper.js
@@ -0,0 +1,99 @@
+
+var PI = Math.PI;
+var min = Math.min;
+var max = Math.max;
+var cos = Math.cos;
+var sin = Math.sin;
+var abs = Math.abs;
+var sign = Math.sign;
+
+var KAPPA90 = 0.5522847493;
+
+function arc (ctx, cx, cy, r, startAngle, endAngle, counterclockwise) {
+ counterclockwise = counterclockwise || false;
+
+ var a = 0, da = 0, hda = 0, kappa = 0;
+ var dx = 0, dy = 0, x = 0, y = 0, tanx = 0, tany = 0;
+ var px = 0, py = 0, ptanx = 0, ptany = 0;
+ var i, ndivs;
+
+ // Clamp angles
+ da = endAngle - startAngle;
+ if (counterclockwise) {
+ if (abs(da) >= PI * 2) {
+ da = PI * 2;
+ } else {
+ while (da < 0) da += PI * 2;
+ }
+ } else {
+ if (abs(da) >= PI * 2) {
+ da = -PI * 2;
+ } else {
+ while (da > 0) da -= PI * 2;
+ }
+ }
+
+ // Split arc into max 90 degree segments.
+ ndivs = max(1, min(abs(da) / (PI * 0.5) + 0.5, 5)) | 0;
+ hda = da / ndivs / 2.0;
+ kappa = abs(4.0 / 3.0 * (1 - cos(hda)) / sin(hda));
+
+ if (!counterclockwise) kappa = -kappa;
+
+ for (i = 0; i <= ndivs; i++) {
+ a = startAngle + da * (i / ndivs);
+ dx = cos(a);
+ dy = sin(a);
+ x = cx + dx * r;
+ y = cy + dy * r;
+ tanx = -dy * r * kappa;
+ tany = dx * r * kappa;
+
+ if (i === 0) {
+ ctx.moveTo(x, y);
+ } else {
+ ctx.bezierCurveTo(px + ptanx, py + ptany, x - tanx, y - tany, x, y);
+ }
+ px = x;
+ py = y;
+ ptanx = tanx;
+ ptany = tany;
+ }
+}
+
+function ellipse (ctx, cx, cy, rx, ry) {
+ ctx.moveTo(cx - rx, cy);
+ ctx.bezierCurveTo(cx - rx, cy + ry * KAPPA90, cx - rx * KAPPA90, cy + ry, cx, cy + ry);
+ ctx.bezierCurveTo(cx + rx * KAPPA90, cy + ry, cx + rx, cy + ry * KAPPA90, cx + rx, cy);
+ ctx.bezierCurveTo(cx + rx, cy - ry * KAPPA90, cx + rx * KAPPA90, cy - ry, cx, cy - ry);
+ ctx.bezierCurveTo(cx - rx * KAPPA90, cy - ry, cx - rx, cy - ry * KAPPA90, cx - rx, cy);
+ ctx.close();
+}
+
+function roundRect (ctx, x, y, w, h, r) {
+ if (r < 0.1) {
+ ctx.rect(x, y, w, h);
+ return;
+ } else {
+ var rx = min(r, abs(w) * 0.5) * sign(w),
+ ry = min(r, abs(h) * 0.5) * sign(h);
+
+ ctx.moveTo(x, y + ry);
+ ctx.lineTo(x, y + h - ry);
+ ctx.bezierCurveTo(x, y + h - ry * (1 - KAPPA90), x + rx * (1 - KAPPA90), y + h, x + rx, y + h);
+ ctx.lineTo(x + w - rx, y + h);
+ ctx.bezierCurveTo(x + w - rx * (1 - KAPPA90), y + h, x + w, y + h - ry * (1 - KAPPA90), x + w, y + h - ry);
+ ctx.lineTo(x + w, y + ry);
+ ctx.bezierCurveTo(x + w, y + ry * (1 - KAPPA90), x + w - rx * (1 - KAPPA90), y, x + w - rx, y);
+ ctx.lineTo(x + rx, y);
+ ctx.bezierCurveTo(x + rx * (1 - KAPPA90), y, x, y + ry * (1 - KAPPA90), x, y + ry);
+ ctx.close();
+ }
+}
+
+
+module.exports = {
+ arc: arc,
+ ellipse: ellipse,
+ roundRect: roundRect,
+};
diff --git a/cocos2d/core/label/CCSGLabel.js b/cocos2d/core/label/CCSGLabel.js
index eb2704d396..9140092841 100644
--- a/cocos2d/core/label/CCSGLabel.js
+++ b/cocos2d/core/label/CCSGLabel.js
@@ -358,6 +358,8 @@ _ccsg.Label = _ccsg.Node.extend({
if (!extName) {
this._fontHandle = fontHandle;
this._labelType = _ccsg.Label.Type.SystemFont;
+ this._blendFunc = cc.BlendFunc._alphaPremultiplied();
+ this._renderCmd._needDraw = true;
this._notifyLabelSkinDirty();
this.emit('load');
return;
@@ -365,10 +367,14 @@ _ccsg.Label = _ccsg.Node.extend({
if (extName === ".ttf") {
this._labelType = _ccsg.Label.Type.TTF;
+ this._blendFunc = cc.BlendFunc._alphaPremultiplied();
+ this._renderCmd._needDraw = true;
this._fontHandle = this._loadTTFFont(fontHandle);
} else if (extName === ".fnt") {
//todo add bmfont here
this._labelType = _ccsg.Label.Type.BMFont;
+ this._blendFunc = cc.BlendFunc._alphaNonPremultiplied();
+ this._renderCmd._needDraw = false;
this._initBMFontWithString(this._string, fontHandle, textureUrl);
}
this._notifyLabelSkinDirty();
@@ -484,7 +490,7 @@ _ccsg.Label = _ccsg.Node.extend({
if (CC_EDITOR) {
this._updateLabel();
} else {
- this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.textDirty);
+ this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.textDirty|_ccsg.Node._dirtyFlags.contentDirty);
}
},
_createRenderCmd: function() {
diff --git a/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js b/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js
index af49a464e5..c96985fd4a 100644
--- a/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js
+++ b/cocos2d/core/label/CCSGLabelCanvasRenderCmd.js
@@ -39,6 +39,11 @@
if (opacityDirty)
this._updateDisplayOpacity();
+ if(locFlag & dirtyFlags.contentDirty) {
+ this._notifyRegionStatus && this._notifyRegionStatus(_ccsg.Node.CanvasRenderCmd.RegionStatus.Dirty);
+ this._dirtyFlag &= ~dirtyFlags.contentDirty;
+ }
+
if (colorDirty || opacityDirty || (locFlag & flags.textDirty)) {
this._notifyRegionStatus && this._notifyRegionStatus(_ccsg.Node.CanvasRenderCmd.RegionStatus.Dirty);
this._rebuildLabelSkin();
@@ -112,10 +117,11 @@
maxWidth -= 2 * this._getMargin();
var wrappedWords = [];
//fast return if strArr is empty
- if(strArr.length === 0) {
+ if(strArr.length === 0 || maxWidth < 0) {
wrappedWords.push('');
return wrappedWords;
}
+
var text = strArr;
var allWidth = ctx.measureText(text).width;
while (allWidth > maxWidth && text.length > 1) {
@@ -217,6 +223,11 @@
var canvasWidthNoMargin = this._canvasSize.width - 2 * this._getMargin();
var canvasHeightNoMargin = this._canvasSize.height - 2 * this._getMargin();
+ if(canvasWidthNoMargin < 0 || canvasHeightNoMargin < 0) {
+ fontDesc = '1px ' + fontFamily;
+ this._labelContext.font = fontDesc;
+ return fontDesc;
+ }
totalHeight = canvasHeightNoMargin + 1;
maxLength = canvasWidthNoMargin + 1;
var actualFontSize = this._drawFontsize + 1;
@@ -246,7 +257,6 @@
textFragment = this._fragmentText(paragraphedStrings[i],
canvasWidthNoMargin,
this._labelContext);
- var isBiggerSize = false;
while(j < textFragment.length) {
var measureWidth = this._labelContext.measureText(textFragment[j]).width;
maxLength = measureWidth;
@@ -466,7 +476,7 @@
}
this._texture._textureLoaded = false;
- this._texture.handleLoadedTexture();
+ this._texture.handleLoadedTexture(true);
};
proto._rebuildLabelSkin = function () {
diff --git a/cocos2d/core/label/CCSGLabelWebGLRenderCmd.js b/cocos2d/core/label/CCSGLabelWebGLRenderCmd.js
index bf26a7144a..5247004163 100644
--- a/cocos2d/core/label/CCSGLabelWebGLRenderCmd.js
+++ b/cocos2d/core/label/CCSGLabelWebGLRenderCmd.js
@@ -69,7 +69,8 @@ proto._updateDisplayOpacity = function (parentOpacity) {
proto.transform = function (parentCmd, recursive) {
this.originTransform(parentCmd, recursive);
- var lx = 0, rx = this._labelCanvas.width,
+ var node = this._node,
+ lx = 0, rx = this._labelCanvas.width,
by = 0, ty = this._labelCanvas.height,
wt = this._worldTransform;
@@ -83,6 +84,12 @@ proto.transform = function (parentCmd, recursive) {
vert[3].x = rx * wt.a + by * wt.c + wt.tx; // br
vert[3].y = rx * wt.b + by * wt.d + wt.ty;
+ if (!node._string || (node._labelType !== _ccsg.Label.Type.TTF &&
+ node._labelType !== _ccsg.Label.Type.SystemFont)) {
+ // No culling for bmfont
+ return;
+ }
+
var rect = cc.visibleRect,
vl = rect.left.x, vr = rect.right.x, vt = rect.top.y, vb = rect.bottom.y;
if (((vert[0].x-vl) & (vert[1].x-vl) & (vert[2].x-vl) & (vert[3].x-vl)) >> 31 || // All outside left
@@ -104,17 +111,11 @@ proto.uploadData = function (f32buffer, ui32buffer, vertexDataOffset) {
return 0;
// Fill in vertex data with quad information (4 vertices for sprite)
+ // Use 255 because color has been set when baking label
+ // premultiplied alpha is used for labelTTF and system font
var opacity = this._displayedOpacity;
- var r = this._displayedColor.r,
- g = this._displayedColor.g,
- b = this._displayedColor.b;
- if (node._opacityModifyRGB) {
- var a = opacity / 255;
- r *= a;
- g *= a;
- b *= a;
- }
- this._color[0] = ((opacity<<24) | (b<<16) | (g<<8) | r);
+ this._color[0] = ((opacity<<24) | (opacity<<16) | (opacity<<8) | opacity);
+
var z = node._vertexZ;
var vertices = this._vertices;
diff --git a/cocos2d/core/load-pipeline/CCLoader.js b/cocos2d/core/load-pipeline/CCLoader.js
index 6f21df201c..9168bf4210 100644
--- a/cocos2d/core/load-pipeline/CCLoader.js
+++ b/cocos2d/core/load-pipeline/CCLoader.js
@@ -29,9 +29,8 @@ var Downloader = require('./downloader');
var Loader = require('./loader');
var AssetTable = require('./asset-table');
var callInNextTick = require('../platform/utils').callInNextTick;
+var AutoReleaseUtils = require('./auto-release-utils');
-var downloader = new Downloader();
-var loader = new Loader();
var resources = new AssetTable();
/**
@@ -40,13 +39,15 @@ var resources = new AssetTable();
* @extends Pipeline
* @static
*/
-cc.loader = new Pipeline([
- downloader,
- loader
-]);
+function CCLoader () {
+ var downloader = new Downloader();
+ var loader = new Loader();
+ Pipeline.call(this, [
+ downloader,
+ loader
+ ]);
-JS.mixin(cc.loader, {
/**
* The downloader in cc.loader's pipeline, it's by default the first pipe.
* It's used to download files with several handlers: pure text, image, script, audio, font, uuid.
@@ -54,7 +55,7 @@ JS.mixin(cc.loader, {
* @property downloader
* @type {Object}
*/
- downloader: downloader,
+ this.downloader = downloader;
/**
* The downloader in cc.loader's pipeline, it's by default the second pipe.
@@ -63,7 +64,13 @@ JS.mixin(cc.loader, {
* @property loader
* @type {Object}
*/
- loader: loader,
+ this.loader = loader;
+
+ // assets to release automatically
+ this._autoReleaseSetting = {};
+}
+JS.extend(CCLoader, Pipeline);
+JS.mixin(CCLoader.prototype, {
/**
* Get XMLHttpRequest.
@@ -82,7 +89,7 @@ JS.mixin(cc.loader, {
* @param {Object} extMap Custom supported types with corresponded handler
*/
addDownloadHandlers: function (extMap) {
- downloader.addHandlers(extMap);
+ this.downloader.addHandlers(extMap);
},
/**
@@ -96,7 +103,7 @@ JS.mixin(cc.loader, {
* @param {Object} extMap Custom supported types with corresponded handler
*/
addLoadHandlers: function (extMap) {
- loader.addHandlers(extMap);
+ this.loader.addHandlers(extMap);
},
/**
@@ -295,7 +302,8 @@ JS.mixin(cc.loader, {
completeCallback = type;
type = null;
}
- var uuid = this._getResUuid(url, type);
+ var self = this;
+ var uuid = self._getResUuid(url, type);
if (uuid) {
this.load(
{
@@ -303,7 +311,15 @@ JS.mixin(cc.loader, {
type: 'uuid',
uuid: uuid
},
- completeCallback
+ function (err, asset) {
+ if (asset) {
+ // should not release these assets, even if they are static referenced in the scene.
+ self.setAutoReleaseRecursively(asset, false);
+ }
+ if (completeCallback) {
+ completeCallback(err, asset);
+ }
+ }
);
}
else {
@@ -315,7 +331,9 @@ JS.mixin(cc.loader, {
else {
info = 'Resources url "' + url + '" does not exist.';
}
- completeCallback(new Error(info), null);
+ if (completeCallback) {
+ completeCallback(new Error(info), null);
+ }
});
}
},
@@ -360,6 +378,7 @@ JS.mixin(cc.loader, {
completeCallback = type;
type = null;
}
+ var self = this;
var uuids = resources.getUuidArray(url, type);
var remain = uuids.length;
if (remain > 0) {
@@ -371,18 +390,25 @@ JS.mixin(cc.loader, {
}
if (err) {
aborted = true;
- completeCallback(err, null);
+ if (completeCallback) {
+ completeCallback(err, null);
+ }
return;
}
results.push(res);
--remain;
if (remain === 0) {
- completeCallback(null, results);
+ for (var i = 0; i < results.length; i++) {
+ self.setAutoReleaseRecursively(results[i], false);
+ }
+ if (completeCallback) {
+ completeCallback(null, results);
+ }
}
}
for (var i = 0, len = remain; i < len; ++i) {
var uuid = uuids[i];
- this.load(
+ self.load(
{
id: uuid,
type: 'uuid',
@@ -394,7 +420,9 @@ JS.mixin(cc.loader, {
}
else {
callInNextTick(function () {
- completeCallback(null, []);
+ if (completeCallback) {
+ completeCallback(null, []);
+ }
});
}
},
@@ -429,7 +457,7 @@ JS.mixin(cc.loader, {
/**
* Returns an item in pipeline.
* @method getItem
- * @return {LoadingItem}
+ * @return {Object}
*/
getItem: function (url) {
var item = this._items.map[url];
@@ -489,9 +517,131 @@ JS.mixin(cc.loader, {
*/
releaseAll: function () {
this.clear();
- }
+ },
+
+ // AUTO RELEASE
+
+ _baseRemoveItem: Pipeline.prototype.removeItem,
+
+ // override
+ removeItem: function (key) {
+ var removed = this._baseRemoveItem(key);
+ delete this._autoReleaseSetting[key];
+ return removed;
+ },
+
+ /**
+ * !#en
+ * Indicates whether to release the asset when loading a new scene.
+ * By default, when loading a new scene, all assets in the previous scene will be released or preserved
+ * according to whether the previous scene checked the "Auto Release Assets" option.
+ * On the other hand, assets dynamically loaded by using `cc.loader.loadRes` or `cc.loader.loadResAll`
+ * will not be affected by that option, remain not released by default.
+ * Use this API to change the default behavior on a single asset, to force preserve or release specified asset when scene switching.
+ *
+ * See: {{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}}, {{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}}
+ * !#zh
+ * 设置当场景切换时是否自动释放资源。
+ * 默认情况下,当加载新场景时,旧场景的资源根据旧场景是否勾选“Auto Release Assets”,将会被释放或者保留。
+ * 而使用 `cc.loader.loadRes` 或 `cc.loader.loadResAll` 动态加载的资源,则不受场景设置的影响,默认不自动释放。
+ * 使用这个 API 可以在单个资源上改变这个默认行为,强制在切换场景时保留或者释放指定资源。
+ *
+ * 参考:{{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}},{{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}}
+ *
+ * @example
+ * // auto release the texture event if "Auto Release Assets" disabled in current scene
+ * cc.loader.setAutoRelease(texture2d, true);
+ * // don't release the texture even if "Auto Release Assets" enabled in current scene
+ * cc.loader.setAutoRelease(texture2d, false);
+ * // first parameter can be url
+ * cc.loader.setAutoRelease(audioUrl, false);
+ *
+ * @method setAutoRelease
+ * @param {Asset|String} assetOrUrl - asset object or the raw asset's url
+ * @param {Boolean} autoRelease - indicates whether should release automatically
+ */
+ setAutoRelease: function (assetOrUrl, autoRelease) {
+ var key = AutoReleaseUtils.getKey(this, assetOrUrl);
+ if (key) {
+ this._autoReleaseSetting[key] = !!autoRelease;
+ }
+ else if (CC_DEV) {
+ cc.warn('No need to release non-cached asset.');
+ }
+ },
+
+ /**
+ * !#en
+ * Indicates whether to release the asset and its referenced other assets when loading a new scene.
+ * By default, when loading a new scene, all assets in the previous scene will be released or preserved
+ * according to whether the previous scene checked the "Auto Release Assets" option.
+ * On the other hand, assets dynamically loaded by using `cc.loader.loadRes` or `cc.loader.loadResAll`
+ * will not be affected by that option, remain not released by default.
+ * Use this API to change the default behavior on the specified asset and its recursively referenced assets, to force preserve or release specified asset when scene switching.
+ *
+ * See: {{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}}, {{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}}
+ * !#zh
+ * 设置当场景切换时是否自动释放资源及资源引用的其它资源。
+ * 默认情况下,当加载新场景时,旧场景的资源根据旧场景是否勾选“Auto Release Assets”,将会被释放或者保留。
+ * 而使用 `cc.loader.loadRes` 或 `cc.loader.loadResAll` 动态加载的资源,则不受场景设置的影响,默认不自动释放。
+ * 使用这个 API 可以在指定资源及资源递归引用到的所有资源上改变这个默认行为,强制在切换场景时保留或者释放指定资源。
+ *
+ * 参考:{{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}},{{#crossLink "loader/isAutoRelease:method"}}cc.loader.isAutoRelease{{/crossLink}}
+ *
+ * @example
+ * // auto release the SpriteFrame and its Texture event if "Auto Release Assets" disabled in current scene
+ * cc.loader.setAutoReleaseRecursively(spriteFrame, true);
+ * // don't release the SpriteFrame and its Texture even if "Auto Release Assets" enabled in current scene
+ * cc.loader.setAutoReleaseRecursively(spriteFrame, false);
+ * // don't release the Prefab and all the referenced assets
+ * cc.loader.setAutoReleaseRecursively(prefab, false);
+ *
+ * @method setAutoReleaseRecursively
+ * @param {Asset|String} assetOrUrl - asset object or the raw asset's url
+ * @param {Boolean} autoRelease - indicates whether should release automatically
+ */
+ setAutoReleaseRecursively: function (assetOrUrl, autoRelease) {
+ autoRelease = !!autoRelease;
+ var key = AutoReleaseUtils.getKey(this, assetOrUrl);
+ if (key) {
+ this._autoReleaseSetting[key] = autoRelease;
+
+ var depends = AutoReleaseUtils.getDependsRecursively(key);
+ for (var i = 0; i < depends.length; i++) {
+ var depend = depends[i];
+ this._autoReleaseSetting[depend] = autoRelease;
+ }
+ }
+ else if (CC_DEV) {
+ cc.warn('No need to release non-cached asset.');
+ }
+ },
+
+ /**
+ * !#en
+ * Returns whether the asset is configured as auto released, despite how "Auto Release Assets" property is set on scene asset.
+ *
+ * See: {{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}}, {{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}}
+ *
+ * !#zh
+ * 返回指定的资源是否有被设置为自动释放,不论场景的“Auto Release Assets”如何设置。
+ *
+ * 参考:{{#crossLink "loader/setAutoRelease:method"}}cc.loader.setAutoRelease{{/crossLink}},{{#crossLink "loader/setAutoReleaseRecursively:method"}}cc.loader.setAutoReleaseRecursively{{/crossLink}}
+ * @method isAutoRelease
+ * @param {Asset|String} assetOrUrl - asset object or the raw asset's url
+ * @returns {Boolean}
+ */
+ isAutoRelease: function (assetOrUrl) {
+ var key = AutoReleaseUtils.getKey(this, assetOrUrl);
+ if (key) {
+ return !!this._autoReleaseSetting[key];
+ }
+ return false;
+ },
});
+cc.loader = new CCLoader();
+
if (CC_EDITOR) {
cc.loader.refreshUrl = function (uuid, oldUrl, newUrl) {
this._items.refreshItemUrl(uuid, oldUrl, newUrl);
diff --git a/cocos2d/core/load-pipeline/auto-release-utils.js b/cocos2d/core/load-pipeline/auto-release-utils.js
new file mode 100644
index 0000000000..3a8164aad3
--- /dev/null
+++ b/cocos2d/core/load-pipeline/auto-release-utils.js
@@ -0,0 +1,93 @@
+
+function parseDepends (key, parsed) {
+ var item = cc.loader.getItem(key);
+ if (item) {
+ var depends = item.dependKeys;
+ if (depends) {
+ for (var i = 0; i < depends.length; i++) {
+ var depend = depends[i];
+ if ( !parsed[depend] ) {
+ parsed[depend] = true;
+ parseDepends(depend, parsed);
+ }
+ }
+ }
+ }
+}
+
+function release (loader, key, nextSceneAssets) {
+ if (!nextSceneAssets || nextSceneAssets.indexOf(key) === -1) {
+ var item = loader.getItem(key);
+ if (item) {
+ var removed = loader.removeItem(key);
+ console.log('auto release: ' + key);
+ // TODO: Audio
+ var asset = item.content;
+ if (asset instanceof cc.Texture2D) {
+ cc.textureCache.removeTextureForKey(item.url);
+ }
+ else if (CC_JSB && asset instanceof cc.SpriteFrame && removed) {
+ // for the "Temporary solution" in deserialize.js
+ asset.release();
+ }
+ }
+ }
+}
+
+module.exports = {
+
+ // get asset url or uuid
+ getKey: function (loader, assetOrUrl) {
+ if (assetOrUrl) {
+ if (typeof assetOrUrl === 'string') {
+ return assetOrUrl;
+ }
+ else if (assetOrUrl instanceof cc.Asset) {
+ return assetOrUrl._uuid;
+ }
+ else if (assetOrUrl instanceof cc.Texture2D) {
+ return assetOrUrl.url;
+ }
+ else if (!CC_JSB && assetOrUrl instanceof cc.Audio) {
+ return assetOrUrl.src;
+ }
+ else if (CC_DEV) {
+ cc.warn('unknown asset type');
+ }
+ }
+ return '';
+ },
+
+ // do auto release
+ autoRelease: function (loader, oldSceneAssets, nextSceneAssets) {
+ var releaseSettings = loader._autoReleaseSetting;
+ var i, key;
+
+ // remove ununsed scene assets
+ if (oldSceneAssets) {
+ for (i = 0; i < oldSceneAssets.length; i++) {
+ key = oldSceneAssets[i];
+ if (releaseSettings[key] !== false) {
+ release(loader, key, nextSceneAssets);
+ }
+ }
+ }
+
+ // remove auto release assets
+ var keys = Object.keys(releaseSettings);
+ // releasing asset will change _autoReleaseSetting, so don't use enumerator
+ for (i = 0; i < keys.length; i++) {
+ key = keys[i];
+ if (releaseSettings[key] === true) {
+ release(loader, key, nextSceneAssets);
+ }
+ }
+ },
+
+ // get dependencies not including self
+ getDependsRecursively: function (key) {
+ var depends = {};
+ parseDepends(key, depends);
+ return Object.keys(depends);
+ }
+};
diff --git a/cocos2d/core/load-pipeline/pipeline.js b/cocos2d/core/load-pipeline/pipeline.js
index 27e962969d..5358ed4f2b 100644
--- a/cocos2d/core/load-pipeline/pipeline.js
+++ b/cocos2d/core/load-pipeline/pipeline.js
@@ -509,6 +509,7 @@ JS.mixin(Pipeline.prototype, {
this.flowOut(item);
}
this._items.removeItem(url);
+ return true;
}
else {
return false;
diff --git a/cocos2d/core/load-pipeline/uuid-loader.js b/cocos2d/core/load-pipeline/uuid-loader.js
index a074f4e931..ebc3db3669 100644
--- a/cocos2d/core/load-pipeline/uuid-loader.js
+++ b/cocos2d/core/load-pipeline/uuid-loader.js
@@ -97,6 +97,9 @@ function loadDepends (pipeline, item, asset, tdInfo, deferredLoadRawAssetsInRunt
return callback(null, asset);
}
+ // cache dependencies for auto release
+ var dependKeys = item.dependKeys = [];
+
pipeline.flowInDeps(depends, function (items) {
var item;
for (var src in items) {
@@ -114,12 +117,14 @@ function loadDepends (pipeline, item, asset, tdInfo, deferredLoadRawAssetsInRunt
if (item.complete) {
var value = item.isRawAsset ? item.url : item.content;
dependObj[dependProp] = value;
+ dependKeys.push(item.isRawAsset ? item.url : dependSrc);
}
else {
// item was removed from cache, but ready in pipeline actually
var loadCallback = function (item) {
var value = item.isRawAsset ? item.url : item.content;
this.obj[this.prop] = value;
+ dependKeys.push(item.isRawAsset ? item.url : item.uuid);
};
var target = {
obj: dependObj,
@@ -159,9 +164,9 @@ function canDeferredLoad (asset, item, isScene) {
else if (isScene) {
if (asset instanceof cc.SceneAsset) {
res = asset.asyncLoadAssets;
- if (res) {
- cc.log('deferred load raw assets for ' + item.id);
- }
+ //if (res) {
+ // cc.log('deferred load raw assets for ' + item.id);
+ //}
}
//else if (asset instanceof cc.Scene) {
// deferredLoadRawAssetsInRuntime = asset._asyncLoadAssets;
@@ -210,7 +215,8 @@ function loadUuid (item, callback) {
});
}
catch (e) {
- callback( new Error('Uuid Loader: Deserialize asset [' + item.id + '] failed : ' + e.stack) );
+ var err = CC_JSB ? (e + '\n' + e.stack) : e.stack;
+ callback( new Error('Uuid Loader: Deserialize asset [' + item.id + '] failed : ' + err) );
return;
}
diff --git a/cocos2d/core/platform/CCAssetLibrary.js b/cocos2d/core/platform/CCAssetLibrary.js
index 6601c11166..ccab1468ff 100644
--- a/cocos2d/core/platform/CCAssetLibrary.js
+++ b/cocos2d/core/platform/CCAssetLibrary.js
@@ -27,6 +27,7 @@ var Asset = require('../assets/CCAsset');
var callInNextTick = require('./utils').callInNextTick;
var Loader = require('../load-pipeline/CCLoader');
var PackDownloader = require('../load-pipeline/pack-downloader');
+var AutoReleaseUtils = require('../load-pipeline/auto-release-utils');
/**
* The asset library which managing loading/unloading assets in project.
@@ -67,6 +68,9 @@ var AssetLibrary = {
* @private
*/
loadAsset: function (uuid, callback, options) {
+ if (typeof uuid !== 'string') {
+ return callInNextTick(callback, new Error('[AssetLibrary] uuid must be string'), null);
+ }
// var readMainCache = typeof (options && options.readMainCache) !== 'undefined' ? readMainCache : true;
// var writeMainCache = typeof (options && options.writeMainCache) !== 'undefined' ? writeMainCache : true;
var item = {
@@ -79,7 +83,22 @@ var AssetLibrary = {
if (options && options.existingAsset) {
item.existingAsset = options.existingAsset;
}
- this._loadAssetByUuid(item, callback);
+ Loader.load(item, function (error, asset) {
+ if (error || !asset) {
+ error = new Error('[AssetLibrary] loading JSON or dependencies failed: ' + error.message);
+ }
+ else {
+ if (asset.constructor === cc.SceneAsset) {
+ asset.scene.dependAssets = AutoReleaseUtils.getDependsRecursively(uuid);
+ }
+ if (CC_EDITOR || isScene(asset)) {
+ Loader.removeItem(uuid);
+ }
+ }
+ if (callback) {
+ callback(error, asset);
+ }
+ });
},
getImportedDir: function (uuid) {
@@ -170,36 +189,6 @@ var AssetLibrary = {
}
},
- /**
- * !#zh uuid加载流程:
- * 1. 查找_uuidToAsset,如果已经加载过,直接返回
- * 2. 查找_uuidToCallbacks,如果已经在加载,则注册回调,直接返回
- * 3. 如果没有url,则将uuid直接作为路径
- * 4. 递归加载Asset及其引用到的其它Asset
- *
- * @method _loadAssetByUuid
- * @param {Object} item - loading item including uuid, type and extra infos
- * @param {loadCallback} callback - the callback to receive the asset, can be null
- * @private
- */
- _loadAssetByUuid: function (item, callback) {
- var uuid = item.id;
- if (typeof uuid !== 'string') {
- return callInNextTick(callback, new Error('[AssetLibrary] uuid must be string'), null);
- }
- Loader.load(item, function (error, asset) {
- if (error || !asset) {
- error = new Error('[AssetLibrary] loading JSON or dependencies failed: ' + error.message);
- }
- else if (CC_EDITOR || isScene(asset)) {
- Loader.removeItem(uuid);
- }
- if (callback) {
- callback(error, asset);
- }
- });
- },
-
/**
* @method loadJson
* @param {String} json
@@ -219,8 +208,13 @@ var AssetLibrary = {
if (error) {
error = new Error('[AssetLibrary] loading JSON or dependencies failed: ' + error.message);
}
- else if (CC_EDITOR || isScene(asset)) {
- Loader.removeItem(randomUuid);
+ else {
+ if (asset.constructor === cc.SceneAsset) {
+ asset.scene.dependAssets = AutoReleaseUtils.getDependsRecursively(randomUuid);
+ }
+ if (CC_EDITOR || isScene(asset)) {
+ Loader.removeItem(randomUuid);
+ }
}
asset._uuid = '';
if (callback) {
diff --git a/cocos2d/core/platform/CCClass.js b/cocos2d/core/platform/CCClass.js
index 14a509e95e..4eda3efe1f 100644
--- a/cocos2d/core/platform/CCClass.js
+++ b/cocos2d/core/platform/CCClass.js
@@ -458,21 +458,21 @@ function define (className, baseClasses, mixins, constructor, options) {
return doDefine(className, baseClasses, mixins, constructor, options);
}
-function _checkCtor (ctor) {
+function _checkCtor (ctor, className) {
if (CC_DEV) {
if (CCClass._isCCClass(ctor)) {
- cc.error("Constructor can not be another CCClass");
+ cc.error('ctor of "%s" can not be another CCClass', className);
return;
}
if (typeof ctor !== 'function') {
- cc.error("Constructor of CCClass must be function type");
+ cc.error('ctor of "%s" must be function type', className);
return;
}
if (ctor.length > 0) {
// fireball-x/dev#138: To make a unified CCClass serialization process,
// we don't allow parameters for constructor when creating instances of CCClass.
// For advance user, construct arguments can still get from 'arguments'.
- cc.warn("Can not instantiate CCClass with arguments.");
+ cc.warn('Can not instantiate CCClass "%s" with arguments.', className);
return;
}
}
@@ -530,7 +530,7 @@ function _createCtor (ctor, baseClass, mixins, className, options) {
var superCallBounded = options && baseClass && boundSuperCalls(baseClass, options);
if (ctor && CC_DEV) {
- _checkCtor(ctor);
+ _checkCtor(ctor, className);
}
// get base user constructors
var ctors = [];
@@ -614,21 +614,21 @@ function _boundSuperCall (func, funcName, base) {
var pd = JS.getPropertyDescriptor(base.prototype, funcName);
if (pd) {
superFunc = pd.value;
- // ignore pd.get, assume that function defined by getter is just for warnings
+ // ignore pd.get, assume that function defined by getter is just for warnings
if (typeof superFunc === 'function') {
var hasSuperCall = SuperCallReg.test(func);
if (hasSuperCall) {
return function () {
var tmp = this._super;
-
+
// Add a new ._super() method that is the same method but on the super-Class
this._super = superFunc;
-
+
var ret = func.apply(this, arguments);
-
+
// The method only need to be bound temporarily, so we remove it when we're done executing
this._super = tmp;
-
+
return ret;
};
}
@@ -689,72 +689,6 @@ function declareProperties (cls, className, properties, baseClass, mixins) {
}
}
-/**
- * @class _ComponentAttributes
- * @constructor
- */
-/**
- * Automatically add required component as a dependency.
- *
- * @property requireComponent
- * @type {Component}
- * @default null
- */
-/**
- * If specified to a type, prevents Component of the same type (or subtype) to be added more than once to a Node.
- *
- * @property disallowMultiple
- * @type {Component}
- * @default null
- */
-/**
- * The menu path to register a component to the editors "Component" menu. Eg. "Rendering/Camera".
- *
- * @property menu
- * @type {String}
- * @default ""
- */
-/**
- * Makes a component execute in edit mode.
- * By default, all components are only executed in play mode,
- * which means they will not have their callback functions executed while the Editor is in edit mode.
- *
- * @property executeInEditMode
- * @type {Boolean}
- * @default false
- */
-/**
- * This property is only available if executeInEditMode is true.
- * If specified, the editor's scene view will keep updating this node in 60 fps when it is selected,
- * otherwise, it will update only if necessary.
- *
- * @property playOnFocus
- * @type {Boolean}
- * @default false
- */
-/**
- * Specifying the url of the custom html to draw the component in inspector.
- *
- * @property inspector
- * @type {String}
- * @default ""
- */
-/**
- * Specifying the url of the icon to display in inspector.
- *
- * @property icon
- * @type {String}
- * @default ""
- */
-
-/**
- * The custom documentation URL
- *
- * @property help
- * @type {String}
- * @default ""
- */
-
/**
* @module cc
*/
@@ -762,9 +696,9 @@ function declareProperties (cls, className, properties, baseClass, mixins) {
/**
* !#en Defines a CCClass using the given specification, please see [Class](/en/scripting/class/) for details.
* !#zh 定义一个 CCClass,传入参数必须是一个包含类型参数的字面量对象,具体用法请查阅[类型定义](/zh/scripting/class/)。
- *
+ *
* @method Class
- *
+ *
* @param {Object} [options]
* @param {String} [options.name] - The class name used for serialization.
* @param {Function} [options.extends] - The base class.
@@ -772,9 +706,17 @@ function declareProperties (cls, className, properties, baseClass, mixins) {
* @param {Object} [options.properties] - The property definitions.
* @param {Object} [options.statics] - The static members.
* @param {Function[]} [options.mixins]
- *
- * @param {Object} [options.editor] - attributes for Component, see {{#crossLink "_ComponentAttributes"}}ComponentAttributes{{/crossLink}}.
- *
+ *
+ * @param {Object} [options.editor] - attributes for Component listed below.
+ * @param {Component} [options.editor.requireComponent] - Automatically add required component as a dependency.
+ * @param {Component} [options.editor.disallowMultiple] - If specified to a type, prevents Component of the same type (or subtype) to be added more than once to a Node.
+ * @param {String} [options.editor.menu] - The menu path to register a component to the editors "Component" menu. Eg. "Rendering/Camera".
+ * @param {Boolean} [options.editor.executeInEditMode] - Makes a component execute in edit mode. By default, all components are only executed in play mode, which means they will not have their callback functions executed while the Editor is in edit mode.
+ * @param {Boolean} [options.editor.playOnFocus] - This property is only available if executeInEditMode is true. If specified, the editor's scene view will keep updating this node in 60 fps when it is selected, otherwise, it will update only if necessary.
+ * @param {String} [options.editor.inspector] - Specifying the url of the custom html to draw the component in inspector.
+ * @param {String} [options.editor.icon] - Specifying the url of the icon to display in inspector.
+ * @param {String} [options.editor.help] - The custom documentation UR
+ *
* @param {Function} [options.update] - lifecycle method for Component, see {{#crossLink "Component/update:method"}}{{/crossLink}}
* @param {Function} [options.lateUpdate] - lifecycle method for Component, see {{#crossLink "Component/lateUpdate:method"}}{{/crossLink}}
* @param {Function} [options.onLoad] - lifecycle method for Component, see {{#crossLink "Component/onLoad:method"}}{{/crossLink}}
@@ -786,9 +728,9 @@ function declareProperties (cls, className, properties, baseClass, mixins) {
* @param {Function} [options.onLostFocusInEditor] - lifecycle method for Component, see {{#crossLink "Component/onLostFocusInEditor:method"}}{{/crossLink}}
* @param {Function} [options.onRestore] - for Component only, see {{#crossLink "Component/onRestore:method"}}{{/crossLink}}
* @param {Function} [options._getLocalBounds] - for Component only, see {{#crossLink "Component/_getLocalBounds:method"}}{{/crossLink}}
- *
+ *
* @return {Function} - the created class
- *
+ *
* @example
// define base class
var Node = cc.Class();
@@ -906,6 +848,15 @@ function CCClass (options) {
});
}
else if (CC_DEV) {
+ if (func === false && base && base.prototype) {
+ // check override
+ var overrided = base.prototype[funcName];
+ if (typeof overrided === 'function') {
+ var baseFuc = JS.getClassName(base) + '.' + funcName;
+ var subFuc = name + '.' + funcName;
+ cc.warn('"%s" overrided "%s" but "%s" is defined as "false" so the super method will not be called. You can set "%s" to null to disable this warning.', subFuc, baseFuc, subFuc, subFuc);
+ }
+ }
var correct = TYPO_TO_CORRECT[funcName];
if (correct) {
cc.warn('Unknown type of %s.%s, maybe you want is "%s".', name, funcName, correct);
@@ -1052,10 +1003,10 @@ function parseAttributes (attrs, className, propName) {
}
function parseSimpleAttr (attrName, expectType, attrCreater) {
- var val = attrs[attrName];
- if (val) {
+ if (attrName in attrs) {
+ var val = attrs[attrName];
if (typeof val === expectType) {
- if (typeof attrCreater === 'undefined') {
+ if ( !attrCreater ) {
var attr = {};
attr[attrName] = val;
result.push(attr);
@@ -1065,7 +1016,7 @@ function parseAttributes (attrs, className, propName) {
}
}
else if (CC_DEV) {
- cc.error('The %s of %s.%s must be type %s', attrName, className, propName, expectType);
+ cc.error(ERR_Type, attrName, className, propName, expectType);
}
}
}
@@ -1119,13 +1070,16 @@ function parseAttributes (attrs, className, propName) {
result.push({ min: range[0], max: range[1], step: range[2] });
}
else if (CC_DEV) {
- cc.error('The length of range array must be 2');
+ cc.error('The length of range array must be equal or greater than 2');
}
}
else if (CC_DEV) {
- cc.error(ERR_Type, '"range"', className + '.' + propName, 'array');
+ cc.error(ERR_Type, 'range', className, propName, 'array');
}
}
+ parseSimpleAttr('min', 'number');
+ parseSimpleAttr('max', 'number');
+ parseSimpleAttr('step', 'number');
return result;
}
@@ -1142,5 +1096,5 @@ module.exports = {
};
if (CC_EDITOR) {
- module.exports.getDefault = getDefault;
+ module.exports.getDefault = getDefault;
}
diff --git a/cocos2d/core/platform/CCSys.js b/cocos2d/core/platform/CCSys.js
index 19f2edf221..0c4463e89f 100644
--- a/cocos2d/core/platform/CCSys.js
+++ b/cocos2d/core/platform/CCSys.js
@@ -232,7 +232,7 @@ sys.MACOS = 2;
*/
sys.ANDROID = 3;
/**
- * @property {Number} IOS
+ * @property {Number} IPHONE
* @readOnly
* @default 4
*/
diff --git a/cocos2d/core/platform/CCView.js b/cocos2d/core/platform/CCView.js
index f04fcc921a..ee9ab75303 100644
--- a/cocos2d/core/platform/CCView.js
+++ b/cocos2d/core/platform/CCView.js
@@ -927,32 +927,30 @@ var View = cc._Class.extend({
return this._isRotated ? {x: this._viewPortRect.width - y, y: x} : {x: x, y: y};
},
- _convertMouseToLocationInView: function(point, relatedPos) {
- var locViewPortRect = this._viewPortRect, _t = this;
- point.x = ((_t._devicePixelRatio * (point.x - relatedPos.left)) - locViewPortRect.x) / _t._scaleX;
- point.y = (_t._devicePixelRatio * (relatedPos.top + relatedPos.height - point.y) - locViewPortRect.y) / _t._scaleY;
+ _convertMouseToLocationInView: function (point, relatedPos) {
+ var viewport = this._viewPortRect, _t = this;
+ point.x = ((_t._devicePixelRatio * (point.x - relatedPos.left)) - viewport.x) / _t._scaleX;
+ point.y = (_t._devicePixelRatio * (relatedPos.top + relatedPos.height - point.y) - viewport.y) / _t._scaleY;
},
- _convertTouchesWithScale: function(touches){
- var locViewPortRect = this._viewPortRect, locScaleX = this._scaleX, locScaleY = this._scaleY,
- selTouch, selPoint, selPrePoint, selStartPoint;
- for( var i = 0; i < touches.length; i ++){
+ _convertPointWithScale: function (point) {
+ var viewport = this._viewPortRect;
+ point.x = (point.x - viewport.x) / this._scaleX;
+ point.y = (point.y - viewport.y) / this._scaleY;
+ },
+
+ _convertTouchesWithScale: function (touches) {
+ var viewport = this._viewPortRect, scaleX = this._scaleX, scaleY = this._scaleY,
+ selTouch, selPoint, selPrePoint;
+ for( var i = 0; i < touches.length; i++){
selTouch = touches[i];
- hasStartPoint = selTouch._startPointCaptured;
selPoint = selTouch._point;
selPrePoint = selTouch._prevPoint;
- selPoint.x = (selPoint.x - locViewPortRect.x) / locScaleX;
- selPoint.y = (selPoint.y - locViewPortRect.y) / locScaleY;
- selPrePoint.x = (selPrePoint.x - locViewPortRect.x) / locScaleX;
- selPrePoint.y = (selPrePoint.y - locViewPortRect.y) / locScaleY;
-
- if (!hasStartPoint) {
- selStartPoint = selTouch._startPoint;
- selStartPoint.x = selPoint.x;
- selStartPoint.y = selPoint.y;
- selTouch._startPointCaptured = true;
- }
+ selPoint.x = (selPoint.x - viewport.x) / scaleX;
+ selPoint.y = (selPoint.y - viewport.y) / scaleY;
+ selPrePoint.x = (selPrePoint.x - viewport.x) / scaleX;
+ selPrePoint.y = (selPrePoint.y - viewport.y) / scaleY;
}
}
});
diff --git a/cocos2d/core/platform/deserialize.js b/cocos2d/core/platform/deserialize.js
index d0ac823e65..d94ef033ff 100644
--- a/cocos2d/core/platform/deserialize.js
+++ b/cocos2d/core/platform/deserialize.js
@@ -467,12 +467,13 @@ var _Deserializer = (function () {
* @return {object} the main data(asset)
*/
cc.deserialize = function (data, result, options) {
- var classFinder = (options && options.classFinder) || JS._getClassById;
+ options = options || {};
+ var classFinder = options.classFinder || JS._getClassById;
// 启用 createAssetRefs 后,如果有 url 属性则会被统一强制设置为 { uuid: 'xxx' },必须后面再特殊处理
- var createAssetRefs = (options && options.createAssetRefs) || cc.sys.platform === cc.sys.EDITOR_CORE;
- var target = CC_DEV && (options && options.target);
- var customEnv = options && options.customEnv;
- var ignoreEditorOnly = options && options.ignoreEditorOnly;
+ var createAssetRefs = options.createAssetRefs || cc.sys.platform === cc.sys.EDITOR_CORE;
+ var target = CC_DEV && options.target;
+ var customEnv = options.customEnv;
+ var ignoreEditorOnly = options.ignoreEditorOnly;
if (CC_EDITOR && Buffer.isBuffer(data)) {
data = data.toString();
diff --git a/cocos2d/core/platform/prefab-info.js b/cocos2d/core/platform/prefab-info.js
index 626f06fd37..c238dc65a7 100644
--- a/cocos2d/core/platform/prefab-info.js
+++ b/cocos2d/core/platform/prefab-info.js
@@ -33,20 +33,17 @@ var PrefabInfo = cc.Class({
//},
// the most top node of this prefab in the scene
- root: {
- default: null,
- },
+ root: null,
// 所属的 prefab 资源对象 (cc.Prefab)
// (这个属性在场景中是会保存的,但是不会保存在 prefab 里面,因为创建 prefab 时还不知道自己的 uuid 是多少。)
- asset: {
- default: null,
- },
+ asset: null,
// 用来标识别该节点在 prefab 资源中的位置,因此这个 ID 只需要保证在 Assets 里不重复就行
- fileId: {
- default: ''
- },
+ fileId: '',
+
+ //// Indicates whether this node should always synchronize with the prefab asset.
+ //sync: false,
}
});
diff --git a/cocos2d/core/renderer/RendererWebGL.js b/cocos2d/core/renderer/RendererWebGL.js
index a380424668..8d14db05fc 100644
--- a/cocos2d/core/renderer/RendererWebGL.js
+++ b/cocos2d/core/renderer/RendererWebGL.js
@@ -38,6 +38,7 @@ var _batchedInfo = {
shader: null
},
+ _batchBroken = false,
_indexBuffer = null,
_vertexBuffer = null,
// Total vertex size
@@ -302,6 +303,10 @@ cc.rendererWebGL = {
_batchingSize += increment;
},
+ _breakBatch: function () {
+ _batchBroken = true;
+ },
+
_uploadBufferData: function (cmd) {
if (_batchingSize >= _maxVertexSize) {
this._batchRendering();
@@ -313,7 +318,8 @@ cc.rendererWebGL = {
var blendSrc = cmd._node._blendFunc.src;
var blendDst = cmd._node._blendFunc.dst;
var shader = cmd._shaderProgram;
- if (_batchedInfo.texture !== texture ||
+ if (_batchBroken ||
+ _batchedInfo.texture !== texture ||
_batchedInfo.blendSrc !== blendSrc ||
_batchedInfo.blendDst !== blendDst ||
_batchedInfo.shader !== shader) {
@@ -324,6 +330,7 @@ cc.rendererWebGL = {
_batchedInfo.blendSrc = blendSrc;
_batchedInfo.blendDst = blendDst;
_batchedInfo.shader = shader;
+ _batchBroken = false;
}
// Upload vertex data
diff --git a/cocos2d/core/sprites/CCScale9Sprite.js b/cocos2d/core/sprites/CCScale9Sprite.js
index 35faf7052c..cb29379ebf 100644
--- a/cocos2d/core/sprites/CCScale9Sprite.js
+++ b/cocos2d/core/sprites/CCScale9Sprite.js
@@ -484,28 +484,6 @@ var fillQuadGeneratorBar = {
sprite._uvs = uvs;
}
- //build quads
- if (webgl) {
- vertices[0] = l * wt.a + b * wt.c + wt.tx;
- vertices[1] = l * wt.b + b * wt.d + wt.ty;
- vertices[2] = r * wt.a + b * wt.c + wt.tx;
- vertices[3] = r * wt.b + b * wt.d + wt.ty;
- vertices[4] = l * wt.a + t * wt.c + wt.tx;
- vertices[5] = l * wt.b + t * wt.d + wt.ty;
- vertices[6] = r * wt.a + t * wt.c + wt.tx;
- vertices[7] = r * wt.b + t * wt.d + wt.ty;
- }
- else {
- vertices[0] = l;
- vertices[1] = b;
- vertices[2] = r;
- vertices[3] = b;
- vertices[4] = l;
- vertices[5] = t;
- vertices[6] = r;
- vertices[7] = t;
- }
-
var quadUV = new Array(8);
if (!spriteFrame._rotated) {
quadUV[0] = quadUV[4] = ul;
@@ -533,13 +511,11 @@ var fillQuadGeneratorBar = {
var progressStart, progressEnd;
switch (fillType) {
case FillType.HORIZONTAL:
- progressStart = vertices[0] + (vertices[2] - vertices[0]) * fillStart;
- progressEnd = vertices[0] + (vertices[2] - vertices[0]) * fillEnd;
+ progressStart = l + (r - l) * fillStart;
+ progressEnd = l + (r - l) * fillEnd;
- vertices[0] = progressStart;
- vertices[2] = progressEnd;
- vertices[4] = progressStart;
- vertices[6] = progressEnd;
+ l = progressStart;
+ r = progressEnd;
uvs[0] = quadUV[0] + (quadUV[2] - quadUV[0]) * fillStart;
uvs[1] = quadUV[1];
@@ -551,13 +527,11 @@ var fillQuadGeneratorBar = {
uvs[7] = quadUV[7];
break;
case FillType.VERTICAL:
- progressStart = vertices[1] + (vertices[5] - vertices[1]) * fillStart;
- progressEnd = vertices[1] + (vertices[5] - vertices[1]) * fillEnd;
+ progressStart = b + (t - b) * fillStart;
+ progressEnd = b + (t - b) * fillEnd;
- vertices[1] = progressStart;
- vertices[3] = progressStart;
- vertices[5] = progressEnd;
- vertices[7] = progressEnd;
+ b = progressStart;
+ t = progressEnd;
uvs[0] = quadUV[0];
uvs[1] = quadUV[1] + (quadUV[5] - quadUV[1]) * fillStart;
@@ -572,6 +546,28 @@ var fillQuadGeneratorBar = {
cc.error('Unrecognized fill type in bar fill');
break;
}
+
+ //build vertices
+ if (webgl) {
+ vertices[0] = l * wt.a + b * wt.c + wt.tx;
+ vertices[1] = l * wt.b + b * wt.d + wt.ty;
+ vertices[2] = r * wt.a + b * wt.c + wt.tx;
+ vertices[3] = r * wt.b + b * wt.d + wt.ty;
+ vertices[4] = l * wt.a + t * wt.c + wt.tx;
+ vertices[5] = l * wt.b + t * wt.d + wt.ty;
+ vertices[6] = r * wt.a + t * wt.c + wt.tx;
+ vertices[7] = r * wt.b + t * wt.d + wt.ty;
+ } else{
+ vertices[0] = l;
+ vertices[1] = b;
+ vertices[2] = r;
+ vertices[3] = b;
+ vertices[4] = l;
+ vertices[5] = t;
+ vertices[6] = r;
+ vertices[7] = t;
+ }
+
sprite._vertCount = 4;
cornerId[0] = 0;
@@ -603,8 +599,7 @@ var fillQuadGeneratorRadial = {
while (fillStart < 0.0) fillStart += 1.0;
var cx = fillCenter.x * contentSize.width,
cy = fillCenter.y * contentSize.height;
- var center = cc.v2( webgl ? cx * wt.a + cy * wt.c + wt.tx : cx,
- webgl ? cx * wt.b + cy * wt.d + wt.ty : cy);
+ var center = cc.v2( cx, cy);
fillStart *= Math.PI * 2;
fillRange *= Math.PI * 2;
@@ -697,7 +692,7 @@ var fillQuadGeneratorRadial = {
}
//all in
if(fillRange >= Math.PI * 2) {
- this._generateTriangle(offset, center, this._vertPos[triangle[0]], this._vertPos[triangle[1]]);
+ this._generateTriangle(wt, offset, center, this._vertPos[triangle[0]], this._vertPos[triangle[1]]);
offset += 6;
count += 3;
continue;
@@ -715,10 +710,10 @@ var fillQuadGeneratorRadial = {
} else if (startAngle >= fillStart) {
if(endAngle >= fillEnd) {
//startAngle to fillEnd
- this._generateTriangle(offset, center, this._vertPos[triangle[0]], this._intersectPoint_2[triangleIndex]);
+ this._generateTriangle(wt, offset, center, this._vertPos[triangle[0]], this._intersectPoint_2[triangleIndex]);
} else {
//startAngle to endAngle
- this._generateTriangle(offset, center, this._vertPos[triangle[0]], this._vertPos[triangle[1]]);
+ this._generateTriangle(wt, offset, center, this._vertPos[triangle[0]], this._vertPos[triangle[1]]);
}
offset += 6;
count += 3;
@@ -728,12 +723,12 @@ var fillQuadGeneratorRadial = {
//all out
} else if(endAngle <= fillEnd) {
//fillStart to endAngle
- this._generateTriangle(offset, center, this._intersectPoint_1[triangleIndex], this._vertPos[triangle[1]]);
+ this._generateTriangle(wt, offset, center, this._intersectPoint_1[triangleIndex], this._vertPos[triangle[1]]);
offset += 6;
count += 3;
} else {
//fillStart to fillEnd
- this._generateTriangle(offset, center, this._intersectPoint_1[triangleIndex], this._intersectPoint_2[triangleIndex]);
+ this._generateTriangle(wt, offset, center, this._intersectPoint_1[triangleIndex], this._intersectPoint_2[triangleIndex]);
offset += 6;
count += 3;
}
@@ -751,7 +746,7 @@ var fillQuadGeneratorRadial = {
cornerId[3] = 6;
},
- _generateTriangle: function(offset, vert0, vert1, vert2) {
+ _generateTriangle: function(wt, offset, vert0, vert1, vert2) {
var rawVerts = this.rawVerts;
var rawUvs = this.rawUvs;
var vertices = this.outVerts;
@@ -763,12 +758,22 @@ var fillQuadGeneratorRadial = {
// tl: 0, 1
// bl: 2, 3
// tr: 4, 5
- vertices[offset] = vert0.x;
- vertices[offset+1] = vert0.y;
- vertices[offset+2] = vert1.x;
- vertices[offset+3] = vert1.y;
- vertices[offset+4] = vert2.x;
- vertices[offset+5] = vert2.y;
+ if(webgl) {
+ vertices[offset] = vert0.x * wt.a + vert0.y * wt.c + wt.tx;
+ vertices[offset+1] = vert0.x * wt.b + vert0.y * wt.d + wt.ty;
+ vertices[offset+2] = vert1.x * wt.a + vert1.y * wt.c + wt.tx;
+ vertices[offset+3] = vert1.x * wt.b + vert1.y * wt.d + wt.ty;
+ vertices[offset+4] = vert2.x * wt.a + vert2.y * wt.c + wt.tx;
+ vertices[offset+5] = vert2.x * wt.b + vert2.y * wt.d + wt.ty;
+
+ } else {
+ vertices[offset] = vert0.x;
+ vertices[offset+1] = vert0.y;
+ vertices[offset+2] = vert1.x;
+ vertices[offset+3] = vert1.y;
+ vertices[offset+4] = vert2.x;
+ vertices[offset+5] = vert2.y;
+ }
progressX = (vert0.x - v0x) / (v1x - v0x);
progressY = (vert0.y - v0y) / (v1y - v0y);
@@ -879,18 +884,10 @@ var fillQuadGeneratorRadial = {
x3 = contentSize.width;
y3 = contentSize.height;
- if (webgl) {
- this._vertices[0].x = x0 * wt.a + y0 * wt.c + wt.tx;
- this._vertices[0].y = x0 * wt.b + y0 * wt.d + wt.ty;
- this._vertices[1].x = x3 * wt.a + y3 * wt.c + wt.tx;
- this._vertices[1].y = x3 * wt.b + y3 * wt.d + wt.ty;
- }
- else {
- this._vertices[0].x = x0;
- this._vertices[0].y = y0;
- this._vertices[1].x = x3;
- this._vertices[1].y = y3;
- }
+ this._vertices[0].x = x0;
+ this._vertices[0].y = y0;
+ this._vertices[1].x = x3;
+ this._vertices[1].y = y3;
},
_calculateUVs : function (spriteFrame) {
diff --git a/cocos2d/core/sprites/CCScale9SpriteWebGLRenderCmd.js b/cocos2d/core/sprites/CCScale9SpriteWebGLRenderCmd.js
index 202e755255..0c7ed638bd 100644
--- a/cocos2d/core/sprites/CCScale9SpriteWebGLRenderCmd.js
+++ b/cocos2d/core/sprites/CCScale9SpriteWebGLRenderCmd.js
@@ -103,13 +103,14 @@ proto.uploadData = function (f32buffer, ui32buffer, vertexDataOffset){
if (node._distortionOffset && this._shaderProgram === Scale9Sprite.WebGLRenderCmd._distortionProgram) {
this._shaderProgram.setUniformLocationWith2f(
- Scale9Sprite.WebGLRenderCmd._distortionOffset,
- node._distortionOffset.x, node._distortionOffset.y
+ Scale9Sprite.WebGLRenderCmd._distortionOffset,
+ node._distortionOffset.x, node._distortionOffset.y
);
this._shaderProgram.setUniformLocationWith2f(
- Scale9Sprite.WebGLRenderCmd._distortionTiling,
- node._distortionTiling.x, node._distortionTiling.y
+ Scale9Sprite.WebGLRenderCmd._distortionTiling,
+ node._distortionTiling.x, node._distortionTiling.y
);
+ cc.renderer._breakBatch();
}
// Color & z
diff --git a/cocos2d/core/textures/CCTexture2D.js b/cocos2d/core/textures/CCTexture2D.js
index 7f1e7cf93b..4d48899d12 100644
--- a/cocos2d/core/textures/CCTexture2D.js
+++ b/cocos2d/core/textures/CCTexture2D.js
@@ -96,7 +96,6 @@ var Texture2D = cc.Class(/** @lends cc.Texture2D# */{
this._isGray = false;
}
else if (cc._renderType === game.RENDER_TYPE_WEBGL) {
- this._hasPremultipliedAlpha = false;
this._pixelFormat = Texture2D.defaultPixelFormat;
this._hasPremultipliedAlpha = false;
this._hasMipmaps = false;
diff --git a/cocos2d/core/textures/CCTextureCache.js b/cocos2d/core/textures/CCTextureCache.js
index 657c66a408..54bd675522 100644
--- a/cocos2d/core/textures/CCTextureCache.js
+++ b/cocos2d/core/textures/CCTextureCache.js
@@ -85,7 +85,7 @@ var textureCache = /** @lends cc.textureCache# */{
return this._textures[textureKeyName];
},
- /**
+ /*
* @method getKeyByTexture
* @param {Image} texture
* @return {String|Null}
diff --git a/cocos2d/core/utils/base-node.js b/cocos2d/core/utils/base-node.js
index e102ee02ae..2e727fd3b3 100644
--- a/cocos2d/core/utils/base-node.js
+++ b/cocos2d/core/utils/base-node.js
@@ -1610,7 +1610,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
* treating the returned/received node point as anchor relative.
* !#zh
* 将一个点转换到世界空间坐标系。结果以 Vec2 为单位。
- * 返回值将基于节点坐标。
+ * 返回值将基于世界坐标。
* @method convertToWorldSpaceAR
* @param {Vec2} nodePoint
* @return {Vec2}
diff --git a/cocos2d/core/videoplayer/CCSGVideoPlayer.js b/cocos2d/core/videoplayer/CCSGVideoPlayer.js
index 9ec0d6287f..64dad7323e 100644
--- a/cocos2d/core/videoplayer/CCSGVideoPlayer.js
+++ b/cocos2d/core/videoplayer/CCSGVideoPlayer.js
@@ -73,6 +73,14 @@ _ccsg.VideoPlayer = _ccsg.Node.extend(/** @lends _ccsg.VideoPlayer# */{
return this._renderCmd.isPlaying();
},
+ duration: function () {
+ return this._renderCmd.duration();
+ },
+
+ currentTime: function() {
+ return this._renderCmd.currentTime();
+ },
+
createDomElementIfNeeded: function () {
if (!this._renderCmd._video) {
this._renderCmd.createDom();
@@ -501,6 +509,7 @@ _ccsg.VideoPlayer.EventType = {
};
proto.isPlaying = function () {
+ var video = this._video;
if(_ccsg.VideoPlayer._polyfill.autoplayAfterOperation && this._playing){
setTimeout(function(){
video.play();
@@ -509,4 +518,18 @@ _ccsg.VideoPlayer.EventType = {
return this._playing;
};
+ proto.duration = function () {
+ var video = this._video;
+ if(!video) return -1;
+
+ return video.duration;
+ };
+
+ proto.currentTime = function () {
+ var video = this._video;
+ if(!video) return -1;
+
+ return video.currentTime;
+ };
+
})(_ccsg.VideoPlayer._polyfill);
diff --git a/cocos2d/deprecated.js b/cocos2d/deprecated.js
index 9cc425071f..c36d786f4f 100644
--- a/cocos2d/deprecated.js
+++ b/cocos2d/deprecated.js
@@ -1,11 +1,12 @@
-var js = cc.js;
-// Label
-if (cc.Label) {
- js.obsolete(cc.Label.prototype, 'cc.Label.file', 'font', true);
-}
+if (CC_DEV && typeof eruda === 'undefined') {
-if (CC_DEV) {
+ var js = cc.js;
+
+ // Label
+ if (cc.Label) {
+ js.obsolete(cc.Label.prototype, 'cc.Label.file', 'font', true);
+ }
var INFO = cc._LogInfos.deprecated;
@@ -210,6 +211,11 @@ if (CC_DEV) {
return cc.js.array.copy;
});
+ js.get(cc, 'PI', function () {
+ cc.warn(INFO, 'cc.PI', 'Math.PI');
+ return Math.PI;
+ });
+
/**
* Get the Tile set information for the layer.
* @memberof cc.TiledLayer
@@ -612,4 +618,41 @@ if (CC_DEV) {
'*etTimeScale': 'timeScale',
});
}
+
+ // SCENE
+
+ var ERR = '"%s" is not defined in the Scene, it is only defined in normal nodes.';
+ Object.defineProperties(cc.Scene.prototype, {
+ active: {
+ get: function () {
+ cc.error(ERR, 'active');
+ return true;
+ },
+ set: function () {
+ cc.error(ERR, 'active');
+ }
+ },
+ activeInHierarchy: {
+ get: function () {
+ cc.error(ERR, 'activeInHierarchy');
+ return true;
+ },
+ },
+ getComponent: {
+ get: function () {
+ cc.error(ERR, 'getComponent');
+ return function () {
+ return null;
+ };
+ }
+ },
+ addComponent: {
+ get: function () {
+ cc.error(ERR, 'addComponent');
+ return function () {
+ return null;
+ };
+ }
+ },
+ });
}
diff --git a/cocos2d/shaders/CCGLStateCache.js b/cocos2d/shaders/CCGLStateCache.js
index c92b0a3623..7bfbde03a1 100644
--- a/cocos2d/shaders/CCGLStateCache.js
+++ b/cocos2d/shaders/CCGLStateCache.js
@@ -48,6 +48,9 @@ if (ENABLE_GL_STATE_CACHE) {
var _currBuffers = {};
+ // IE 10 WebGLRenderingContext does not exist
+ if (!window.WebGLRenderingContext) return;
+
WebGLRenderingContext.prototype.glBindBuffer = WebGLRenderingContext.prototype.bindBuffer;
WebGLRenderingContext.prototype.bindBuffer = function (target, buffer) {
if (_currBuffers[target] !== buffer) {
diff --git a/cocos2d/tilemap/CCSGTMXLayer.js b/cocos2d/tilemap/CCSGTMXLayer.js
index 07729a7cbf..da8dacb4a9 100644
--- a/cocos2d/tilemap/CCSGTMXLayer.js
+++ b/cocos2d/tilemap/CCSGTMXLayer.js
@@ -326,7 +326,7 @@ _ccsg.TMXLayer = _ccsg.Node.extend(/** @lends _ccsg.TMXLayer# */{
* Tile set information for the layer
* @return {cc.TMXTilesetInfo}
*/
- getTileset:function () {
+ getTileSet:function () {
return this.tileset;
},
@@ -334,7 +334,7 @@ _ccsg.TMXLayer = _ccsg.Node.extend(/** @lends _ccsg.TMXLayer# */{
* Tile set information for the layer
* @param {cc.TMXTilesetInfo} Var
*/
- setTileset:function (Var) {
+ setTileSet:function (Var) {
this.tileset = Var;
},
@@ -439,7 +439,7 @@ _ccsg.TMXLayer = _ccsg.Node.extend(/** @lends _ccsg.TMXLayer# */{
return tile;
}
- var z = Math.floor(pos.x) + Math.floor(pos.y) * this._layerSize.width;
+ var z = Math.floor(x) + Math.floor(y) * this._layerSize.width;
tile = this._spriteTiles[z];
// tile not created yet. create it
if (!tile) {
@@ -482,7 +482,7 @@ _ccsg.TMXLayer = _ccsg.Node.extend(/** @lends _ccsg.TMXLayer# */{
return null;
}
- var idx = Math.floor(pos.x) + Math.floor(pos.y) * this._layerSize.width;
+ var idx = Math.floor(x) + Math.floor(y) * this._layerSize.width;
// Bits on the far end of the 32-bit global tile ID are used for tile flags
var tile = this.tiles[idx];
diff --git a/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js b/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js
index 43a0867603..0d63c5d17c 100644
--- a/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js
+++ b/cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js
@@ -46,14 +46,17 @@ proto.constructor = _ccsg.TMXLayer.CanvasRenderCmd;
proto.visit = function (parentCmd) {
var node = this._node, renderer = cc.renderer;
+
+ parentCmd = parentCmd || this.getParentRenderCmd();
+ if (parentCmd) {
+ this._curLevel = parentCmd._curLevel + 1;
+ }
+ this._propagateFlagsDown(parentCmd);
+
// quick return if not visible
if (!node._visible)
return;
- parentCmd = parentCmd || this.getParentRenderCmd();
- if (parentCmd)
- this._curLevel = parentCmd._curLevel + 1;
-
if (isNaN(node._customZ)) {
node._vertexZ = renderer.assignedZ;
renderer.assignedZ += renderer.assignedZStep;
@@ -62,7 +65,7 @@ proto.visit = function (parentCmd) {
this._syncStatus(parentCmd);
// Visit children
- var children = node._children, child, cmd,
+ var children = node._children, child,
spTiles = node._spriteTiles,
i, len = children.length;
if (len > 0) {
@@ -71,8 +74,7 @@ proto.visit = function (parentCmd) {
for (i = 0; i < len; i++) {
child = children[i];
if (child._localZOrder < 0) {
- cmd = child._renderCmd;
- cmd.visit(this);
+ child._renderCmd.visit(this);
}
else {
break;
@@ -87,7 +89,7 @@ proto.visit = function (parentCmd) {
child._vertexZ = renderer.assignedZ;
renderer.assignedZ += renderer.assignedZStep;
}
- child._renderCmd.updateStatus(this, true);
+ child._renderCmd.updateStatus();
continue;
}
child._renderCmd.visit(this);
diff --git a/cocos2d/tilemap/CCTMXObjectGroup.js b/cocos2d/tilemap/CCTMXObjectGroup.js
index 4618b0368e..1986a93113 100644
--- a/cocos2d/tilemap/CCTMXObjectGroup.js
+++ b/cocos2d/tilemap/CCTMXObjectGroup.js
@@ -32,10 +32,15 @@
*/
/**
- * @property {Array} properties - Properties from the group. They can be added using tilemap editors
+ * Properties from the group. They can be added using tilemap editors.
+ * @property properties
+ * @type {Array}
*/
+
/**
- * @property {String} groupName - Name of the group
+ * Name of the group
+ * @property groupName
+ * @type {String}
*/
cc.TMXObjectGroup = cc._Class.extend(/** @lends cc.TMXObjectGroup# */{
properties: null,
diff --git a/extensions/anysdk/jsb_anysdk.js b/extensions/anysdk/jsb_anysdk.js
new file mode 100644
index 0000000000..b6bbc8e366
--- /dev/null
+++ b/extensions/anysdk/jsb_anysdk.js
@@ -0,0 +1,2784 @@
+/****************************************************************************
+ Copyright (c) 2013-2016 Chukong Technologies Inc.
+
+ http://www.cocos.com
+
+ Permission is hereby granted, free of Stringge, to any person obtaining a copy
+ of this software and associated engine source code (the "Software"), a limited,
+ worldwide, royalty-free, non-assignable, revocable and non-exclusive license
+ to use Cocos Creator solely to develop games on your target platforms. You shall
+ not use Cocos Creator software for developing other software or tools that's
+ used for developing games. You are not granted to publish, distribute,
+ sublicense, and/or sell copies of Cocos Creator.
+
+ The software or tools in this License Agreement are licensed, not sold.
+ Chukong Aipu reserves all rights not expressly granted to you.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+ ****************************************************************************/
+
+/**
+ * !#en
+ * AnySDK is a third party solution that offers game developers SDK integration without making changes to the SDK's features or parameters.It can do all of this while remaining invisible to your end user.Our goal is to handle all the tedious SDK integration work for you so that you can use your time to focus on the game itself.No matter if it’s the channel SDK, user system, payment system, ad system, statistics system, sharing system or any other type of SDK: we’ll take care of it for you.
+ * !#zh
+ * AnySDK 为 CP 提供一套第三方 SDK 接入解决方案,整个接入过程,不改变任何 SDK 的功能、特性、参数等,对于最终玩家而言是完全透明无感知的。
+目的是让 CP 商能有更多时间更专注于游戏本身的品质,所有 SDK 的接入工作统统交给我们吧。第三方 SDK 包括了渠道SDK、用户系统、支付系统、广告系统、统计系统、分享系统等等。
+ * @module anysdk
+ * @main anysdk
+ */
+var anysdk = anysdk || {};
+/**
+ * !#en
+ * agent manager of plugin
+ * !#zh
+ * 插件管理对象
+ * @property {anysdk.AgentManager} agentManager
+ */
+anysdk.agentManager = anysdk.AgentManager.getInstance();
+
+/**
+ * !#en
+ * agent manager of plugin
+ * !#zh
+ * 插件管理类
+ * @class AgentManager
+ * @constructor
+ */
+anysdk.AgentManager = {
+ /**
+ * !#en
+ * AppKey appSecret and privateKey are the only three parameters generated
+ * after the packing tool client finishes creating the game.
+ * The oauthLoginServer parameter is the API address provided by the game service
+ * to login verification
+ * !#zh
+ * appKey、appSecret、privateKey是通过 AnySDK 客户端工具创建游戏后生成的。
+ * oauthLoginServer参数是游戏服务提供的用来做登陆验证转发的接口地址。
+ * @method init
+ * @param {String} appKey
+ * @param {String} appSecret
+ * @param {String} privateKey
+ * @param {String} oauthLoginServer
+ */
+ init: function(appKey, appSecret, privateKey, oauthLoginServer){
+ },
+
+ /**
+ * !#en
+ * load all plugins, the operation includes SDK`s initialization
+ * !#zh
+ * 加载所有插件,该操作包含了 SDKs 初始化
+ * @method loadAllPlugins
+ * @param {Function} callback
+ * @param {object} target The object to bind to.
+ */
+ loadAllPlugins: function(callback, target){
+ },
+
+ /**
+ * !#en
+ * unload all plugins
+ * !#zh
+ * 卸载插件
+ * @method unloadAllPlugins
+ */
+ unloadAllPlugins: function(){
+ },
+
+ /**
+ * !#en
+ * get user system plugin
+ * !#zh
+ * 获取用户系统插件
+ * @method getUserPlugin
+ * @return {anysdk.ProtocolUser}
+ */
+ getUserPlugin: function(){
+ return anysdk.ProtocolUser;
+ },
+
+ /**
+ * !#en
+ * get IAP system plugins
+ * !#zh
+ * 获取支付系统插件
+ * @method getIAPPlugins
+ * @return {anysdk.ProtocolIAP}
+ */
+ getIAPPlugins: function(){
+ return {anysdk.ProtocolIAP};
+ },
+
+ /**
+ * !#en
+ * get IAP system plugin
+ * !#zh
+ * 获取支付系统插件
+ * @method getIAPPlugin
+ * @return {anysdk.ProtocolIAP}
+ */
+ getIAPPlugin: function(){
+ return anysdk.ProtocolIAP;
+ },
+
+ /**
+ * !#en
+ * get social system plugin
+ * !#zh
+ * 获取社交系统插件
+ * @method getSocialPlugin
+ * @return {anysdk.ProtocolSocial}
+ */
+ getSocialPlugin: function(){
+ return anysdk.ProtocolSocial;
+ },
+
+ /**
+ * !#en
+ * get share system plugin
+ * !#zh
+ * 获取分享系统插件
+ * @method getSharePlugin
+ * @return {anysdk.ProtocolShare}
+ */
+ getSharePlugin: function(){
+ return anysdk.ProtocolShare;
+ },
+
+ /**
+ * !#en
+ * get analytics system plugin
+ * !#zh
+ * 获取统计系统插件
+ * @method getAnalyticsPlugin
+ * @return {anysdk.ProtocolAnalytics}
+ */
+ getAnalyticsPlugin: function(){
+ return anysdk.ProtocolAnalytics;
+ },
+
+ /**
+ * !#en
+ * get ads system plugin
+ * !#zh
+ * 获取广告系统插件
+ * @method getAdsPlugin
+ * @return {anysdk.ProtocolAds}
+ */
+ getAdsPlugin: function(){
+ return anysdk.ProtocolAds;
+ },
+
+ /**
+ * !#en
+ * get push system plugin
+ * !#zh
+ * 获取推送系统插件
+ * @method getPushPlugin
+ * @return {anysdk.ProtocolPush}
+ */
+ getPushPlugin: function(){
+ return anysdk.ProtocolPush;
+ },
+
+ /**
+ * !#en
+ * get REC system plugin
+ * !#zh
+ * 获取录屏系统插件
+ * @method getRECPlugin
+ * @return {anysdk.ProtocolREC}
+ */
+ getRECPlugin: function(){
+ return anysdk.ProtocolREC;
+ },
+
+ /**
+ * !#en
+ * get crash system plugin
+ * !#zh
+ * 获取崩溃分析系统插件
+ * @method getCrashPlugin
+ * @return {anysdk.ProtocolCrash}
+ */
+ getCrashPlugin: function(){
+ return anysdk.ProtocolCrash;
+ },
+
+ /**
+ * !#en
+ * get ad track system plugin
+ * !#zh
+ * 获取广告追踪系统插件
+ * @method getAdTrackingPlugin
+ * @return {anysdk.ProtocolAdTracking}
+ */
+ getAdTrackingPlugin: function(){
+ return anysdk.ProtocolAdTracking;
+ },
+
+ /**
+ * !#en
+ * get custom system plugin
+ * !#zh
+ * 获取自定义系统插件
+ * @method getCustomPlugin
+ * @return {anysdk.ProtocolCustom}
+ */
+ getCustomPlugin: function(){
+ return anysdk.ProtocolCustom;
+ },
+
+ /**
+ * !#en
+ * get custom parameter
+ * !#zh
+ * 获取自定义参数
+ * @method getCustomParam
+ * @return {String}
+ */
+ getCustomParam: function(){
+ return String;
+ },
+
+ /**
+ * !#en
+ * get channel id
+ * !#zh
+ * 获取渠道唯一表示符
+ * @method getChannelId
+ * @return {String}
+ */
+ getChannelId: function(){
+ return String;
+ },
+
+ /**
+ * !#en
+ * get status of analytics
+ * !#zh
+ * 获取统计状态
+ * @method isAnaylticsEnabled
+ * @return {boolean}
+ */
+ isAnaylticsEnabled: function(){
+ return boolean;
+ },
+
+ /**
+ * !#en
+ * set whether to analytics
+ * !#zh
+ * 设置是否统计
+ * @method setIsAnaylticsEnabled
+ * @param {boolean} enabled
+ */
+ setIsAnaylticsEnabled: function(enabled){
+ },
+
+ /**
+ * !#en
+ * destory instance
+ * !#zh
+ * 销毁单例
+ * @method end
+ * @static
+ */
+ end: function(){
+ },
+
+ /**
+ * !#en
+ * get instance
+ * !#zh
+ * 获取单例
+ * @method getInstance
+ * @return {anysdk.AgentManager}
+ * @static
+ */
+ getInstance: function(){
+ return anysdk.AgentManager;
+ },
+};
+
+
+
+/**
+ * !#en
+ * plugin protocol
+ * !#zh
+ * 插件协议
+ * @class PluginProtocol
+ * @brief The super class for all plugins.
+ */
+anysdk.PluginProtocol = {
+
+ /**
+ * !#en
+ * Check whether the function is supported
+ * !#zh
+ * 判断函数是否支持
+ * @method isFunctionSupported
+ * @param {String} functionName
+ * @return {boolean}
+ */
+ isFunctionSupported: function(functionName)
+ {
+ return boolean;
+ },
+
+ /**
+ * !#en
+ * get plugin name
+ * !#zh
+ * 获取插件名称
+ * @method getPluginName
+ * @return {String}
+ */
+ getPluginName: function(){
+ return String;
+ },
+
+ /**
+ * !#en
+ * get plugin version
+ * !#zh
+ * 获取插件版本
+ * @method getPluginVersion
+ * @return {String}
+ */
+ getPluginVersion: function (){
+ return String;
+ },
+
+ /**
+ * !#en
+ * get SDK version
+ * !#zh
+ * 获取 SDK 版本
+ * @method getSDKVersion
+ * @return {String}
+ */
+ getSDKVersion: function(){
+ return String;
+ },
+
+ /**
+ * !#en
+ * void methods for reflections with parameter
+ * !#zh
+ * 反射调用带参数的void方法
+ * @method callFuncWithParam
+ * @param {String} funName
+ * @param {Object|anysdk.PluginParam} [...args] optional arguments
+ * @expose
+ */
+ callFuncWithParam: function(funName){
+ },
+
+ /**
+ * !#en
+ * String methods for reflections with parameter
+ * !#zh
+ * 反射调用带参数的 String 方法
+ * @method callStringFuncWithParam
+ * @param {String} funName
+ * @param {Object|anysdk.PluginParam} [...args] optional arguments
+ * @return {String}
+ * @expose
+ */
+ callStringFuncWithParam: function(funName){
+ return String;
+ },
+
+ /**
+ * !#en
+ * int methods for reflections with parameter
+ * !#zh
+ * 反射调用带参数的 Int 方法
+ * @method callIntFuncWithParam
+ * @param {String} funName
+ * @param {Object|anysdk.PluginParam} [...args] optional arguments
+ * @return {Number} Type:int
+ * @expose
+ */
+ callIntFuncWithParam: function(funName){
+ return int;
+ },
+
+ /**
+ * !#en
+ * boolean methods for reflections with parameter
+ * !#zh
+ * 反射调用带参数的 boolean 方法
+ * @method callBoolFuncWithParam
+ * @param {String} funName
+ * @param {Object|anysdk.PluginParam} [...args] optional arguments
+ * @return {boolean}
+ * @expose
+ */
+ callBoolFuncWithParam: function(funName){
+ return boolean;
+ },
+
+ /**
+ * !#en
+ * float methods for reflections with parameter
+ * !#zh
+ * 反射调用带参数的 float 方法
+ * @method callFloatFuncWithParam
+ * @param {String} funName
+ * @param {Object|anysdk.PluginParam} [...args] optional arguments
+ * @return {Number} Type:float
+ * @expose
+ */
+ callFloatFuncWithParam: function(funName){
+ return float;
+ },
+};
+
+/**
+ * !#en
+ * user protocol
+ * !#zh
+ * 用户系统协议接口
+ * @class ProtocolUser
+ * @extends PluginProtocol
+ */
+anysdk.ProtocolUser = PluginProtocol.extend({
+
+ /**
+ * !#en
+ * login interface
+ * !#zh
+ * 登录接口
+ * @method login
+ * @param {String|Object} [...args] optional arguments
+ */
+ login: function(){
+ },
+
+ /**
+ * !#en
+ * get status of login
+ * !#zh
+ * 获取登录状态
+ * @method isLogined
+ * @return {boolean}
+ */
+ isLogined : function ()
+ {
+ return boolean;
+ },
+
+ /**
+ * !#en
+ * get user ID
+ * !#zh
+ * 获取用户唯一标示符
+ * @method getUserID
+ * @return {String}
+ */
+ getUserID : function ()
+ {
+ return String;
+ },
+
+ /**
+ * !#en
+ * get plugin ID
+ * !#zh
+ * 获取插件ID
+ * @method getPluginId
+ * @return {String}
+ */
+ getPluginId: function (){
+ return String;
+ },
+
+ /**
+ * !#en
+ * set listener
+ * !#zh
+ * 设置用户系统的监听
+ * @method setListener
+ * @param {Function} listener
+ * @param {Object} target
+ */
+ setListener: function(listener, target) {
+ },
+
+ /**
+ * !#en
+ * get listener
+ * !#zh
+ * 获取用户系统的监听
+ * @method getListener
+ * @return {Function} listener
+ */
+ getListener: function() {
+ return Function;
+ },
+
+ /**
+ * !#en
+ * logout
+ * Before to invoke, you need to verdict whether this properties existed
+ * !#zh
+ * 登出,调用前需要判断属性是否存在
+ * @method logout
+ */
+ logout: function(){
+ },
+
+ /**
+ * !#en
+ * show toolbar
+ * Before to invoke, you need to verdict whether this properties existed
+ * !#zh
+ * 显示悬浮窗,调用前需要判断属性是否存在
+ * @method showToolBar
+ * @param {anysdk.ToolBarPlace} place
+ */
+ showToolBar: function(place){
+ },
+
+ /**
+ * !#en
+ * hide toolbar
+ * Before to invoke, you need to verdict whether this properties existed
+ * !#zh
+ * 隐藏悬浮窗,调用前需要判断属性是否存在
+ * @method hideToolBar
+ */
+ hideToolBar: function(){
+ },
+
+ /**
+ * !#en
+ * enter platform
+ * Before to invoke, you need to verdict whether this properties existed
+ * !#zh
+ * 显示平台中心,调用前需要判断属性是否存在
+ * @method enterPlatform
+ */
+ enterPlatform: function(){
+ },
+
+ /**
+ * !#en
+ * show exit page
+ * Before to invoke, you need to verdict whether this properties existed
+ * !#zh
+ * 显示退出界面,调用前需要判断属性是否存在
+ * @method exit
+ */
+ exit: function(){
+ },
+
+ /**
+ * !#en
+ * show pause page
+ * Before to invoke, you need to verdict whether this properties existed
+ * !#zh
+ * 显示暂停界面,调用前需要判断属性是否存在
+ * @method pause
+ */
+ pause: function(){
+ },
+
+ /**
+ * !#en
+ * Real-name registration
+ * Before to invoke, you need to verdict whether this properties existed
+ * !#zh
+ * 实名注册,调用前需要判断属性是否存在
+ * @method realNameRegister
+ */
+ realNameRegister: function(){
+ },
+
+ /**
+ * !#en
+ * Anti-addiction query
+ * Before to invoke, you need to verdict whether this properties existed
+ * !#zh
+ * 防沉迷查询,调用前需要判断属性是否存在
+ * @method antiAddictionQuery
+ */
+ antiAddictionQuery: function(){
+ },
+
+ /**
+ * !#en
+ * submit game role information
+ * Before to invoke, you need to verdict whether this properties existed
+ * !#zh
+ * 提交角色信息,调用前需要判断属性是否存在
+ * @method submitLoginGameRole
+ * @param {Object} data
+ */
+ submitLoginGameRole: function(data){
+ },
+ /**
+ * !#en
+ * get user information
+ * Before to invoke, you need to verdict whether this properties existed
+ * !#zh
+ * 获取用户信息,调用前需要判断属性是否存在
+ * @method getUserInfo
+ * @param {Object} info
+ */
+ getUserInfo:function(info){
+ },
+
+ /**
+ * !#en
+ * set login type
+ * Before to invoke, you need to verdict whether this properties existed
+ * !#zh
+ * 设置登录类型,调用前需要判断属性是否存在
+ * @method getAvailableLoginType
+ * @param {Object} info
+ */
+ getAvailableLoginType:function(info){
+ },
+
+ /**
+ * !#en
+ * set login type
+ * Before to invoke, you need to verdict whether this properties existed
+ * !#zh
+ * 设置登录类型,调用前需要判断属性是否存在
+ * @method setLoginType
+ * @param {String} loginType
+ */
+ setLoginType:function(loginType){
+ },
+
+
+ /**
+ * !#en
+ * send to desktop
+ * Before to invoke, you need to verdict whether this properties existed
+ * !#zh
+ * 发送到桌面,调用前需要判断属性是否存在
+ * @method sendToDesktop
+ */
+ sendToDesktop: function(){
+ },
+
+ /**
+ * !#en
+ * open bbs
+ * Before to invoke, you need to verdict whether this properties existed
+ * !#zh
+ * 打开论坛,调用前需要判断属性是否存在
+ * @method openBBS
+ */
+ openBBS: function(){
+ },
+
+});
+
+
+/**
+ * !#en
+ * IAP protocol
+ * !#zh
+ * 支付系统协议接口
+ * @class ProtocolIAP
+ * @extends PluginProtocol
+ */
+anysdk.ProtocolIAP = PluginProtocol.extend({
+
+ /**
+ * !#en
+ * pay interface
+ * !#zh
+ * 支付接口
+ * @method payForProduct
+ * @param {Object} info Type:map
+ */
+ payForProduct: function(info){
+ },
+
+ /**
+ * !#en
+ * get order ID
+ * !#zh
+ * 获取订单ID
+ * @method getOrderId
+ * @return {String}
+ */
+ getOrderId: function(){
+ return String;
+ },
+
+ /**
+ * !#en
+ * reset the pay status
+ * !#zh
+ * 重置支付状态
+ * @static
+ * @method resetPayState
+ */
+ resetPayState: function(){
+ },
+
+ /**
+ * !#en
+ * get plugin ID
+ * !#zh
+ * 获取插件ID
+ * @method getPluginId
+ * @return {String}
+ */
+ getPluginId: function (){
+ return String;
+ },
+
+ /**
+ * !#en
+ * set listener
+ * !#zh
+ * 设置支付系统的监听
+ * @method setListener
+ * @param {Function} listener
+ * @param {Object} target
+ */
+ setListener: function(listener, target) {
+ },
+
+ /**
+ * !#en
+ * get listener
+ * !#zh
+ * 获取支付系统的监听
+ * @method getListener
+ * @return {Function} listener
+ */
+ getListener: function() {
+ return Function;
+ },
+
+});
+
+/**
+ * !#en
+ * analytics protocol
+ * !#zh
+ * 统计系统协议接口
+ * @class ProtocolAnalytics
+ * @extends PluginProtocol
+ */
+anysdk.ProtocolAnalytics = PluginProtocol.extend({
+
+ /**
+ * !#en
+ * Start a new session.
+ * !#zh
+ * 启动会话
+ * @method startSession
+ */
+ startSession: function(){
+ },
+
+ /**
+ * !#en
+ * Stop a session.
+ * !#zh
+ * 关闭会话
+ * @method stopSession
+ */
+ stopSession: function(){
+ },
+
+ /**
+ * !#en
+ * Set the timeout for expiring a session.
+ * !#zh
+ * 设置会话超时时间
+ * @method setSessionContinueMillis
+ * @param {Number} millis Type: long
+ */
+ setSessionContinueMillis: function(millis){
+ },
+
+ /**
+ * !#en
+ * log an error
+ * !#zh
+ * 捕捉异常
+ * @method logError
+ * @param {String} errorId
+ * @param {String} message
+ */
+ logError: function(errorId, message){
+ },
+
+ /**
+ * !#en
+ * log an event.
+ * !#zh
+ * 捕捉事件
+ * @method logEvent
+ * @param {String} errorId
+ * @param {Object} [...args] optional arguments Type: map
+ */
+ logEvent: function(errorId, paramMap){
+ },
+
+ /**
+ * !#en
+ * Track an event begin.
+ * !#zh
+ * 统计事件开始
+ * @method logTimedEventBegin
+ * @param {String} eventId
+ */
+ logTimedEventBegin: function(eventId){
+ },
+
+ /**
+ * !#en
+ * Track an event end.
+ * !#zh
+ * 统计事件结束
+ * @method logTimedEventEnd
+ * @param {String} eventId
+ */
+ logTimedEventEnd: function(eventId){
+ },
+
+ /**
+ * !#en
+ * set Whether to catch uncaught exceptions to server.
+ * !#zh
+ * 设置是否开启自动异常捕捉
+ * @method setCaptureUncaughtException
+ * @param {boolean} enabled
+ */
+ setCaptureUncaughtException: function(enabled){
+ },
+
+ /**
+ * !#en
+ * analytics account information
+ * !#zh
+ * 统计玩家帐户信息
+ * @method setAccount
+ * @param {Object} paramMap Type: map
+ */
+ setAccount: function(paramMap){
+ },
+
+ /**
+ * !#en
+ * track user to request payment
+ * !#zh
+ * 跟踪用户支付请求
+ * @method onChargeRequest
+ * @param {Object} paramMap Type: map
+ */
+ onChargeRequest: function(paramMap){
+ },
+
+ /**
+ * !#en
+ * track Successful payment
+ * !#zh
+ * 追踪用户支付成功
+ * @method onChargeSuccess
+ * @param {String} orderID
+ */
+ onChargeSuccess: function(orderID){
+ },
+
+ /**
+ * !#en
+ * track failed payment
+ * !#zh
+ * 追踪用户支付失败
+ * @method onChargeFail
+ * @param {Object} paramMap Type: map
+ */
+ onChargeFail: function(paramMap){
+ },
+
+ /**
+ * !#en
+ * track Successful payment
+ * !#zh
+ * 统计玩家支付成功
+ * @method onChargeOnlySuccess
+ * @param {Object} paramMap Type: map
+ */
+ onChargeOnlySuccess: function(paramMap){
+ },
+
+ /**
+ * !#en
+ * track user purchase
+ * !#zh
+ * 统计玩家消费
+ * @method onPurchase
+ * @param {Object} paramMap Type: map
+ */
+ onPurchase: function(paramMap){
+ },
+
+ /**
+ * !#en
+ * track user to use goods
+ * !#zh
+ * 统计玩家使用道具
+ * @method onUse
+ * @param {Object} paramMap Type: map
+ */
+ onUse: function(paramMap){
+ },
+
+ /**
+ * !#en
+ * track user to reward goods
+ * !#zh
+ * 统计玩家获取奖励
+ * @method onReward
+ * @param {Object} paramMap Type: map
+ */
+ onReward: function(paramMap){
+ },
+
+ /**
+ * !#en
+ * start level
+ * !#zh
+ * 开始关卡
+ * @method startLevel
+ * @param {Object} paramMap Type: map
+ */
+ startLevel: function(paramMap){
+ },
+
+ /**
+ * !#en
+ * finish level
+ * !#zh
+ * 结束关卡
+ * @method finishLevel
+ * @param {String} levelID
+ */
+ finishLevel: function(levelID){
+ },
+
+ /**
+ * !#en
+ * failed level
+ * !#zh
+ * 关卡失败
+ * @method failLevel
+ * @param {Object} paramMap Type: map
+ */
+ failLevel: function(paramMap){
+ },
+
+ /**
+ * !#en
+ * start task
+ * !#zh
+ * 开始任务
+ * @method startTask
+ * @param {Object} paramMap Type: map
+ */
+ startTask: function(paramMap){
+ },
+
+ /**
+ * !#en
+ * finish task
+ * !#zh
+ * 完成任务
+ * @method finishTask
+ * @param {String} taskID
+ */
+ finishTask: function(taskID){
+ },
+
+ /**
+ * !#en
+ * failed task
+ * !#zh
+ * 任务失败
+ * @method failTask
+ * @param {Object} paramMap Type: map
+ */
+ failTask: function(paramMap){
+ },
+
+
+
+});
+
+/**
+ * !#en
+ * share protocol
+ * !#zh
+ * 分享系统协议接口
+ * @class ProtocolShare
+ * @extends PluginProtocol
+ */
+anysdk.ProtocolShare = PluginProtocol.extend({
+
+ /**
+ * !#en
+ * share interface
+ * !#zh
+ * 分享
+ * @method share
+ * @param {Object} info Type: map
+ */
+ share: function(info){
+ },
+ /**
+ * !#en
+ * set listener
+ * !#zh
+ * 设置分享系统的监听
+ * @method setListener
+ * @param {Function} listener
+ * @param {Object} target
+ */
+ setListener: function(listener, target) {
+ },
+
+ /**
+ * !#en
+ * get listener
+ * !#zh
+ * 获取分享系统的监听
+ * @method getListener
+ * @return {Function} listener
+ */
+ getListener: function() {
+ return Function;
+ },
+});
+
+
+/**
+ * !#en
+ * ads protocol
+ * !#zh
+ * 广告系统协议接口
+ * @class ProtocolAds
+ * @extends PluginProtocol
+ */
+anysdk.ProtocolAds = PluginProtocol.extend({
+ /*
+ * !#en
+ * show ads view
+ * !#zh
+ * 显示广告
+ * @param {anysdk.AdsType} adstype
+ * @param {Number} idx
+ */
+ showAds: function(adstype, idx){
+ },
+
+ /**
+ * !#en
+ * hide ads view
+ * !#zh
+ * 隐藏广告
+ * @method hideAds
+ * @param {anysdk.AdsType} adstype
+ * @param {Number} idx
+ */
+ hideAds: function (adstype, idx){
+ },
+
+ /**
+ * !#en
+ * preload ads view
+ * !#zh
+ * 预加载广告
+ * @method preloadAds
+ * @param {anysdk.AdsType} adstype
+ * @param {Number} idx
+ */
+ preloadAds: function(adstype, idx){
+ },
+
+ /**
+ * !#en
+ * query points
+ * !#zh
+ * 查询分数
+ * @method queryPoints
+ * @return {Number}
+ */
+ queryPoints : function (){
+ return 0;
+ },
+
+ /**
+ * !#en
+ * get whether the ads type is supported
+ * !#zh
+ * 获取广告类型是否支持
+ * @method isAdTypeSupported
+ * @param {anysdk.AdsType} arg0
+ * @return {boolean}
+ */
+ isAdTypeSupported: function (adstype){
+ return false;
+ },
+
+ /**
+ * !#en
+ * spend point
+ * !#zh
+ * 消费分数
+ * @method spendPoints
+ * @param {Number} points
+ */
+ spendPoints: function(points){
+ },
+
+ /**
+ * !#en
+ * set listener
+ * !#zh
+ * 设置广告系统的监听
+ * @method setListener
+ * @param {Function} listener
+ * @param {Object} target
+ */
+ setListener: function(listener, target) {
+ },
+
+ /**
+ * !#en
+ * get listener
+ * !#zh
+ * 获取广告系统的监听
+ * @method getListener
+ * @return {Function} listener
+ */
+ getListener: function() {
+ return Function;
+ },
+
+});
+
+/**
+ * !#en
+ * social protocol
+ * !#zh
+ * 社交系统协议接口
+ * @class ProtocolSocial
+ * @extends PluginProtocol
+ */
+anysdk.ProtocolSocial = PluginProtocol.extend({
+
+ /**
+ * !#en
+ * sign in
+ * !#zh
+ * 登录
+ * @method signIn
+ */
+ signIn: function(){
+ },
+
+ /**
+ * !#en
+ * sign out
+ * !#zh
+ * 登出
+ * @method signOut
+ */
+ signOut: function(){
+ },
+
+ /**
+ * !#en
+ * submit score
+ * !#zh
+ * 提交分数
+ * @method submitScore
+ * @param {String} leadboardID
+ * @param {Number} score Type: long
+ */
+ submitScore: function(leadboardID, score){
+ },
+
+ /**
+ * !#en
+ * show the id of Leaderboard page
+ * !#zh
+ * 根据唯一标识符显示排行榜
+ * @method showLeaderboard
+ * @param {String} leaderboardID
+ */
+ showLeaderboard: function(leaderboardID){
+ },
+
+ /**
+ * !#en
+ * show the page of achievements
+ * !#zh
+ * 显示成就榜
+ * @method showAchievements
+ */
+ showAchievements: function(){
+ },
+
+ /**
+ * !#en
+ * unlock achievement
+ * !#zh
+ * 解锁成就
+ * @method share
+ * @param {Object} info Type: map
+ */
+ unlockAchievement: function (info){
+ },
+
+ /**
+ * !#en
+ * set listener
+ * !#zh
+ * 设置社交系统的监听
+ * @method setListener
+ * @param {Function} listener
+ * @param {Object} target
+ */
+ setListener: function(listener, target) {
+ },
+
+ /**
+ * !#en
+ * get listener
+ * !#zh
+ * 获取社交系统的监听
+ * @method getListener
+ * @return {Function} listener
+ */
+ getListener: function() {
+ return Function;
+ },
+
+
+ /**
+ * !#en
+ * get friends info
+ * Before to invoke, you need to verdict whether this properties existed
+ * !#zh
+ * 获取好友信息,调用前需要判断属性是否存在
+ * @method pauseRecording
+ */
+ getFriendsInfo: function(){
+ },
+
+ /**
+ * !#en
+ * interact
+ * Before to invoke, you need to verdict whether this properties existed
+ * !#zh
+ * 订阅,调用前需要判断属性是否存在
+ * @method interact
+ */
+ interact: function(){
+ },
+
+ /**
+ * !#en
+ * subscribe
+ * Before to invoke, you need to verdict whether this properties existed
+ * !#zh
+ * 关注,调用前需要判断属性是否存在
+ * @method subscribe
+ */
+ subscribe: function(){
+ },
+});
+
+/**
+ * !#en
+ * push protocol
+ * !#zh
+ * 推送系统协议接口
+ * @class ProtocolPush
+ * @extends PluginProtocol
+ */
+anysdk.ProtocolPush = PluginProtocol.extend({
+
+ /**
+ * !#en
+ * start Push services
+ * !#zh
+ * 启动推送服务
+ * @method startPush
+ */
+ startPush: function(){
+ },
+
+ /**
+ * !#en
+ * close Push services
+ * !#zh
+ * 暂停推送服务
+ * @method closePush
+ */
+ closePush: function(){
+ },
+
+ /**
+ * !#en
+ * delete alias
+ * !#zh
+ * 删除别名
+ * @method delAlias
+ * @param {String} alias
+ */
+ delAlias: function(alias){
+ },
+
+ /**
+ * !#en
+ * set alias
+ * !#zh
+ * 设置别名
+ * @method setAlias
+ * @param {String} alias
+ */
+ setAlias: function(alias){
+ },
+
+ /**
+ * !#en
+ * delete tags
+ * !#zh
+ * 删除标签
+ * @method delTags
+ * @param {Object} tags Type: list
+ */
+ delTags: function(tags){
+ },
+
+ /**
+ * !#en
+ * set tags
+ * !#zh
+ * 设置标签
+ * @method setTags
+ * @param {Object} tags Type: list
+ */
+ setTags: function(tags){
+ },
+
+ /**
+ * !#en
+ * set listener
+ * !#zh
+ * 设置推送系统的监听
+ * @method setListener
+ * @param {Function} listener
+ * @param {Object} target
+ */
+ setListener: function(listener, target) {
+ },
+
+ /**
+ * !#en
+ * get listener
+ * !#zh
+ * 获取推送系统的监听
+ * @method getListener
+ * @return {Function} listener
+ */
+ getListener: function() {
+ return Function;
+ },
+
+});
+
+/**
+ * !#en
+ * crash protocol
+ * !#zh
+ * 崩溃分析系统协议接口
+ * @class ProtocolCrash
+ * @extends PluginProtocol
+ */
+anysdk.ProtocolCrash = PluginProtocol.extend({
+
+ /**
+ * !#en
+ * set user identifier
+ * !#zh
+ * 统计用户唯一标识符
+ * @method setUserIdentifier
+ * @param {String} identifier
+ */
+ setUserIdentifier: function(identifier)
+ {
+ },
+
+ /**
+ * !#en
+ * The uploader captured in exception information
+ * !#zh
+ * 上报异常信息
+ * @method reportException
+ * @param {String} message
+ * @param {String} exception
+ */
+ reportException: function(message, exception){
+ },
+
+ /**
+ * !#en
+ * customize logging
+ * !#zh
+ * 自定义日志记录
+ * @method leaveBreadcrumb
+ * @param {String} breadcrumb
+ */
+ leaveBreadcrumb : function (breadcrumb)
+ {
+ },
+
+});
+
+/**
+ * !#en
+ * REC protocol
+ * !#zh
+ * 录屏系统协议接口
+ * @class ProtocolREC
+ * @extends PluginProtocol
+ */
+anysdk.ProtocolREC = PluginProtocol.extend({
+
+ /**
+ * !#en
+ * share video
+ * !#zh
+ * 分享视频
+ * @method share
+ * @param {Object} info Type: map
+ */
+ share: function (info){
+ },
+
+ /**
+ * !#en
+ * Start to record video
+ * !#zh
+ * 开始录制视频
+ * @method startRecording
+ */
+ startRecording: function(){
+ },
+
+ /**
+ * !#en
+ * Start to record video
+ * !#zh
+ * 结束录制视频
+ * @method stopRecording
+ */
+ stopRecording: function(){
+ },
+
+ /**
+ * !#en
+ * set listener
+ * !#zh
+ * 设置录屏系统的监听
+ * @method setListener
+ * @param {Function} listener
+ * @param {Object} target
+ */
+ setListener: function(listener, target) {
+ },
+
+ /**
+ * !#en
+ * get listener
+ * !#zh
+ * 获取录屏系统的监听
+ * @method getListener
+ * @return {Function} listener
+ */
+ getListener: function() {
+ return Function;
+ },
+
+ /**
+ * !#en
+ * pause to record video
+ * Before to invoke, you need to verdict whether this properties existed
+ * !#zh
+ * 暂停录制视频,调用前需要判断属性是否存在
+ * @method pauseRecording
+ */
+ pauseRecording: function(){
+ },
+
+ /**
+ * !#en
+ * resume to record video
+ * Before to invoke, you need to verdict whether this properties existed
+ * !#zh
+ * 恢复录制视频,调用前需要判断属性是否存在
+ * @method resumeRecording
+ */
+ resumeRecording: function(){
+ },
+
+ /**
+ * !#en
+ * get whether the device is isAvailable
+ * Before to invoke, you need to verdict whether this properties existed
+ * !#zh
+ * 获取设备是否可用,调用前需要判断属性是否存在
+ * @method isAvailable
+ * @return {boolean}
+ */
+ isAvailable: function(){
+ return boolean;
+ },
+
+ /**
+ * !#en
+ * get status of recording
+ * Before to invoke, you need to verdict whether this properties existed
+ * !#zh
+ * 获取录制状态,调用前需要判断属性是否存在
+ * @method isRecording
+ * @return {boolean}
+ */
+ isRecording: function(){
+ return boolean;
+ },
+
+ /**
+ * !#en
+ * show toolbar
+ * Before to invoke, you need to verdict whether this properties existed
+ * !#zh
+ * 显示悬浮窗,调用前需要判断属性是否存在
+ * @method showToolBar
+ */
+ showToolBar: function(){
+ },
+
+ /**
+ * !#en
+ * hide toolbar
+ * Before to invoke, you need to verdict whether this properties existed
+ * !#zh
+ * 隐藏悬浮窗,调用前需要判断属性是否存在
+ * @method hideToolBar
+ */
+ hideToolBar: function(){
+ },
+
+ /**
+ * !#en
+ * show video center
+ * Before to invoke, you need to verdict whether this properties existed
+ * !#zh
+ * 显示视频中心,调用前需要判断属性是否存在
+ * @method showVideoCenter
+ */
+ showVideoCenter: function(){
+ },
+
+ /**
+ * !#en
+ * enter platform
+ * Before to invoke, you need to verdict whether this properties existed
+ * !#zh
+ * 显示平台中心,调用前需要判断属性是否存在
+ * @method enterPlatform
+ */
+ enterPlatform: function(){
+ },
+
+ /**
+ * !#en
+ * Set the video data, it is recommended to check whether are recorded firstly
+ * Before to invoke, you need to verdict whether this properties existed
+ * !#zh
+ * 设置视频相关数据,建议先检查是否是正在录制,调用前需要判断属性是否存在
+ * @method setMetaData
+ * @param {Object} info Type: map
+ */
+ setMetaData: function(info){
+ },
+
+});
+
+
+
+/**
+ * !#en
+ * ad tracking protocol
+ * !#zh
+ * 广告追踪系统协议接口
+ * @class ProtocolAdTracking
+ * @extends PluginProtocol
+ */
+anysdk.ProtocolAdTracking = PluginProtocol.extend({
+
+ /**
+ * !#en
+ * Call this method if you want to track register events as happening during a section.
+ * !#zh
+ * 统计用户注册信息
+ * @method onPay
+ * @param {Object} productInfo Type: map
+ */
+ onPay : function (productInfo){
+ },
+
+ /**
+ * !#en
+ * Call this method if you want to track register events as happening during a section.
+ * !#zh
+ * 统计用户注册信息
+ * @method onLogin
+ * @param {Object} userInfo Type: map
+ */
+ onLogin: function(userInfo){
+ },
+
+ /**
+ * !#en
+ * Call this method if you want to track register events as happening during a section.
+ * !#zh
+ * 统计用户注册信息
+ * @method onRegister
+ * @param {String} userId
+ */
+ onRegister: function(userId){
+ },
+
+ /**
+ * !#en
+ * Call this method if you want to track custom events with parameters as happening during a section.
+ * !#zh
+ * 统计自定义事件
+ * @method trackEvent
+ * @param {String} eventId
+ * @param {Object} paramMap Type: map
+ */
+ trackEvent: function(eventId, paramMap){
+ },
+
+ /**
+ * !#en
+ * Call this method with parameters if you want to create role as happening during a section.
+ * !#zh
+ * 统计创建角色事件,调用前需要判断属性是否存在
+ * @method onCreateRole
+ * @param {Object} userInfo Type: map
+ */
+ onCreateRole: function(userInfo){
+ },
+
+ /**
+ * !#en
+ * Call this method if you want to track levelup events with parameters as happening during a section.
+ * Before to invoke, you need to verdict whether this properties existed
+ * !#zh
+ * 统计角色升级事件,调用前需要判断属性是否存在
+ * @method onLevelUp
+ * @param {Object} info Type: map
+ */
+ onLevelUp: function(info){
+ },
+
+ /**
+ * !#en
+ * Invoke this method with parameters if you want to start to pay as happening during a section.
+ * Before to invoke, you need to verdict whether this properties existed
+ * !#zh
+ * 统计开始充值事件,调用前需要判断属性是否存在
+ * @method onStartToPay
+ * @param {Object} info Type: map
+ */
+ onStartToPay: function(info){
+ },
+
+});
+
+/**
+ * !#en
+ * custom protocol
+ * !#zh
+ * 自定义系统协议接口
+ * @class ProtocolCustom
+ * @extends PluginProtocol
+ */
+anysdk.ProtocolCustom = PluginProtocol.extend({
+ /**
+ * !#en
+ * set listener
+ * !#zh
+ * 设置自定义系统的监听
+ * @method setListener
+ * @param {Function} listener
+ * @param {Object} target
+ */
+ setListener: function(listener, target) {
+ },
+
+ /**
+ * !#en
+ * get listener
+ * !#zh
+ * 获取自定义系统的监听
+ * @method getListener
+ * @return {Function} listener
+ */
+ getListener: function() {
+ return Function;
+ },
+});
+
+/**
+ * !#en
+ * Data structure class
+ * !#zh
+ * 数据结构类
+ * @constructor
+ * @class PluginParam
+ */
+anysdk.PluginParam = {
+ /**
+ * !#en
+ * create plugin parameters
+ * !#zh
+ * 创建对象
+ * @method create
+ * @static
+ * @param {Number|String|Object} parameters
+ * @return {anysdk.PluginParam}
+ */
+ create: function(parameters) {
+ return anysdk.PluginParam
+ },
+};
+
+/**
+ * !#en The callback of user system
+ * !#zh 用户系统回调
+ * @enum UserActionResultCode
+ */
+anysdk.UserActionResultCode = {
+ /**
+ * !#en The callback of succeeding in initing sdk
+ * !#zh 用户系统的初始化成功回调
+ * @property {Number} kInitSuccess
+ */
+ kInitSuccess: 0,
+
+ /**
+ * !#en The callback of failing to init sdk
+ * !#zh 用户系统的初始化失败回调
+ * @property {Number} kInitFail
+ */
+ kInitFail: 1,
+
+ /**
+ * !#en The callback of succeeding in login.
+ * !#zh 用户系统的登录成功回调
+ * @property {Number} kLoginSuccess
+ */
+ kLoginSuccess: 2,
+
+ /**
+ * !#en The callback of network error
+ * !#zh 用户系统的初始化成功回调
+ * @property {Number} kLoginNetworkError
+ */
+ kLoginNetworkError: 3,
+
+ /**
+ * !#en The callback of no need login.
+ * !#zh 用户系统的无需登录回调
+ * @property {Number} kLoginNoNeed
+ */
+ kLoginNoNeed: 4,
+
+ /**
+ * !#en The callback of failing to login
+ * !#zh 用户系统的登录失败回调
+ * @property {Number} kLoginFail
+ */
+ kLoginFail: 5,
+
+ /**
+ * !#en The callback of canceling to login.
+ * !#zh 用户系统的登录取消回调
+ * @property {Number} kLoginCancel
+ */
+ kLoginCancel: 6,
+
+ /**
+ * !#en The callback of succeeding in logout
+ * !#zh 用户系统的登出成功回调
+ * @property {Number} kLogoutSuccess
+ */
+ kLogoutSuccess: 7,
+
+ /**
+ * !#en The callback of failing to logout
+ * !#zh 用户系统的登出失败回调
+ * @property {Number} kLogoutFail
+ */
+ kLogoutFail: 8,
+
+ /**
+ * !#en The callback after enter platform..
+ * !#zh 用户系统的进入平台回调
+ * @property {Number} kPlatformEnter
+ */
+ kPlatformEnter: 9,
+
+ /**
+ * !#en The callback after exit antiAddiction
+ * !#zh 用户系统的退出平台回调
+ * @property {Number} kPlatformBack
+ */
+ kPlatformBack: 10,
+
+ /**
+ * !#en The callback after exit pause page
+ * !#zh 用户系统的暂停界面回调
+ * @property {Number} kPausePage
+ */
+ kPausePage: 11,
+
+ /**
+ * !#en The callback after exit page
+ * !#zh 用户系统的退出界面回调
+ * @property {Number} kExitPage
+ */
+ kExitPage: 12,
+
+ /**
+ * !#en The callback after querying antiAddiction
+ * !#zh 用户系统的实名认证回调
+ * @property {Number} kAntiAddictionQuery
+ */
+ kAntiAddictionQuery: 13,
+
+ /**
+ * !#en The callback after registering realname
+ * !#zh 用户系统的注册账号回调
+ * @property {Number} kRealNameRegister
+ */
+ kRealNameRegister: 14,
+
+ /**
+ * !#en The callback of succeeding in switching account
+ * !#zh 用户系统的切换账号成功回调
+ * @property {Number} kAccountSwitchSuccess
+ */
+ kAccountSwitchSuccess: 15,
+
+ /**
+ * !#en The callback of failing to switch account
+ * !#zh 用户系统的切换账号失败回调
+ * @property {Number} kAccountSwitchFail
+ */
+ kAccountSwitchFail: 16,
+
+ /**
+ * !#en The callback of opening the shop
+ * !#zh 用户系统的打开商店回调
+ * @property {Number} kOpenShop
+ */
+ kOpenShop: 17,
+
+ /**
+ * !#en The callback of canceling to switch account.
+ * !#zh 用户系统的取消切换账号回调
+ * @property {Number} kAccountSwitchCancel
+ */
+ kAccountSwitchCancel: 18,
+
+ /**
+ * !#en extension code of user type
+ * !#zh 用户系统的扩展回调
+ * @property {Number} kUserExtension
+ */
+ kUserExtension: 50000,
+
+ /**
+ * !#en The callback of succeeding in sending to desktop
+ * !#zh 用户系统的发送到桌面成功回调
+ * @property {Number} kSendToDesktopSuccess
+ */
+ kSendToDesktopSuccess: 51001,
+ /**
+ * !#en The callback of failing to sending to desktop
+ * !#zh 用户系统的发送到桌面失败回调
+ * @property {Number} kSendToDesktopFail
+ */
+ kSendToDesktopFail: 51002,
+
+ /**
+ * !#en The callback of succeeding in getting available login type
+ * !#zh 用户系统的获取可登录类型成功回调
+ * @property {Number} kGetAvailableLoginTypeSuccess
+ */
+ kGetAvailableLoginTypeSuccess: 51003,
+
+ /**
+ * !#en The callback of failing to get available login type
+ * !#zh 用户系统的获取可登录类型失败回调
+ * @property {Number} kGetAvailableLoginTypeFail
+ */
+ kGetAvailableLoginTypeFail: 51004 ,
+
+ /**
+ * !#en The callback of succeeding in getting user info
+ * !#zh 用户系统的获取用户信息成功回调
+ * @property {Number} kGetUserInfoSuccess
+ */
+ kGetUserInfoSuccess: 51005,
+
+ /**
+ * !#en The callback of failing in getting user`s info
+ * !#zh 用户系统的获取用户信息失败回调
+ * @property {Number} kGetUserInfoFail
+ */
+ kGetUserInfoFail: 51006 ,
+
+ /**
+ * !#en The callback of succeeding in opening BBS.
+ * !#zh 用户系统的进入论坛成功回调
+ * @property {Number} kOpenBBSSuccess
+ */
+ kOpenBBSSuccess: 51007,
+
+ /**
+ * !#en The callback of failing in opening BBS
+ * !#zh 用户系统的进入论坛失败回调
+ * @property {Number} kOpenBBSFail
+ */
+ kOpenBBSFail: 51008
+
+};
+
+/**
+ * !#en The toolbar position of user type
+ * !#zh 用户系统悬浮窗位置
+ * @enum ToolBarPlace
+ */
+anysdk.ToolBarPlace = {
+ /**
+ * !#en The upper left corner
+ * !#zh 左上方
+ * @property {Number} kToolBarTopLeft
+ */
+ kToolBarTopLeft: 1,
+
+ /**
+ * !#en the upper right corner
+ * !#zh 右上方
+ * @property {Number} kToolBarTopRight
+ */
+ kToolBarTopRight: 2,
+
+ /**
+ * !#en at the left of the center
+ * !#zh 中间偏左
+ * @property {Number} kToolBarMidLeft
+ */
+ kToolBarMidLeft: 3,
+
+ /**
+ * !#en At the right of the center
+ * !#zh 中间偏右
+ * @property {Number} kToolBarMidRight
+ */
+ kToolBarMidRight: 4,
+
+ /**
+ * !#en The lower left corner
+ * !#zh 左下方
+ * @property {Number} kToolBarBottomLeft
+ */
+ kToolBarBottomLeft: 5,
+
+ /**
+ * !#en The lower right corner
+ * !#zh 右下方
+ * @property {Number} kToolBarBottomRight
+ */
+ kToolBarBottomRight: 6
+};
+
+/**
+ * !#en The callback of IAP type
+ * !#zh 支付系统回调
+ * @enum PayResultCode
+ */
+anysdk.PayResultCode = {
+ /**
+ * !#en The callback of succeeding in paying
+ * !#zh 支付系统的支付成功回调
+ * @property {Number} kPaySuccess
+ */
+ kPaySuccess: 0,
+
+ /**
+ * !#en The callback of failing to pay
+ * !#zh 支付系统的支付失败回调
+ * @property {Number} kPayFail
+ */
+ kPayFail: 1,
+
+ /**
+ * !#en The callback of canceling to pay
+ * !#zh 支付系统的支付取消回调
+ * @property {Number} kPayCancel
+ */
+ kPayCancel: 2,
+
+ /**
+ * !#en The callback of network error
+ * !#zh 支付系统的网络失败回调
+ * @property {Number} kPayNetworkError
+ */
+ kPayNetworkError: 3,
+
+ /**
+ * !#en The callback of incompleting info
+ * !#zh 支付系统的支付信息不完整回调
+ * @property {Number} kPayProductionInforIncomplete
+ */
+ kPayProductionInforIncomplete: 4,
+
+ /**
+ * !#en callback of succeeding in initing sdk .
+ * !#zh 支付系统的初始化成功回调
+ * @property {Number} kPayInitSuccess
+ */
+ kPayInitSuccess: 5,
+
+ /**
+ * !#en The callback of failing to init sdk
+ * !#zh 支付系统的初始化失败回调
+ * @property {Number} kPayInitFail
+ */
+ kPayInitFail: 6,
+
+ /**
+ * !#en The callback of paying now
+ * !#zh 支付系统的正在支付回调
+ * @property {Number} kPayNowPaying
+ */
+ kPayNowPaying: 7,
+
+ /**
+ * !#en The callback of succeeding in reStringging
+ * !#zh 支付系统的充值成功回调
+ * @property {Number} kPayReStringgeSuccess
+ */
+ kPayReStringgeSuccess: 8,
+
+ /**
+ * !#en extension code of user type
+ * !#zh 支付系统的扩展回调
+ * @property {Number} kPayExtension
+ */
+ kPayExtension: 30000,
+
+ /**
+ * !#en The callback of re-logining .
+ * !#zh 支付系统的重登陆回调
+ * @property {Number} kPayNeedLoginAgain
+ */
+ kPayNeedLoginAgain: 31002
+};
+
+/**
+ * !#en The callback of requesting reStringge
+ * !#zh 支付系统支付请求回调
+ * @enum PayResultCode
+ */
+anysdk.RequestResultCode = {
+ /**
+ * !#en The callback of succeeding in requesting .
+ * !#zh 支付系统的请求成功回调
+ * @property {Number} kRequestSuccess
+ */
+ kRequestSuccess: 31000,
+
+ /**
+ * !#en The callback of failing to requesting .
+ * !#zh 支付系统的请求失败回调
+ * @property {Number} kRequestFail
+ */
+ kRequestFail: 31001
+};
+
+/**
+ * !#en The enum of account type
+ * !#zh 统计系统的账号类型
+ * @enum AccountType
+ */
+anysdk.AccountType = {
+ /**
+ * !#en The source of account is anonymous
+ * !#zh 账号来源:匿名
+ * @property {Number} ANONYMOUS
+ */
+ ANONYMOUS: 0,
+
+ /**
+ * !#en The source of account is Registered
+ * !#zh 账号来源:注册
+ * @property {Number} REGISTED
+ */
+ REGISTED: 1,
+
+ /**
+ * !#en The source of account is Sina weibo
+ * !#zh 账号来源:新浪微博
+ * @property {Number} SINA_WEIBO
+ */
+ SINA_WEIBO: 2,
+
+ /**
+ * !#en The source of account is Tencent weibo
+ * !#zh 账号来源:腾讯微博
+ * @property {Number} TENCENT_WEIBO
+ */
+ TENCENT_WEIBO: 3,
+
+ /**
+ * !#en The source of account is QQ
+ * !#zh 账号来源:QQ
+ * @property {Number} QQ
+ */
+ QQ: 4,
+
+ /**
+ * !#en The source of account is ND91
+ * !#zh 账号来源:ND91
+ * @property {Number} ND91
+ */
+ ND91: 5
+};
+
+/**
+ * !#en The enum of account operation
+ * !#zh 统计系统的账号操作
+ * @enum AccountOperate
+ */
+anysdk.AccountOperate = {
+ /**
+ * !#en Login
+ * !#zh 登录
+ * @property {Number} LOGIN
+ */
+ LOGIN: 0,
+
+ /**
+ * !#en Logout
+ * !#zh 登出
+ * @property {Number} LOGOUT
+ */
+ LOGOUT: 1,
+
+ /**
+ * !#en Register
+ * !#zh 注册
+ * @property {Number} REGISTER
+ */
+ REGISTER: 2
+};
+
+/**
+ * !#en The enum of gender
+ * !#zh 统计系统的账号性别
+ * @enum AccountGender
+ */
+anysdk.AccountGender = {
+ /**
+ * !#en Male
+ * !#zh 男性
+ * @property {Number} MALE
+ */
+ MALE: 0,
+ /**
+ * !#en Female
+ * !#zh 女性
+ * @property {Number} FEMALE
+ */
+ FEMALE: 1,
+
+ /**
+ * !#en Unknow
+ * !#zh 未知
+ * @property {Number} UNKNOWN
+ */
+ UNKNOWN: 2
+};
+
+/**
+ * !#en The enum of task type
+ * !#zh 统计系统的任务类型
+ * @enum TaskType
+ */
+anysdk.TaskType = {
+ /**
+ * !#en Guide line
+ * !#zh 新手引导
+ * @property {Number} GUIDE_LINE
+ */
+ GUIDE_LINE: 0,
+
+ /**
+ * !#en Main line
+ * !#zh 主线
+ * @property {Number} MAIN_LINE
+ */
+ MAIN_LINE: 1,
+
+ /**
+ * !#en Branch line
+ * !#zh 支线
+ * @property {Number} BRANCH_LINE
+ */
+ BRANCH_LINE: 2,
+
+ /**
+ * !#en Daily
+ * !#zh 日常
+ * @property {Number} DAILY
+ */
+ DAILY: 3,
+
+ /**
+ * !#en Activity
+ * !#zh 活动
+ * @property {Number} ACTIVITY
+ */
+ ACTIVITY: 4,
+
+ /**
+ * !#en Other
+ * !#zh 其他
+ * @property {Number} OTHER
+ */
+ OTHER: 5
+};
+
+/**
+ * !#en The callback of share system
+ * !#zh 分享系统回调
+ * @enum ShareResultCode
+ */
+anysdk.ShareResultCode = {
+ /**
+ * !#en The callback of failing to sharing
+ * !#zh 分享系统的分享成功回调
+ * @property {Number} kShareSuccess
+ */
+ kShareSuccess: 0,
+
+ /**
+ * !#en The callback of failing to share
+ * !#zh 分享系统的分享失败回调
+ * @property {Number} kShareFail
+ */
+ kShareFail: 1,
+
+ /**
+ * !#en The callback of canceling to share
+ * !#zh 分享系统的分享取消回调
+ * @property {Number} kShareCancel
+ */
+ kShareCancel: 2,
+
+ /**
+ * !#en The callback of network error
+ * !#zh 分享系统的网络错误回调
+ * @property {Number} kShareNetworkError
+ */
+ kShareNetworkError: 3,
+
+ /**
+ * !#en The extension code of share system
+ * !#zh 分享系统的扩展回调
+ * @property {Number} kShareExtension
+ */
+ kShareExtension: 10000
+};
+
+/**
+ * !#en The callback of social system
+ * !#zh 社交系统回调
+ * @enum SocialRetCode
+ */
+anysdk.SocialRetCode = {
+
+ /**
+ * !#en The callback of succeeding in submiting.
+ * !#zh 社交系统的成功提交回调
+ * @property {Number} kScoreSubmitSucceed
+ */
+ kScoreSubmitSucceed: 1,
+
+ /**
+ * !#en The callback of failing to submit.
+ * !#zh 社交系统的提交失败回调
+ * @property {Number} kScoreSubmitfail
+ */
+ kScoreSubmitfail: 2,
+
+ /**
+ * !#en The is callback of succeeding in unlocking
+ * !#zh 社交系统的解锁成功回调
+ * @property {Number} kAchUnlockSucceed
+ */
+ kAchUnlockSucceed: 3,
+
+ /**
+ * !#en The callback of failing to unlock.
+ * !#zh 社交系统的解锁失败回调
+ * @property {Number} kAchUnlockFail
+ */
+ kAchUnlockFail: 4,
+
+ /**
+ * !#en The callback of succeeding to login.
+ * !#zh 社交系统的登录成功回调
+ * @property {Number} kSocialSignInSucceed
+ */
+ kSocialSignInSucceed: 5,
+
+ /**
+ * !#en The callback of failing to login
+ * !#zh 社交系统的登录失败回调
+ * @property {Number} kSocialSignInFail
+ */
+ kSocialSignInFail: 6,
+
+ /**
+ * !#en The callback of succeeding to logout.
+ * !#zh 社交系统的登出成功回调
+ * @property {Number} kSocialSignOutSucceed
+ */
+ kSocialSignOutSucceed: 7,
+
+ /**
+ * !#en The callback of failing to logout.
+ * !#zh 社交系统的登出失败回调
+ * @property {Number} kSocialSignOutFail
+ */
+ kSocialSignOutFail: 8,
+
+ /**
+ * !#en The callback of getting friends`s .
+ * !#zh 社交系统的获取好友回调
+ * @property {Number} kSocialGetGameFriends
+ */
+ kSocialGetGameFriends: 9,
+
+ /**
+ * !#en The extension code of social system
+ * !#zh 社交系统的扩展回调
+ * @property {Number} kSocialExtensionCode
+ */
+ kSocialExtensionCode:20000,
+
+ /**
+ * !#en The callback of succeeding in getting friends`s info
+ * !#zh 社交系统的获取好友信息成功回调
+ * @property {Number} kSocialGetFriendsInfoSuccess
+ */
+ kSocialGetFriendsInfoSuccess: 21001,
+
+ /**
+ * !#en The callback of failing in getting friends`s info.
+ * !#zh 社交系统的获取好友信息失败回调
+ * @property {Number} kSocialGetFriendsInfoFail
+ */
+ kSocialGetFriendsInfoFail: 21002,
+
+ /**
+ * !#en The callback of subscription
+ * !#zh 社交系统的订阅回调
+ * @property {Number} kSocialAlreadySubscription
+ */
+ kSocialAlreadySubscription: 21003,
+
+ /**
+ * !#en The callback No subscription.
+ * !#zh 社交系统的无需订阅回调
+ * @property {Number} kSocialNoSubscription
+ */
+ kSocialNoSubscription: 21004,
+
+ /**
+ * !#en The callback of failing in subscription
+ * !#zh 社交系统的订阅失败回调
+ * @property {Number} kSocialSubscriptionFail
+ */
+ kSocialSubscriptionFail: 21005,
+};
+
+/**
+ * !#en The callback of ads system
+ * !#zh 广告系统回调
+ * @enum AdsResultCode
+ */
+anysdk.AdsResultCode = {
+
+ /**
+ * !#en The callback : the ad is received
+ * !#zh 广告系统的接受广告回调
+ * @property {Number} kAdsReceived
+ */
+ kAdsReceived: 0,
+
+ /**
+ * !#en The callback: the advertisement dismissed.
+ * !#zh 广告系统的显示广告回调
+ * @property {Number} kAdsShown
+ */
+ kAdsShown: 1,
+
+ /**
+ * !#en The callback: the advertisement dismissed.
+ * !#zh 广告系统的广告消失回调
+ * @property {Number} kAdsDismissed
+ */
+ kAdsDismissed: 2,
+
+ /**
+ * !#en The callback: the points spend succeed.
+ * !#zh 广告系统的花费积分成功回调
+ * @property {Number} kPointsSpendSucceed
+ */
+ kPointsSpendSucceed: 3,
+
+ /**
+ * !#en The callback: the points spend failed.
+ * !#zh 广告系统的花费积分失败回调
+ * @property {Number} kPointsSpendFailed
+ */
+ kPointsSpendFailed: 4,
+
+ /**
+ * !#en The callback of network error
+ * !#zh 广告系统的网络错误回调
+ * @property {Number} kNetworkError
+ */
+ kNetworkError: 5,
+
+ /**
+ * !#en The callback of Unknown error.
+ * !#zh 广告系统的未知错误回调
+ * @property {Number} kUnknownError
+ */
+ kUnknownError: 6,
+
+ /**
+ * !#en The callback of Changing the point of offerwall.
+ * !#zh 广告系统的积金墙积金变化回调
+ * @property {Number} kOfferWallOnPointsChanged
+ */
+ kOfferWallOnPointsChanged: 7,
+
+ /**
+ * !#en The callback of receive the reward of rewardedvideo
+ * !#zh 广告系统的激励视频奖励回调
+ * @property {Number} kRewardedVideoWithReward
+ */
+ kRewardedVideoWithReward: 8,
+
+ /**
+ * !#en The callback of finishing IAP ad
+ * !#zh 广告系统的应用内支付广告回调
+ * @property {Number} kInAppPurchaseFinished
+ */
+ kInAppPurchaseFinished: 9,
+
+ /**
+ * !#en The callback of the advertisement clicked
+ * !#zh 广告系统的广告被点击回调
+ * @property {Number} kAdsClicked
+ */
+ kAdsClicked: 10,
+
+ /**
+ * !#en The extension code
+ * !#zh 广告系统的扩展回调
+ * @property {Number} kAdsExtension
+ */
+ kAdsExtension: 40000
+};
+
+/**
+ * !#en The enum of ads position
+ * !#zh 广告位置
+ * @enum AdsPos
+ */
+anysdk.AdsPos = {
+
+ /**
+ * !#en In the center
+ * !#zh 中间
+ * @property {Number} kPosCenter
+ */
+ kPosCenter:0,
+
+ /**
+ * !#en at the top of center
+ * !#zh 上方
+ * @property {Number} kPosTop
+ */
+ kPosTop:1,
+
+ /**
+ * !#en the upper left corner
+ * !#zh 左上方
+ * @property {Number} kPosTopLeft
+ */
+ kPosTopLeft:2,
+
+ /**
+ * !#en the upper right corner
+ * !#zh 右上方
+ * @property {Number} kPosTopRight
+ */
+ kPosTopRight:3,
+
+ /**
+ * !#en at the bottom of the center
+ * !#zh 底部
+ * @property {Number} kPosBottom
+ */
+ kPosBottom: 4,
+
+ /**
+ * !#en the lower left corner
+ * !#zh 左下方
+ * @property {Number} kPosBottomLeft
+ */
+ kPosBottomLeft: 5,
+
+ /**
+ * !#en the lower right corner
+ * !#zh 右下方
+ * @property {Number} kPosBottomRight
+ */
+ kPosBottomRight: 6
+};
+
+/**
+ * !#en The enum of ads type
+ * !#zh 广告类型
+ * @enum AdsType
+ */
+anysdk.AdsType = {
+
+ /**
+ * !#en Banner Ads
+ * !#zh 横幅广告
+ * @property {Number} AD_TYPE_BANNER
+ */
+ AD_TYPE_BANNER: 0,
+
+ /**
+ * !#en Full Screen Ads
+ * !#zh 插屏广告
+ * @property {Number} AD_TYPE_FULLSCREEN
+ */
+ AD_TYPE_FULLSCREEN: 1,
+
+ /**
+ * !#en Move APP Ads
+ * !#zh 精品广告
+ * @property {Number} AD_TYPE_MOREAPP
+ */
+ AD_TYPE_MOREAPP: 2,
+
+ /**
+ * !#en Offer Wall Ads
+ * !#zh 积金墙
+ * @property {Number} AD_TYPE_OFFERWALL
+ */
+ AD_TYPE_OFFERWALL: 3,
+
+ /**
+ * !#en Reward Video Ads
+ * !#zh 激励视频
+ * @property {Number} AD_TYPE_REWARDEDVIDEOc
+ */
+ AD_TYPE_REWARDEDVIDEO: 4,
+
+ /**
+ * !#en Native Express Ads
+ * !#zh 原生广告
+ * @property {Number} AD_TYPE_NATIVEEXPRESS
+ */
+ AD_TYPE_NATIVEEXPRESS: 5,
+
+ /**
+ * !#en Native Advanced Ads
+ * !#zh 改进版原生广告
+ * @property {Number} AD_TYPE_NATIVEADVANCED
+ */
+ AD_TYPE_NATIVEADVANCED: 6
+};
+
+/**
+ * !#en The callback of push system
+ * !#zh 推送系统回调
+ * @enum PushActionResultCode
+ */
+anysdk.PushActionResultCode = {
+ /**
+ * !#en The callback of Receiving Message
+ * !#zh 推送系统的接受消息回调
+ * @property {Number} kPushReceiveMessage
+ */
+ kPushReceiveMessage: 0,
+
+ /**
+ * !#en The extension code
+ * !#zh 推送系统的扩展回调
+ * @property {Number} kPushExtensionCode
+ */
+ kPushExtensionCode: 60000
+};
+
+/**
+ * !#en The callback of custom system
+ * !#zh 自定义系统回调
+ * @enum CustomResultCode
+ */
+anysdk.CustomResultCode = {
+ /**
+ * !#en The extension code of custom system
+ * !#zh 自定义系统扩展回调
+ * @property {Number} kCustomExtension
+ */
+ kCustomExtension:80000
+} ;
+
+/**
+ * !#en The callback of REC system
+ * !#zh 录屏系统回调
+ * @enum RECResultCode
+ */
+anysdk.RECResultCode = {
+
+ /**
+ * !#en The callback of succeeding in initing sdk
+ * !#zh 录屏系统的初始化成功回调
+ * @property {Number} kRECInitSuccess
+ */
+ kRECInitSuccess: 0,
+
+ /**
+ * !#en The callback of failing to init sdk.
+ * !#zh 录屏系统的初始化失败回调
+ * @property {Number} kRECInitFail
+ */
+ kRECInitFail: 1,
+
+ /**
+ * !#en The callback of starting to record.
+ * !#zh 录屏系统的开始录屏回调
+ * @property {Number} kRECStartRecording
+ */
+ kRECStartRecording: 2,
+
+ /**
+ * !#en The callback of stoping to record.
+ * !#zh 录屏系统的停止录屏回调
+ * @property {Number} kRECStopRecording
+ */
+ kRECStopRecording: 3,
+
+ /**
+ * !#en The callback of pausing to record.
+ * !#zh 录屏系统的暂停录屏回调
+ * @property {Number} kRECPauseRecording
+ */
+ kRECPauseRecording: 4,
+
+ /**
+ * !#en The callback of resuming to record.
+ * !#zh 录屏系统的恢复录屏回调
+ * @property {Number} kRECResumeRecording
+ */
+ kRECResumeRecording: 5,
+
+ /**
+ * !#en The callback of entering SDK`s page.
+ * !#zh 录屏系统的初进入SDK界面回调
+ * @property {Number} kRECEnterSDKPage
+ */
+ kRECEnterSDKPage: 6,
+
+ /**
+ * !#en The callback of quiting SDK`s page.
+ * !#zh 录屏系统的退出SDK界面回调
+ * @property {Number} kRECQuitSDKPage
+ */
+ kRECQuitSDKPage: 7,
+
+ /**
+ * !#en The callback of succeeding in initing sdk
+ * !#zh 录屏系统的分享成功回调
+ * @property {Number} kRECShareSuccess
+ */
+ kRECShareSuccess: 8,
+
+ /**
+ * !#en The callback of failing to share.
+ * !#zh 录屏系统的分享失败回调
+ * @property {Number} kRECShareFail
+ */
+ kRECShareFail: 9,/**< enum value is callback of failing to share. */
+
+ /**
+ * !#en The extension code of REC system
+ * !#zh 录屏系统的扩展回调
+ * @property {Number} kRECExtension
+ */
+ kRECExtension: 90000
+};
+
+
+
+
+
+
+
+
+
+
diff --git a/extensions/ccpool/CCPool.js b/extensions/ccpool/CCPool.js
index 384dac278e..a39b9f56db 100644
--- a/extensions/ccpool/CCPool.js
+++ b/extensions/ccpool/CCPool.js
@@ -38,6 +38,7 @@
* cc.pool 是一个单例对象,用作为对象缓存池。
* 它可以帮助您提高游戏性能,适用于优化对象的反复创建和销毁
* @class pool
+ * @deprecated !#en Please use cc.NodePool instead !#zh 请使用 cc.NodePool 代替
*/
cc.pool = /** @lends cc.pool# */{
_pool: {},
diff --git a/extensions/spine/SkeletonData.js b/extensions/spine/SkeletonData.js
index 191de16798..37aba4712d 100644
--- a/extensions/spine/SkeletonData.js
+++ b/extensions/spine/SkeletonData.js
@@ -128,7 +128,7 @@ var SkeletonData = cc.Class({
// -------------------------------------------------
/**
- * @property {Texture2D} textures
+ * @property {cc.Texture2D} textures
*/
textures: {
default: [],
diff --git a/jsb/jsb-action.js b/jsb/jsb-action.js
index a7f4cddaad..f48501f545 100644
--- a/jsb/jsb-action.js
+++ b/jsb/jsb-action.js
@@ -205,6 +205,7 @@ cc.Node.prototype.runAction = function (action) {
action.release();
action._retained = false;
}
+ return action;
};
function getSGTarget (target) {
@@ -347,19 +348,19 @@ var actionUpdate = {
'JumpTo': syncPositionUpdate,
'JumpBy': syncPositionUpdate,
'Place': syncPositionUpdate,
+ 'CardinalSplineTo': syncPositionUpdate,
'RotateTo': syncRotationUpdate,
'RotateBy': syncRotationUpdate,
'ScaleTo': syncScaleUpdate,
- 'ScaleBy': syncScaleUpdate,
'RemoveSelf': syncRemoveSelfUpdate,
'SkewTo': syncSkewUpdate,
- 'SkewBy': syncSkewUpdate,
'Blink': syncOpacityUpdate,
'FadeIn': syncOpacityUpdate,
'FadeOut': syncOpacityUpdate,
'FadeTo': syncOpacityUpdate,
'TintTo': syncColorUpdate,
- 'TintBy': syncColorUpdate
+ 'TintBy': syncColorUpdate,
+ 'BezierBy': syncPositionUpdate
};
for (var key in actionUpdate) {
diff --git a/jsb/jsb-director.js b/jsb/jsb-director.js
index 691b65ef70..88a5463a10 100644
--- a/jsb/jsb-director.js
+++ b/jsb/jsb-director.js
@@ -25,6 +25,8 @@
'use strict';
+var AutoReleaseUtils = require('../cocos2d/core/load-pipeline/auto-release-utils');
+
// cc.director
cc.js.mixin(cc.director, {
/**
@@ -122,8 +124,7 @@ cc.js.mixin(cc.director, {
var persistNodes = game._persistRootNodes;
if (scene instanceof cc.Scene) {
- // ensure scene initialized
- scene._load();
+ scene._load(); // ensure scene initialized
}
// detach persist nodes
@@ -134,8 +135,13 @@ cc.js.mixin(cc.director, {
game._ignoreRemovePersistNode = null;
}
- // unload scene
var oldScene = this._scene;
+
+ // auto release assets
+ var autoReleaseAssets = oldScene && oldScene.autoReleaseAssets && oldScene.dependAssets;
+ AutoReleaseUtils.autoRelease(cc.loader, autoReleaseAssets, scene.dependAssets);
+
+ // unload scene
if (cc.isValid(oldScene)) {
oldScene.destroy();
}
diff --git a/jsb/jsb-game.js b/jsb/jsb-game.js
index 60321f0599..78f75bd92e 100644
--- a/jsb/jsb-game.js
+++ b/jsb/jsb-game.js
@@ -259,6 +259,12 @@ cc.js.mixin(cc.game, {
}
});
-
cc.EventTarget.call(cc.game);
-cc.js.addon(cc.game, cc.EventTarget.prototype);
\ No newline at end of file
+cc.js.addon(cc.game, cc.EventTarget.prototype);
+
+cc.eventManager.addCustomListener(cc.game.EVENT_HIDE, function () {
+ cc.game.emit(cc.game.EVENT_HIDE, cc.game);
+});
+cc.eventManager.addCustomListener(cc.game.EVENT_SHOW, function () {
+ cc.game.emit(cc.game.EVENT_SHOW, cc.game);
+});
\ No newline at end of file
diff --git a/jsb/jsb-tex-sprite-frame.js b/jsb/jsb-tex-sprite-frame.js
index 0da03497f3..769d1704fc 100644
--- a/jsb/jsb-tex-sprite-frame.js
+++ b/jsb/jsb-tex-sprite-frame.js
@@ -32,6 +32,7 @@ require('../cocos2d/core/assets/CCAsset');
// cc.SpriteFrameAnimation = cc.Animation;
// cc.textureCache.cacheImage
+
cc.textureCache._textures = {};
cc.textureCache.cacheImage = function (key, texture) {
if (texture instanceof cc.Texture2D) {
@@ -56,8 +57,10 @@ var prototype = cc.Texture2D.prototype;
prototype.isLoaded = function () {
return true;
};
+prototype.releaseTexture = prototype.releaseGLTexture;
prototype.getPixelWidth = prototype.getPixelsWide;
prototype.getPixelHeight = prototype.getPixelsHigh;
+prototype.description = prototype.getDescription;
cc.js.get(prototype, 'pixelWidth', prototype.getPixelWidth);
cc.js.get(prototype, 'pixelHeight', prototype.getPixelHeight);
@@ -73,7 +76,6 @@ prototype.textureLoaded = function () {
return this.getTexture() !== null;
};
-// cc.SpriteFrame
prototype._ctor = function (filename, rect, rotated, offset, originalSize) {
this._name = '';
if (filename !== undefined) {
diff --git a/package.json b/package.json
index e506a21978..09e8334775 100644
--- a/package.json
+++ b/package.json
@@ -11,6 +11,7 @@
"test": "gulp test"
},
"devDependencies": {
+ "async": "1.5.2",
"browserify": "13.0.0",
"chalk": "1.1.0",
"del": "1.2.0",
@@ -27,7 +28,6 @@
"gulp-rename": "1.2.2",
"gulp-shell": "0.4.1",
"gulp-size": "2.1.0",
- "async": "1.5.2",
"gulp-sourcemaps": "1.5.2",
"gulp-uglify": "1.5.3",
"gulp-util": "3.0.6",