- * Sets the arrival order when this node has a same ZOrder with other children.
+ * Update the arrival order.
*
* A node which called addChild subsequently will take a larger arrival order,
* If two children have the same Z order, the child with larger arrival order will be drawn later.
*
* Sets view's target-densitydpi for android mobile browser. it can be set to:
@@ -250,14 +258,14 @@ var View = cc._Class.extend({
if (!this.__resizeWithBrowserSize) {
this.__resizeWithBrowserSize = true;
window.addEventListener('resize', this._resizeEvent);
- window.addEventListener('orientationchange', this._resizeEvent);
+ window.addEventListener('orientationchange', this._orientationChange);
}
} else {
//disable
if (this.__resizeWithBrowserSize) {
this.__resizeWithBrowserSize = false;
window.removeEventListener('resize', this._resizeEvent);
- window.removeEventListener('orientationchange', this._resizeEvent);
+ window.removeEventListener('orientationchange', this._orientationChange);
}
}
},
@@ -298,7 +306,7 @@ var View = cc._Class.extend({
var h = __BrowserGetter.availHeight(cc.game.frame);
var isLandscape = w >= h;
- if (CC_EDITOR || !cc.sys.isMobile ||
+ if (CC_EDITOR || !this._orientationChanging || !cc.sys.isMobile ||
(isLandscape && this._orientation & cc.macro.ORIENTATION_LANDSCAPE) ||
(!isLandscape && this._orientation & cc.macro.ORIENTATION_PORTRAIT)) {
locFrameSize.width = w;
@@ -316,6 +324,7 @@ var View = cc._Class.extend({
cc.container.style.transformOrigin = '0px 0px 0px';
this._isRotated = true;
}
+ this._orientationChanging = false;
},
// hack
@@ -416,6 +425,55 @@ var View = cc._Class.extend({
return this._retinaEnabled;
},
+ /**
+ * !#en Whether to Enable on anti-alias
+ * !#zh 控制抗锯齿是否开启
+ * @method enableAntiAlias
+ * @param {Boolean} enabled - Enable or not anti-alias
+ */
+ enableAntiAlias: function (enabled) {
+ if (this._antiAliasEnabled === enabled) {
+ return;
+ }
+ this._antiAliasEnabled = enabled;
+ if(cc._renderType === cc.game.RENDER_TYPE_WEBGL) {
+ var map = cc.loader._items.map;
+ for (var key in map) {
+ var item = map[key];
+ var tex = item && item.content instanceof cc.Texture2D ? item.content : null;
+ if (tex) {
+ if (enabled) {
+ tex.setAntiAliasTexParameters();
+ }
+ else {
+ tex.setAliasTexParameters();
+ }
+ }
+ }
+ }
+ else if(cc._renderType === cc.game.RENDER_TYPE_CANVAS) {
+ var ctx = cc._canvas.getContext('2d');
+ ctx.imageSmoothingEnabled = enabled;
+ ctx.mozImageSmoothingEnabled = enabled;
+ // refresh canvas
+ var dirtyRegion = cc.rendererCanvas._dirtyRegion;
+ if (dirtyRegion) {
+ var oldRegion = new cc.Region();
+ oldRegion.setTo(0, 0, cc.visibleRect.width, cc.visibleRect.height);
+ dirtyRegion.addRegion(oldRegion);
+ }
+ }
+ },
+
+ /**
+ * !#en Returns whether the current enable on anti-alias
+ * !#zh 返回当前是否抗锯齿
+ * @method isAntiAliasEnabled
+ * @return {Boolean}
+ */
+ isAntiAliasEnabled: function () {
+ return this._antiAliasEnabled;
+ },
/**
* If enabled, the application will try automatically to enter full screen mode on mobile devices
* You can pass true as parameter to enable it and disable it by passing false.
@@ -704,6 +762,9 @@ var View = cc._Class.extend({
// reset director's member variables to fit visible rect
director.setGLDefaultValues();
}
+ else if (cc._renderType === cc.game.RENDER_TYPE_CANVAS) {
+ cc.renderer._allNeedDraw = true;
+ }
this._originalScaleX = this._scaleX;
this._originalScaleY = this._scaleY;
@@ -875,32 +936,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;
}
}
});
@@ -1058,7 +1117,15 @@ cc.ContentStrategy = cc._Class.extend(/** @lends cc.ContentStrategy# */{
*/
var EqualToFrame = cc.ContainerStrategy.extend({
apply: function (view) {
+ var frameH = view._frameSize.height, containerStyle = cc.container.style;
this._setupContainer(view, view._frameSize.width, view._frameSize.height);
+ // Setup container's margin and padding
+ if (view._isRotated) {
+ containerStyle.marginLeft = frameH + 'px';
+ }
+ else {
+ containerStyle.margin = '0px';
+ }
}
});
diff --git a/cocos2d/core/platform/attribute.js b/cocos2d/core/platform/attribute.js
index cefd57fac9..ec6625a082 100644
--- a/cocos2d/core/platform/attribute.js
+++ b/cocos2d/core/platform/attribute.js
@@ -351,10 +351,6 @@ function RawType (typename) {
};
}
-function Range (min, max) {
- return { min: min, max: max };
-}
-
module.exports = {
attr: attr,
getClassAttrs: getClassAttrs,
@@ -366,5 +362,4 @@ module.exports = {
ObjectType: ObjectType,
RawType: RawType,
ScriptUuid: {}, // the value will be represented as a uuid string
- Range: Range
};
diff --git a/cocos2d/core/platform/deserialize.js b/cocos2d/core/platform/deserialize.js
index 76b5d66d11..d94ef033ff 100644
--- a/cocos2d/core/platform/deserialize.js
+++ b/cocos2d/core/platform/deserialize.js
@@ -27,9 +27,6 @@ var JS = require('./js');
var CCObject = require('./CCObject');
var Attr = require('./attribute');
-var EDITOR = CC_DEV;
-var ENABLE_TARGET = EDITOR;
-
// HELPERS
/**
@@ -67,22 +64,18 @@ var Details = function () {
*/
this.rawProp = '';
- if (EDITOR) {
+ if (CC_DEV) {
/**
- * 用户可以指定一个在反序列化结束时会被触发的回调,该回调会传回反序列化时统计到的所有解析过的字段。
+ * 用户可以指定一个在反序列化过程中会被触发的回调,该回调会在反序列化之前调用,并且传回反序列化时解析到的字段。
* NOTE:
+ * - only available in editor
* - 会被传回的字段仅限于非 Asset 类型,并且如果字段值为 null 或 undefined,则可能不会被传回。
- * - 该回调在 DeserializeInfo 第一次调用 reset 时就会被清空。
- * @callback visitorInEditor
- * @param {Object[]} objs
- * @param {String[]} propNames
- * @param {Object} _Deserializer
+ * @callback visit
+ * @param {Object} obj
+ * @param {String} propName
* @private
*/
- this.visitorInEditor = null;
-
- this.visitObjList = [];
- this.visitPropList = [];
+ this.visit = null;
}
};
/**
@@ -95,17 +88,15 @@ Details.prototype.reset = function () {
this.rawProp = '';
//this.rawObjList.length = 0;
//this.rawPropList.length = 0;
-
- if (EDITOR) {
- this.visitorInEditor = null;
- this.visitObjList.length = 0;
- this.visitPropList.length = 0;
- }
};
-if (EDITOR) {
- Details.prototype.visitLater = function (obj, propName) {
- this.visitObjList.push(obj);
- this.visitPropList.push(propName);
+if (CC_DEV) {
+ Details.prototype.assignAssetsBy = function (getter) {
+ for (var i = 0, len = this.uuidList.length; i < len; i++) {
+ var uuid = this.uuidList[i];
+ var obj = this.uuidObjList[i];
+ var prop = this.uuidPropList[i];
+ obj[prop] = getter(uuid);
+ }
};
}
/**
@@ -122,28 +113,6 @@ Details.prototype.getUuidOf = function (obj, propName) {
}
return "";
};
-/**
- * @method assignAssetsBy
- * @param {Function} getter
- * @return {Boolean} success
- */
-Details.prototype.assignAssetsBy = function (getter) {
- var success = true;
- for (var i = 0, len = this.uuidList.length; i < len; i++) {
- var uuid = this.uuidList[i];
- var asset = getter(uuid);
- if (asset) {
- var obj = this.uuidObjList[i];
- var prop = this.uuidPropList[i];
- obj[prop] = asset;
- }
- else {
- cc.error('Failed to assign asset: ' + uuid);
- success = false;
- }
- }
- return success;
-};
/**
* @method push
* @param {Object} obj
@@ -159,13 +128,11 @@ Details.prototype.push = function (obj, propName, uuid) {
// IMPLEMENT OF DESERIALIZATION
var _Deserializer = (function () {
- ///**
- // * @param {Boolean} isEditor - if false, "editorOnly" properties will be discarded
- // */
- function _Deserializer(jsonObj, result, target, classFinder, customEnv) {
+ function _Deserializer(jsonObj, result, target, classFinder, customEnv, ignoreEditorOnly) {
this._classFinder = classFinder;
- if (ENABLE_TARGET) {
+ if (CC_DEV) {
this._target = target;
+ this._ignoreEditorOnly = ignoreEditorOnly;
}
this._idList = [];
this._idObjList = [];
@@ -181,7 +148,7 @@ var _Deserializer = (function () {
for (var i = 0; i < refCount; i++) {
if (jsonArray[i]) {
var mainTarget;
- if (ENABLE_TARGET) {
+ if (CC_DEV) {
mainTarget = (i === 0 && target);
}
this.deserializedList[i] = _deserializeObject(this, jsonArray[i], mainTarget);
@@ -209,14 +176,9 @@ var _Deserializer = (function () {
// dereference
_dereference(this);
-
- // call visitor after all properties initialized
- if (EDITOR) {
- this._callVisitorInEditor();
- }
}
- var _dereference = function (self) {
+ function _dereference (self) {
// 这里不采用遍历反序列化结果的方式,因为反序列化的结果如果引用到复杂的外部库,很容易堆栈溢出。
var deserializedList = self.deserializedList;
var idPropList = self._idPropList;
@@ -227,18 +189,9 @@ var _Deserializer = (function () {
var id = idList[i];
idObjList[i][propName] = deserializedList[id];
}
- };
-
- if (EDITOR) {
- _Deserializer.prototype._callVisitorInEditor = function () {
- var result = this.result;
- if (result.visitorInEditor) {
- result.visitorInEditor(result.visitObjList, result.visitPropList, this);
- }
- };
}
- // 和 _deserializeObject 不同的地方在于会判断 id 和 uuid
+ // 和 _deserializeObject 不同的地方在于会判断 id 和 uuid
_Deserializer.prototype._deserializeObjField = function (obj, jsonObj, propName, target) {
var id = jsonObj.__id__;
if (typeof id === 'undefined') {
@@ -258,14 +211,14 @@ var _Deserializer = (function () {
this.result.uuidPropList.push(propName);
}
else {
- if (ENABLE_TARGET) {
+ if (CC_DEV) {
obj[propName] = _deserializeObject(this, jsonObj, target && target[propName]);
}
else {
obj[propName] = _deserializeObject(this, jsonObj);
}
- if (this.result.visitorInEditor && EDITOR) {
- this.result.visitLater(obj, propName);
+ if (CC_DEV && this.result.visit) {
+ this.result.visit(obj, propName);
}
}
}
@@ -279,8 +232,8 @@ var _Deserializer = (function () {
this._idObjList.push(obj);
this._idPropList.push(propName);
}
- if (this.result.visitorInEditor && EDITOR) {
- this.result.visitLater(obj, propName);
+ if (CC_DEV && this.result.visit) {
+ this.result.visit(obj, propName);
}
}
};
@@ -292,14 +245,14 @@ var _Deserializer = (function () {
if (typeof prop !== 'object') {
if (propName !== '__type__'/* && k != '__id__'*/) {
instance[propName] = prop;
- if (self.result.visitorInEditor && EDITOR) {
- self.result.visitLater(instance, propName);
+ if (CC_DEV && self.result.visit) {
+ self.result.visit(instance, propName);
}
}
}
else {
if (prop) {
- if (ENABLE_TARGET) {
+ if (CC_DEV) {
self._deserializeObjField(instance, prop, propName, self._target && instance);
}
else {
@@ -328,7 +281,7 @@ var _Deserializer = (function () {
}
else {
if (prop) {
- if (ENABLE_TARGET) {
+ if (CC_DEV) {
self._deserializeObjField(instance, prop, propName, self._target && instance);
}
else {
@@ -344,22 +297,25 @@ var _Deserializer = (function () {
//--self.stackCounter;
}
+ var RAW_TYPE = Attr.DELIMETER + 'rawType';
+ var EDITOR_ONLY = Attr.DELIMETER + 'editorOnly';
+ var SERIALIZABLE = Attr.DELIMETER + 'serializable';
+
function _deserializeFireClass(self, obj, serialized, klass, target) {
- var DELIMETER = Attr.DELIMETER;
var props = klass.__props__;
var attrs = Attr.getClassAttrs(klass);
for (var p = 0; p < props.length; p++) {
var propName = props[p];
- // assume all prop in __props__ must have attr
- var rawType = attrs[propName + DELIMETER + 'rawType'];
+ var rawType = attrs[propName + RAW_TYPE];
if (!rawType) {
- if (!EDITOR && attrs[propName + DELIMETER + 'editorOnly']) {
+ if (((CC_EDITOR && self._ignoreEditorOnly) || (!CC_EDITOR && CC_DEV && !CC_TEST))
+ && attrs[propName + EDITOR_ONLY]) {
var mayUsedInPersistRoot = (obj instanceof cc.Node && propName === '_id');
if ( !mayUsedInPersistRoot ) {
- continue; // skip editor only if not editor
+ continue; // skip editor only if in preview
}
}
- if (attrs[propName + DELIMETER + 'serializable'] === false) {
+ if (attrs[propName + SERIALIZABLE] === false) {
continue; // skip nonSerialized
}
var prop = serialized[propName];
@@ -371,7 +327,7 @@ var _Deserializer = (function () {
}
else {
if (prop) {
- if (ENABLE_TARGET) {
+ if (CC_DEV) {
self._deserializeObjField(obj, prop, propName, target && obj);
}
else {
@@ -404,8 +360,8 @@ var _Deserializer = (function () {
// * @param {Object} serialized - The obj to deserialize, must be non-nil
// * @param {Object} [target=null]
// */
- var _deserializeObject = function (self, serialized, target) {
- var propName, prop;
+ function _deserializeObject (self, serialized, target) {
+ var prop;
var obj = null; // the obj to return
var klass = null;
if (serialized.__type__) {
@@ -413,18 +369,16 @@ var _Deserializer = (function () {
// Type Object (including CCClass)
var type = serialized.__type__;
- klass = self._classFinder(type);
+ klass = self._classFinder(type, serialized);
if (!klass) {
- if (CC_EDITOR && Editor.UuidUtils.isUuid(type)) {
- type = Editor.UuidUtils.decompressUuid(type);
- cc.warn('Can not find script "%s"', type);
- return null;
+ var noLog = self._classFinder === JS._getClassById;
+ if (noLog) {
+ cc.deserialize.reportMissingClass(type);
}
- cc.warn('Can not find class "%s"', type);
return null;
}
- if (ENABLE_TARGET && target) {
+ if (CC_DEV && target) {
// use target
if ( !(target instanceof klass) ) {
cc.warn('Type of target to deserialize not matched with data: target is %s, data is %s',
@@ -456,14 +410,14 @@ var _Deserializer = (function () {
// embedded primitive javascript object
- obj = (ENABLE_TARGET && target) || {};
+ obj = (CC_DEV && target) || {};
_deserializePrimitiveObject(self, obj, serialized);
}
else {
// Array
- if (ENABLE_TARGET && target) {
+ if (CC_DEV && target) {
target.length = serialized.length;
obj = target;
}
@@ -474,7 +428,7 @@ var _Deserializer = (function () {
for (var i = 0; i < serialized.length; i++) {
prop = serialized[i];
if (typeof prop === 'object' && prop) {
- if (ENABLE_TARGET) {
+ if (CC_DEV) {
self._deserializeObjField(obj, prop, '' + i, target && obj);
}
else {
@@ -483,21 +437,18 @@ var _Deserializer = (function () {
}
else {
obj[i] = prop;
-
- if (self.result.visitorInEditor && EDITOR) {
- self.result.visitLater(obj, '' + i);
+ if (CC_DEV && self.result.visit) {
+ self.result.visit(obj, '' + i);
}
}
}
}
return obj;
- };
+ }
return _Deserializer;
})();
-// FACADE
-
/**
* @module cc
*/
@@ -516,11 +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 = ENABLE_TARGET && (options && options.target);
- var customEnv = (options && options.customEnv);
+ 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();
@@ -536,7 +489,7 @@ cc.deserialize = function (data, result, options) {
result = new Details();
}
cc.game._isCloning = true;
- var deserializer = new _Deserializer(data, result, target, classFinder, customEnv);
+ var deserializer = new _Deserializer(data, result, target, classFinder, customEnv, ignoreEditorOnly);
cc.game._isCloning = false;
if (createAssetRefs) {
@@ -552,3 +505,12 @@ cc.deserialize = function (data, result, options) {
};
cc.deserialize.Details = Details;
+cc.deserialize.reportMissingClass = function (id) {
+ if (CC_EDITOR && Editor.UuidUtils.isUuid(id)) {
+ id = Editor.UuidUtils.decompressUuid(id);
+ cc.warn('Can not find script "%s"', id);
+ }
+ else {
+ cc.warn('Can not find class "%s"', id);
+ }
+};
diff --git a/cocos2d/core/platform/index.js b/cocos2d/core/platform/index.js
index 727edca891..c4c74cd209 100644
--- a/cocos2d/core/platform/index.js
+++ b/cocos2d/core/platform/index.js
@@ -30,7 +30,6 @@ require('./callbacks-invoker');
require('./url');
require('./deserialize');
require('./instantiate');
-require('./prefab-info');
require('./requiring-frame');
require('./CCSys');
require('./CCMacro');
diff --git a/cocos2d/core/platform/instantiate.js b/cocos2d/core/platform/instantiate.js
index 34218a6012..9feb76de04 100644
--- a/cocos2d/core/platform/instantiate.js
+++ b/cocos2d/core/platform/instantiate.js
@@ -46,15 +46,21 @@ var _isDomNode = require('./utils').isDomNode;
*/
function instantiate (original) {
if (typeof original !== 'object' || Array.isArray(original)) {
- cc.error('The thing you want to instantiate must be an object');
+ if (CC_DEV) {
+ cc.error('The thing you want to instantiate must be an object');
+ }
return null;
}
if (!original) {
- cc.error('The thing you want to instantiate is nil');
+ if (CC_DEV) {
+ cc.error('The thing you want to instantiate is nil');
+ }
return null;
}
if (original instanceof CCObject && !original.isValid) {
- cc.error('The thing you want to instantiate is destroyed');
+ if (CC_DEV) {
+ cc.error('The thing you want to instantiate is destroyed');
+ }
return null;
}
@@ -69,7 +75,9 @@ function instantiate (original) {
}
else if (original instanceof cc.Asset) {
// 不允许用通用方案实例化资源
- cc.error('The instantiate method for given asset do not implemented');
+ if (CC_DEV) {
+ cc.error('The instantiate method for given asset do not implemented');
+ }
return null;
}
}
@@ -103,12 +111,21 @@ function doInstantiate (obj, parent) {
cc.error('Can not instantiate array');
return null;
}
- if (_isDomNode && _isDomNode(obj)) {
+ if (!CC_JSB && _isDomNode && _isDomNode(obj)) {
cc.error('Can not instantiate DOM element');
return null;
}
- var clone = enumerateObject(obj, parent);
+ var clone;
+ if (obj._iN$t) {
+ clone = obj._iN$t;
+ }
+ else {
+ // User can specify an existing object by assigning the "_iN$t" property
+ var klass = obj.constructor;
+ clone = new klass();
+ }
+ enumerateObject(obj, clone, parent);
for (var i = 0, len = objsToClearTmpVar.length; i < len; ++i) {
objsToClearTmpVar[i]._iN$t = null;
@@ -118,14 +135,10 @@ function doInstantiate (obj, parent) {
return clone;
}
-///**
-// * @param {Object} obj - The object to instantiate, typeof must be 'object' and should not be an array.
-// * @return {Object} - the instantiated instance
-// */
-var enumerateObject = function (obj, parent) {
+// @param {Object} obj - The object to instantiate, typeof must be 'object' and should not be an array.
+function enumerateObject (obj, clone, parent) {
var value, type, key;
var klass = obj.constructor;
- var clone = new klass();
obj._iN$t = clone;
objsToClearTmpVar.push(obj);
if (cc.Class._isCCClass(klass)) {
@@ -175,8 +188,7 @@ var enumerateObject = function (obj, parent) {
if (obj instanceof CCObject) {
clone._objFlags &= PersistentMask;
}
- return clone;
-};
+}
///**
// * @return {Object} - the original non-nil object, typeof must be 'object'
@@ -248,7 +260,9 @@ function instantiateObj (obj, parent, ownerObj, ownerKey) {
// unknown type
return obj;
}
- return enumerateObject(obj, parent);
+ clone = new ctor();
+ enumerateObject(obj, clone, parent);
+ return clone;
}
}
diff --git a/cocos2d/core/platform/utils.js b/cocos2d/core/platform/utils.js
index a1ff8bda00..b38154bf89 100644
--- a/cocos2d/core/platform/utils.js
+++ b/cocos2d/core/platform/utils.js
@@ -24,12 +24,17 @@
****************************************************************************/
module.exports = {
- isDomNode: typeof window === 'object' && function (obj) {
- return (
- typeof Node === "object" ? obj instanceof Node :
- obj && typeof obj === "object" && typeof obj.nodeType === "number" && typeof obj.nodeName === "string"
- );
- },
+ isDomNode: typeof window === 'object' && (typeof Node === 'function' ?
+ function (obj) {
+ return obj instanceof Node;
+ } :
+ function (obj) {
+ return obj &&
+ typeof obj === 'object' &&
+ typeof obj.nodeType === 'number' &&
+ typeof obj.nodeName === 'string';
+ }
+ ),
callInNextTick: CC_EDITOR ?
function (callback, p1, p2) {
diff --git a/cocos2d/core/renderer/RendererCanvas.js b/cocos2d/core/renderer/RendererCanvas.js
index af6676b101..dc0665fcb8 100644
--- a/cocos2d/core/renderer/RendererCanvas.js
+++ b/cocos2d/core/renderer/RendererCanvas.js
@@ -44,6 +44,11 @@ cc.rendererCanvas = {
//max dirty Region count, default is 10
_dirtyRegionCountThreshold: 10,
+ init: function() {
+ if(cc.sys.browserType === cc.sys.BROWSER_TYPE_IE || cc.sys.browserType === cc.sys.BROWSER_TYPE_UC) {
+ this.enableDirtyRegion(false);
+ }
+ },
getRenderCmd: function (renderableObject) {
//TODO Add renderCmd pool here
@@ -390,14 +395,7 @@ cc.rendererCanvas = {
};
proto.setFillStyle = function(fillStyle){
- if (this._saveCount > 0) {
- this._context.fillStyle = fillStyle;
- } else {
- if (this._currentFillStyle !== fillStyle) {
- this._currentFillStyle = fillStyle;
- this._context.fillStyle = fillStyle;
- }
- }
+ this._context.fillStyle = fillStyle;
};
proto.setStrokeStyle = function(strokeStyle){
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/CCSGSprite.js b/cocos2d/core/sprites/CCSGSprite.js
index f7d6488693..c0bde3d40a 100644
--- a/cocos2d/core/sprites/CCSGSprite.js
+++ b/cocos2d/core/sprites/CCSGSprite.js
@@ -400,12 +400,12 @@ _ccsg.Sprite = _ccsg.Node.extend({
* @param {Boolean} relative
* @override
*/
- ignoreAnchorPointForPosition:function (relative) {
+ setIgnoreAnchorPointForPosition:function (relative) {
if(this._batchNode){
- cc.log(cc._LogInfos.Sprite.ignoreAnchorPointForPosition);
+ cc.log(cc._LogInfos.Sprite.setIgnoreAnchorPointForPosition);
return;
}
- _ccsg.Node.prototype.ignoreAnchorPointForPosition.call(this, relative);
+ _ccsg.Node.prototype.setIgnoreAnchorPointForPosition.call(this, relative);
},
/**
@@ -975,7 +975,7 @@ Object.defineProperty(spritePro, 'visible', {
Object.defineProperty(spritePro, 'ignoreAnchor', {
get: _ccsg.Node.prototype.isIgnoreAnchorPointForPosition,
- set: spritePro.ignoreAnchorPointForPosition
+ set: spritePro.setIgnoreAnchorPointForPosition
});
Object.defineProperty(spritePro, 'opacityModifyRGB', {
diff --git a/cocos2d/core/sprites/CCScale9Sprite.js b/cocos2d/core/sprites/CCScale9Sprite.js
index 52e1a20362..cb29379ebf 100644
--- a/cocos2d/core/sprites/CCScale9Sprite.js
+++ b/cocos2d/core/sprites/CCScale9Sprite.js
@@ -84,13 +84,6 @@ var FIX_ARTIFACTS_BY_STRECHING_TEXEL = cc.macro.FIX_ARTIFACTS_BY_STRECHING_TEXEL
var simpleQuadGenerator = {
_rebuildQuads_base: function (sprite, spriteFrame, contentSize, isTrimmedContentSize) {
//build vertices
- this._calculateVertices(sprite, spriteFrame, contentSize, isTrimmedContentSize);
- //build uvs
- this._calculateUVs(sprite, spriteFrame);
- sprite._vertCount = 4;
- },
-
- _calculateVertices: function (sprite, spriteFrame, contentSize, isTrimmedContentSize) {
var vertices = sprite._vertices,
wt = sprite._renderCmd._worldTransform,
l, b, r, t;
@@ -100,9 +93,9 @@ var simpleQuadGenerator = {
r = contentSize.width;
t = contentSize.height;
} else {
- var originalSize = spriteFrame.getOriginalSize();
+ var originalSize = spriteFrame._originalSize;
var rect = spriteFrame._rect;
- var offset = spriteFrame.getOffset();
+ var offset = spriteFrame._offset;
var scaleX = contentSize.width / originalSize.width;
var scaleY = contentSize.height / originalSize.height;
var trimmLeft = offset.x + (originalSize.width - rect.width) / 2;
@@ -147,12 +140,19 @@ var simpleQuadGenerator = {
cornerId[1] = 2;
cornerId[2] = 4;
cornerId[3] = 6;
+
+ //build uvs
+ if (sprite._uvsDirty) {
+ this._calculateUVs(sprite, spriteFrame);
+ }
+
+ sprite._vertCount = 4;
},
_calculateUVs: function (sprite, spriteFrame) {
var uvs = sprite._uvs;
- var atlasWidth = spriteFrame._texture.getPixelWidth();
- var atlasHeight = spriteFrame._texture.getPixelHeight();
+ var atlasWidth = spriteFrame._texture._pixelWidth;
+ var atlasHeight = spriteFrame._texture._pixelHeight;
var textureRect = spriteFrame._rect;
if (uvs.length < 8) {
@@ -189,24 +189,19 @@ var simpleQuadGenerator = {
};
var scale9QuadGenerator = {
+ x: new Array(4),
+ y: new Array(4),
_rebuildQuads_base: function (sprite, spriteFrame, contentSize, insetLeft, insetRight, insetTop, insetBottom) {
//build vertices
- this._calculateVertices(sprite, spriteFrame, contentSize, insetLeft, insetRight, insetTop, insetBottom);
- //build uvs
- this._calculateUVs(sprite, spriteFrame, insetLeft, insetRight, insetTop, insetBottom);
- },
-
- _calculateVertices: function (sprite, spriteFrame, contentSize, insetLeft, insetRight, insetTop, insetBottom) {
var vertices = sprite._vertices;
var wt = sprite._renderCmd._worldTransform;
var leftWidth, centerWidth, rightWidth;
var topHeight, centerHeight, bottomHeight;
-
var rect = spriteFrame._rect;
+
leftWidth = insetLeft;
rightWidth = insetRight;
centerWidth = rect.width - leftWidth - rightWidth;
-
topHeight = insetTop;
bottomHeight = insetBottom;
centerHeight = rect.height - topHeight - bottomHeight;
@@ -220,8 +215,8 @@ var scale9QuadGenerator = {
yScale = yScale > 1 ? 1 : yScale;
sizableWidth = sizableWidth < 0 ? 0 : sizableWidth;
sizableHeight = sizableHeight < 0 ? 0 : sizableHeight;
- var x = new Array(4);
- var y = new Array(4);
+ var x = this.x;
+ var y = this.y;
x[0] = 0;
x[1] = leftWidth * xScale;
x[2] = x[1] + sizableWidth;
@@ -260,25 +255,30 @@ var scale9QuadGenerator = {
cornerId[1] = 6;
cornerId[2] = 24;
cornerId[3] = 30;
+
+ //build uvs
+ if (sprite._uvsDirty) {
+ this._calculateUVs(sprite, spriteFrame, insetLeft, insetRight, insetTop, insetBottom);
+ }
},
_calculateUVs: function (sprite, spriteFrame, insetLeft, insetRight, insetTop, insetBottom) {
var uvs = sprite._uvs;
var rect = spriteFrame._rect;
- var atlasWidth = spriteFrame._texture.getPixelWidth();
- var atlasHeight = spriteFrame._texture.getPixelHeight();
+ var atlasWidth = spriteFrame._texture._pixelWidth;
+ var atlasHeight = spriteFrame._texture._pixelHeight;
//caculate texture coordinate
var leftWidth, centerWidth, rightWidth;
var topHeight, centerHeight, bottomHeight;
+ var textureRect = spriteFrame._rect;
+
leftWidth = insetLeft;
rightWidth = insetRight;
centerWidth = rect.width - leftWidth - rightWidth;
-
topHeight = insetTop;
bottomHeight = insetBottom;
centerHeight = rect.height - topHeight - bottomHeight;
- var textureRect = spriteFrame._rect;
if (uvs.length < 32) {
dataPool.put(uvs);
@@ -287,20 +287,20 @@ var scale9QuadGenerator = {
}
//uv computation should take spritesheet into account.
- var u = new Array(4);
- var v = new Array(4);
- var offset = 0, row, col;
+ var u = this.x;
+ var v = this.y;
var texelCorrect = FIX_ARTIFACTS_BY_STRECHING_TEXEL ? 0.5 : 0;
+ var offset = 0, row, col;
if (spriteFrame._rotated) {
u[0] = (textureRect.x + texelCorrect) / atlasWidth;
- u[1] = (bottomHeight + textureRect.x - texelCorrect) / atlasWidth;
- u[2] = (bottomHeight + centerHeight + textureRect.x - texelCorrect) / atlasWidth;
+ u[1] = (bottomHeight + textureRect.x) / atlasWidth;
+ u[2] = (bottomHeight + centerHeight + textureRect.x) / atlasWidth;
u[3] = (textureRect.x + textureRect.height - texelCorrect) / atlasWidth;
v[3] = (textureRect.y + texelCorrect) / atlasHeight;
- v[2] = (leftWidth + textureRect.y - texelCorrect) / atlasHeight;
- v[1] = (leftWidth + centerWidth + textureRect.y - texelCorrect) / atlasHeight;
+ v[2] = (leftWidth + textureRect.y) / atlasHeight;
+ v[1] = (leftWidth + centerWidth + textureRect.y) / atlasHeight;
v[0] = (textureRect.y + textureRect.width - texelCorrect) / atlasHeight;
for (row = 0; row < 4; row++) {
@@ -313,13 +313,13 @@ var scale9QuadGenerator = {
}
else {
u[0] = (textureRect.x + texelCorrect) / atlasWidth;
- u[1] = (leftWidth + textureRect.x - texelCorrect) / atlasWidth;
- u[2] = (leftWidth + centerWidth + textureRect.x - texelCorrect) / atlasWidth;
+ u[1] = (leftWidth + textureRect.x) / atlasWidth;
+ u[2] = (leftWidth + centerWidth + textureRect.x) / atlasWidth;
u[3] = (textureRect.x + textureRect.width - texelCorrect) / atlasWidth;
v[3] = (textureRect.y + texelCorrect) / atlasHeight;
- v[2] = (topHeight + textureRect.y - texelCorrect) / atlasHeight;
- v[1] = (topHeight + centerHeight + textureRect.y - texelCorrect) / atlasHeight;
+ v[2] = (topHeight + textureRect.y) / atlasHeight;
+ v[1] = (topHeight + centerHeight + textureRect.y) / atlasHeight;
v[0] = (textureRect.y + textureRect.height - texelCorrect) / atlasHeight;
for (row = 0; row < 4; row++) {
@@ -339,8 +339,8 @@ var tiledQuadGenerator = {
wt = sprite._renderCmd._worldTransform,
uvs = sprite._uvs;
//build uvs
- var atlasWidth = spriteFrame._texture.getPixelWidth();
- var atlasHeight = spriteFrame._texture.getPixelHeight();
+ var atlasWidth = spriteFrame._texture._pixelWidth;
+ var atlasHeight = spriteFrame._texture._pixelHeight;
var textureRect = spriteFrame._rect;
//uv computation should take spritesheet into account.
@@ -437,9 +437,9 @@ var tiledQuadGenerator = {
}
cornerId[0] = 0;
- cornerId[1] = 2;
- cornerId[2] = 4;
- cornerId[3] = 6;
+ cornerId[1] = col * 8 + 2;
+ cornerId[2] = dataLength - col * 8 + 4;
+ cornerId[3] = dataLength - 2;
}
};
@@ -454,8 +454,8 @@ var fillQuadGeneratorBar = {
var l = 0, b = 0,
r = contentSize.width, t = contentSize.height;
//build uvs
- var atlasWidth = spriteFrame._texture.getPixelWidth();
- var atlasHeight = spriteFrame._texture.getPixelHeight();
+ var atlasWidth = spriteFrame._texture._pixelWidth;
+ var atlasHeight = spriteFrame._texture._pixelHeight;
var textureRect = spriteFrame._rect;
//uv computation should take spritesheet into account.
var ul, vb, ur, vt;
@@ -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;
@@ -532,14 +510,12 @@ var fillQuadGeneratorBar = {
// tr : 6, 7
var progressStart, progressEnd;
switch (fillType) {
- case cc.Scale9Sprite.FillType.HORIZONTAL:
- progressStart = vertices[0] + (vertices[2] - vertices[0]) * fillStart;
- progressEnd = vertices[0] + (vertices[2] - vertices[0]) * fillEnd;
+ case FillType.HORIZONTAL:
+ 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];
@@ -550,14 +526,12 @@ var fillQuadGeneratorBar = {
uvs[6] = quadUV[4] + (quadUV[6] - quadUV[4]) * fillEnd;
uvs[7] = quadUV[7];
break;
- case cc.Scale9Sprite.FillType.VERTICAL:
- progressStart = vertices[1] + (vertices[5] - vertices[1]) * fillStart;
- progressEnd = vertices[1] + (vertices[5] - vertices[1]) * fillEnd;
+ case FillType.VERTICAL:
+ 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;
@@ -681,12 +676,12 @@ var fillQuadGeneratorRadial = {
if (vertices.length < dataLength) {
dataPool.put(vertices);
vertices = dataPool.get(dataLength) || new Float32Array(dataLength);
- sprite._vertices = vertices;
+ this.outVerts = sprite._vertices = vertices;
}
if (uvs.length < dataLength) {
dataPool.put(uvs);
uvs = dataPool.get(dataLength) || new Float32Array(dataLength);
- sprite._uvs = uvs;
+ this.outUvs = sprite._uvs = uvs;
}
var offset = 0, count = 0;
@@ -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,23 +884,15 @@ 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) {
- var atlasWidth = spriteFrame._texture.getPixelWidth();
- var atlasHeight = spriteFrame._texture.getPixelHeight();
+ var atlasWidth = spriteFrame._texture._pixelWidth;
+ var atlasHeight = spriteFrame._texture._pixelHeight;
var textureRect = spriteFrame._rect;
//uv computation should take spritesheet into account.
@@ -946,6 +943,7 @@ cc.Scale9Sprite = _ccsg.Node.extend({
_uvs: null,
_vertCount: 0,
_quadsDirty: true,
+ _uvsDirty: true,
_isTriangle: false,
_isTrimmedContentSize: true,
//fill type
@@ -1045,6 +1043,7 @@ cc.Scale9Sprite = _ccsg.Node.extend({
if (spriteFrame) {
this._spriteFrame = spriteFrame;
this._quadsDirty = true;
+ this._uvsDirty = true;
this._renderCmd._needDraw = false;
var self = this;
var onResourceDataLoaded = function () {
@@ -1076,6 +1075,7 @@ cc.Scale9Sprite = _ccsg.Node.extend({
this._blendFunc.src = blendFunc || cc.macro.BLEND_SRC;
this._blendFunc.dst = dst || cc.macro.BLEND_DST;
}
+ this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty);
},
/**
@@ -1106,6 +1106,7 @@ cc.Scale9Sprite = _ccsg.Node.extend({
if (this._isTrimmedContentSize !== isTrimmed) {
this._isTrimmedContentSize = isTrimmed;
this._quadsDirty = true;
+ this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty);
}
},
@@ -1120,6 +1121,7 @@ cc.Scale9Sprite = _ccsg.Node.extend({
setState: function (state) {
this._brightState = state;
this._renderCmd.setState(state);
+ this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty);
},
/**
@@ -1138,6 +1140,8 @@ cc.Scale9Sprite = _ccsg.Node.extend({
if (this._renderingType === type) return;
this._renderingType = type;
this._quadsDirty = true;
+ this._uvsDirty = true;
+ this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty);
},
/**
* get the rendering type, could be simple or slice
@@ -1153,6 +1157,8 @@ cc.Scale9Sprite = _ccsg.Node.extend({
setInsetLeft: function (insetLeft) {
this._insetLeft = insetLeft;
this._quadsDirty = true;
+ this._uvsDirty = true;
+ this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty);
},
/**
* get the left border of 9 slice sprite, the result is specified before trimmed.
@@ -1168,6 +1174,8 @@ cc.Scale9Sprite = _ccsg.Node.extend({
setInsetTop: function (insetTop) {
this._insetTop = insetTop;
this._quadsDirty = true;
+ this._uvsDirty = true;
+ this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty);
},
/**
@@ -1185,6 +1193,8 @@ cc.Scale9Sprite = _ccsg.Node.extend({
setInsetRight: function (insetRight) {
this._insetRight = insetRight;
this._quadsDirty = true;
+ this._uvsDirty = true;
+ this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty);
},
/**
@@ -1202,6 +1212,8 @@ cc.Scale9Sprite = _ccsg.Node.extend({
setInsetBottom: function (insetBottom) {
this._insetBottom = insetBottom;
this._quadsDirty = true;
+ this._uvsDirty = true;
+ this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty);
},
/**
* get the bottom border of 9 slice sprite, the result is specified before trimmed.
@@ -1215,8 +1227,9 @@ cc.Scale9Sprite = _ccsg.Node.extend({
if(this._fillType === value)
return;
this._fillType = value;
- if(this._renderingType === cc.Scale9Sprite.RenderingType.FILLED) {
+ if(this._renderingType === RenderingType.FILLED) {
this._quadsDirty = true;
+ this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty);
}
},
@@ -1226,8 +1239,9 @@ cc.Scale9Sprite = _ccsg.Node.extend({
setFillCenter: function(value, y) {
this._fillCenter = cc.v2(value,y);
- if(this._renderingType === cc.Scale9Sprite.RenderingType.FILLED && this._fillType === cc.Scale9Sprite.FillType.RADIAL) {
+ if(this._renderingType === RenderingType.FILLED && this._fillType === FillType.RADIAL) {
this._quadsDirty = true;
+ this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty);
}
},
@@ -1259,8 +1273,9 @@ cc.Scale9Sprite = _ccsg.Node.extend({
if(this._fillStart === value)
return;
this._fillStart = value;
- if(this._renderingType === cc.Scale9Sprite.RenderingType.FILLED) {
+ if(this._renderingType === RenderingType.FILLED) {
this._quadsDirty = true;
+ this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty);
}
},
@@ -1272,8 +1287,9 @@ cc.Scale9Sprite = _ccsg.Node.extend({
if(this._fillRange === value)
return;
this._fillRange = value;
- if(this._renderingType === cc.Scale9Sprite.RenderingType.FILLED ) {
+ if(this._renderingType === RenderingType.FILLED ) {
this._quadsDirty = true;
+ this._renderCmd.setDirtyFlag(_ccsg.Node._dirtyFlags.contentDirty);
}
},
@@ -1287,24 +1303,24 @@ cc.Scale9Sprite = _ccsg.Node.extend({
return;
}
this._isTriangle = false;
- var vert;
- if (this._renderingType === cc.Scale9Sprite.RenderingType.SIMPLE) {
- simpleQuadGenerator._rebuildQuads_base(this, this._spriteFrame, this.getContentSize(), this._isTrimmedContentSize);
- vert = this._vertices;
- } else if (this._renderingType === cc.Scale9Sprite.RenderingType.SLICED) {
- scale9QuadGenerator._rebuildQuads_base(this, this._spriteFrame, this.getContentSize(), this._insetLeft, this._insetRight, this._insetTop, this._insetBottom);
- vert = this._vertices;
- } else if (this._renderingType === cc.Scale9Sprite.RenderingType.TILED) {
- tiledQuadGenerator._rebuildQuads_base(this, this._spriteFrame, this.getContentSize());
- vert = this._vertices;
- } else if (this._renderingType === cc.Scale9Sprite.RenderingType.FILLED) {
+ switch (this._renderingType) {
+ case RenderingType.SIMPLE:
+ simpleQuadGenerator._rebuildQuads_base(this, this._spriteFrame, this._contentSize, this._isTrimmedContentSize);
+ break;
+ case RenderingType.SLICED:
+ scale9QuadGenerator._rebuildQuads_base(this, this._spriteFrame, this._contentSize, this._insetLeft, this._insetRight, this._insetTop, this._insetBottom);
+ break;
+ case RenderingType.TILED:
+ tiledQuadGenerator._rebuildQuads_base(this, this._spriteFrame, this._contentSize);
+ break;
+ case RenderingType.FILLED:
var fillstart = this._fillStart;
var fillRange = this._fillRange;
if(fillRange < 0) {
fillstart += fillRange;
fillRange = -fillRange;
}
- if (this._fillType !== cc.Scale9Sprite.FillType.RADIAL) {
+ if (this._fillType !== FillType.RADIAL) {
fillRange = fillstart + fillRange;
fillstart = fillstart > 1.0 ? 1.0 : fillstart;
fillstart = fillstart < 0.0 ? 0.0 : fillstart;
@@ -1312,20 +1328,19 @@ cc.Scale9Sprite = _ccsg.Node.extend({
fillRange = fillRange > 1.0 ? 1.0 : fillRange;
fillRange = fillRange < 0.0 ? 0.0 : fillRange;
fillRange = fillRange - fillstart;
- fillQuadGeneratorBar._rebuildQuads_base(this, this._spriteFrame, this.getContentSize(), this._fillType, fillstart, fillRange);
- vert = this._vertices;
+ fillQuadGeneratorBar._rebuildQuads_base(this, this._spriteFrame, this._contentSize, this._fillType, fillstart, fillRange);
} else {
this._isTriangle = true;
if (!this._rawVerts) {
this._rawVerts = dataPool.get(8) || new Float32Array(8);
this._rawUvs = dataPool.get(8) || new Float32Array(8);
}
- fillQuadGeneratorRadial._rebuildQuads_base(this, this._spriteFrame, this.getContentSize(), this._fillCenter,fillstart, fillRange);
- vert = this._rawVerts;
+ fillQuadGeneratorRadial._rebuildQuads_base(this, this._spriteFrame, this._contentSize, this._fillCenter,fillstart, fillRange);
}
- } else {
- this._quads = [];
+ break;
+ default:
this._quadsDirty = false;
+ this._uvsDirty = false;
this._renderCmd._needDraw = false;
cc.error('Can not generate quad');
return;
@@ -1333,12 +1348,13 @@ cc.Scale9Sprite = _ccsg.Node.extend({
// Culling
if (webgl) {
- var x0 = cornerId[0], x1 = cornerId[1], x2 = cornerId[2], x3 = cornerId[3],
- y0 = cornerId[0]+1, y1 = cornerId[1]+1, y2 = cornerId[2]+1, y3 = cornerId[3]+1;
- if (((vert[x0]-vl.x) & (vert[x1]-vl.x) & (vert[x2]-vl.x) & (vert[x3]-vl.x)) >> 31 || // All outside left
- ((vr.x-vert[x0]) & (vr.x-vert[x1]) & (vr.x-vert[x2]) & (vr.x-vert[x3])) >> 31 || // All outside right
- ((vert[y0]-vb.y) & (vert[y1]-vb.y) & (vert[y2]-vb.y) & (vert[y3]-vb.y)) >> 31 || // All outside bottom
- ((vt.y-vert[y0]) & (vt.y-vert[y1]) & (vt.y-vert[y2]) & (vt.y-vert[y3])) >> 31) // All outside top
+ var vert = this._isTriangle ? this._rawVerts : this._vertices,
+ x0 = vert[cornerId[0]], x1 = vert[cornerId[1]], x2 = vert[cornerId[2]], x3 = vert[cornerId[3]],
+ y0 = vert[cornerId[0]+1], y1 = vert[cornerId[1]+1], y2 = vert[cornerId[2]+1], y3 = vert[cornerId[3]+1];
+ if (((x0-vl.x) & (x1-vl.x) & (x2-vl.x) & (x3-vl.x)) >> 31 || // All outside left
+ ((vr.x-x0) & (vr.x-x1) & (vr.x-x2) & (vr.x-x3)) >> 31 || // All outside right
+ ((y0-vb.y) & (y1-vb.y) & (y2-vb.y) & (y3-vb.y)) >> 31 || // All outside bottom
+ ((vt.y-y0) & (vt.y-y1) & (vt.y-y2) & (vt.y-y3)) >> 31) // All outside top
{
this._renderCmd._needDraw = false;
}
@@ -1358,6 +1374,7 @@ cc.Scale9Sprite = _ccsg.Node.extend({
}
this._quadsDirty = false;
+ this._uvsDirty = false;
},
_createRenderCmd: function () {
if (cc._renderType === cc.game.RENDER_TYPE_CANVAS)
@@ -1382,7 +1399,7 @@ cc.Scale9Sprite.state = {NORMAL: 0, GRAY: 1, DISTORTION: 2};
* Enum for sprite type
* @enum SpriteType
*/
-cc.Scale9Sprite.RenderingType = cc.Enum({
+var RenderingType = cc.Scale9Sprite.RenderingType = cc.Enum({
/**
* @property {Number} SIMPLE
*/
@@ -1401,7 +1418,7 @@ cc.Scale9Sprite.RenderingType = cc.Enum({
FILLED: 3
});
-cc.Scale9Sprite.FillType = cc.Enum({
+var FillType = cc.Scale9Sprite.FillType = cc.Enum({
HORIZONTAL: 0,
VERTICAL: 1,
RADIAL:2,
diff --git a/cocos2d/core/sprites/CCScale9SpriteCanvasRenderCmd.js b/cocos2d/core/sprites/CCScale9SpriteCanvasRenderCmd.js
index 8329cf238d..448fd5eb2a 100644
--- a/cocos2d/core/sprites/CCScale9SpriteCanvasRenderCmd.js
+++ b/cocos2d/core/sprites/CCScale9SpriteCanvasRenderCmd.js
@@ -83,8 +83,8 @@ proto.rendering = function (ctx, scaleX, scaleY) {
}
var sx,sy,sw,sh;
var x, y, w,h;
- var textureWidth = this._textureToRender.getPixelWidth();
- var textureHeight = this._textureToRender.getPixelHeight();
+ var textureWidth = this._textureToRender._pixelWidth;
+ var textureHeight = this._textureToRender._pixelHeight;
var image = this._textureToRender._htmlElementObj;
var vertices = node._vertices;
var uvs = node._uvs;
diff --git a/cocos2d/core/sprites/CCScale9SpriteWebGLRenderCmd.js b/cocos2d/core/sprites/CCScale9SpriteWebGLRenderCmd.js
index d34298c50c..0c7ed638bd 100644
--- a/cocos2d/core/sprites/CCScale9SpriteWebGLRenderCmd.js
+++ b/cocos2d/core/sprites/CCScale9SpriteWebGLRenderCmd.js
@@ -39,8 +39,9 @@ cc.Scale9Sprite.WebGLRenderCmd = function (renderable) {
this._shaderProgram = cc.shaderCache.programForKey(cc.macro.SHADER_SPRITE_POSITION_TEXTURECOLOR);
};
-var proto = cc.Scale9Sprite.WebGLRenderCmd.prototype = Object.create(_ccsg.Node.WebGLRenderCmd.prototype);
-proto.constructor = cc.Scale9Sprite.WebGLRenderCmd;
+var Scale9Sprite = cc.Scale9Sprite;
+var proto = Scale9Sprite.WebGLRenderCmd.prototype = Object.create(_ccsg.Node.WebGLRenderCmd.prototype);
+proto.constructor = Scale9Sprite.WebGLRenderCmd;
proto._uploadSliced = function (vertices, uvs, color, z, f32buffer, ui32buffer, offset) {
var off;
@@ -84,21 +85,6 @@ proto._uploadSliced = function (vertices, uvs, color, z, f32buffer, ui32buffer,
return 36;
};
-proto._uploadVertices = function (vertices, uvs, color, z, f32buffer, ui32buffer, offset) {
- // src: bl, br, tl, tr
- var count = this._node._vertCount;
- for (var i = 0, srcOff = 0; i < count; i++, srcOff += 2) {
- f32buffer[offset] = vertices[srcOff];
- f32buffer[offset + 1] = vertices[srcOff+1];
- f32buffer[offset + 2] = z;
- ui32buffer[offset + 3] = color[0];
- f32buffer[offset + 4] = uvs[srcOff];
- f32buffer[offset + 5] = uvs[srcOff+1];
- offset += 6;
- }
- return count;
-};
-
proto.transform = function (parentCmd, recursive) {
this.originTransform(parentCmd, recursive);
this._node._rebuildQuads();
@@ -106,7 +92,7 @@ proto.transform = function (parentCmd, recursive) {
proto.uploadData = function (f32buffer, ui32buffer, vertexDataOffset){
var node = this._node;
- if (!node._spriteFrame || !node._spriteFrame.textureLoaded() || this._displayedOpacity === 0) {
+ if (this._displayedOpacity === 0) {
return 0;
}
@@ -115,16 +101,16 @@ proto.uploadData = function (f32buffer, ui32buffer, vertexDataOffset){
node._rebuildQuads();
}
- // this._shaderProgram.use();
- if (this._shaderProgram === cc.Scale9Sprite.WebGLRenderCmd._distortionProgram && this._node._distortionOffset) {
+ if (node._distortionOffset && this._shaderProgram === Scale9Sprite.WebGLRenderCmd._distortionProgram) {
this._shaderProgram.setUniformLocationWith2f(
- cc.Scale9Sprite.WebGLRenderCmd._distortionOffset,
- this._node._distortionOffset.x, this._node._distortionOffset.y
+ Scale9Sprite.WebGLRenderCmd._distortionOffset,
+ node._distortionOffset.x, node._distortionOffset.y
);
this._shaderProgram.setUniformLocationWith2f(
- cc.Scale9Sprite.WebGLRenderCmd._distortionTiling,
- this._node._distortionTiling.x, this._node._distortionTiling.y
+ Scale9Sprite.WebGLRenderCmd._distortionTiling,
+ node._distortionTiling.x, node._distortionTiling.y
);
+ cc.renderer._breakBatch();
}
// Color & z
@@ -144,20 +130,30 @@ proto.uploadData = function (f32buffer, ui32buffer, vertexDataOffset){
// Upload data
var vertices = node._vertices;
var uvs = node._uvs;
- var types = cc.Scale9Sprite.RenderingType;
+ var types = Scale9Sprite.RenderingType;
var offset = vertexDataOffset;
var len = 0;
switch (node._renderingType) {
case types.SIMPLE:
case types.TILED:
case types.FILLED:
- len = this._uploadVertices(vertices, uvs, this._color, z, f32buffer, ui32buffer, offset);
+ // Inline for performance
+ len = this._node._vertCount;
+ for (var i = 0, srcOff = 0; i < len; i++, srcOff += 2) {
+ f32buffer[offset] = vertices[srcOff];
+ f32buffer[offset + 1] = vertices[srcOff+1];
+ f32buffer[offset + 2] = z;
+ ui32buffer[offset + 3] = this._color[0];
+ f32buffer[offset + 4] = uvs[srcOff];
+ f32buffer[offset + 5] = uvs[srcOff+1];
+ offset += 6;
+ }
break;
case types.SLICED:
len = this._uploadSliced(vertices, uvs, this._color, z, f32buffer, ui32buffer, offset);
break;
}
- if (node._renderingType === types.FILLED && node._fillType === cc.Scale9Sprite.FillType.RADIAL) {
+ if (node._renderingType === types.FILLED && node._fillType === Scale9Sprite.FillType.RADIAL) {
this.vertexType = cc.renderer.VertexType.TRIANGLE;
}
else {
@@ -167,18 +163,18 @@ proto.uploadData = function (f32buffer, ui32buffer, vertexDataOffset){
};
proto.setState = function (state) {
- if (state === cc.Scale9Sprite.state.NORMAL) {
+ if (state === Scale9Sprite.state.NORMAL) {
this._shaderProgram = cc.shaderCache.programForKey(cc.macro.SHADER_SPRITE_POSITION_TEXTURECOLOR);
- } else if (state === cc.Scale9Sprite.state.GRAY) {
+ } else if (state === Scale9Sprite.state.GRAY) {
this._shaderProgram = cc.Scale9Sprite.WebGLRenderCmd._getGrayShaderProgram();
- } else if (state === cc.Scale9Sprite.state.DISTORTION) {
+ } else if (state === Scale9Sprite.state.DISTORTION) {
this._shaderProgram = cc.Scale9Sprite.WebGLRenderCmd._getDistortionProgram();
}
};
-cc.Scale9Sprite.WebGLRenderCmd._grayShaderProgram = null;
-cc.Scale9Sprite.WebGLRenderCmd._getGrayShaderProgram = function(){
- var grayShader = cc.Scale9Sprite.WebGLRenderCmd._grayShaderProgram;
+Scale9Sprite.WebGLRenderCmd._grayShaderProgram = null;
+Scale9Sprite.WebGLRenderCmd._getGrayShaderProgram = function(){
+ var grayShader = Scale9Sprite.WebGLRenderCmd._grayShaderProgram;
if (grayShader)
return grayShader;
@@ -190,11 +186,11 @@ cc.Scale9Sprite.WebGLRenderCmd._getGrayShaderProgram = function(){
grayShader.link();
grayShader.updateUniforms();
- cc.Scale9Sprite.WebGLRenderCmd._grayShaderProgram = grayShader;
+ Scale9Sprite.WebGLRenderCmd._grayShaderProgram = grayShader;
return grayShader;
};
-cc.Scale9Sprite.WebGLRenderCmd._grayShaderFragment =
+Scale9Sprite.WebGLRenderCmd._grayShaderFragment =
"precision lowp float;\n"
+ "varying vec4 v_fragmentColor; \n"
+ "varying vec2 v_texCoord; \n"
@@ -205,9 +201,9 @@ cc.Scale9Sprite.WebGLRenderCmd._grayShaderFragment =
+" gl_FragColor.w = c.w ; \n"
+ "}";
-cc.Scale9Sprite.WebGLRenderCmd._distortionProgram = null;
-cc.Scale9Sprite.WebGLRenderCmd._getDistortionProgram = function(){
- var shader = cc.Scale9Sprite.WebGLRenderCmd._distortionProgram;
+Scale9Sprite.WebGLRenderCmd._distortionProgram = null;
+Scale9Sprite.WebGLRenderCmd._getDistortionProgram = function(){
+ var shader = Scale9Sprite.WebGLRenderCmd._distortionProgram;
if(shader)
return shader;
@@ -219,9 +215,9 @@ cc.Scale9Sprite.WebGLRenderCmd._getDistortionProgram = function(){
shader.link();
shader.updateUniforms();
- cc.Scale9Sprite.WebGLRenderCmd._distortionProgram = shader;
- cc.Scale9Sprite.WebGLRenderCmd._distortionOffset = shader.getUniformLocationForName('u_offset');
- cc.Scale9Sprite.WebGLRenderCmd._distortionTiling = shader.getUniformLocationForName('u_offset_tiling');
+ Scale9Sprite.WebGLRenderCmd._distortionProgram = shader;
+ Scale9Sprite.WebGLRenderCmd._distortionOffset = shader.getUniformLocationForName('u_offset');
+ Scale9Sprite.WebGLRenderCmd._distortionTiling = shader.getUniformLocationForName('u_offset_tiling');
return shader;
};
diff --git a/cocos2d/core/sprites/CCSpriteFrame.js b/cocos2d/core/sprites/CCSpriteFrame.js
index 50d886fbbd..8065abc8ba 100644
--- a/cocos2d/core/sprites/CCSpriteFrame.js
+++ b/cocos2d/core/sprites/CCSpriteFrame.js
@@ -292,20 +292,23 @@ cc.SpriteFrame = cc.Class(/** @lends cc.SpriteFrame# */{
this._texture = texture;
function textureLoadedCallback () {
self._textureLoaded = true;
+ var w = texture.width, h = texture.height;
+
if (self._rotated && cc._renderType === cc.game.RENDER_TYPE_CANVAS) {
var tempElement = texture.getHtmlElementObj();
tempElement = _ccsg.Sprite.CanvasRenderCmd._cutRotateImageToCanvas(tempElement, self.getRect());
var tempTexture = new cc.Texture2D();
tempTexture.initWithElement(tempElement);
tempTexture.handleLoadedTexture();
- // _refreshTexture will be recalled in setTexture
- self.setTexture(tempTexture);
- return;
+ self._texture = tempTexture;
+ self._rotated = false;
+ w = self._texture.width;
+ h = self._texture.height;
+ self.setRect(cc.rect(0, 0, w, h));
}
- var w = texture.width, h = texture.height;
if (self._rect) {
- self._checkRect(texture);
+ self._checkRect(self._texture);
}
else {
self.setRect(cc.rect(0, 0, w, h));
diff --git a/cocos2d/core/textures/CCTexture2D.js b/cocos2d/core/textures/CCTexture2D.js
index 859c5d646a..c60399c190 100644
--- a/cocos2d/core/textures/CCTexture2D.js
+++ b/cocos2d/core/textures/CCTexture2D.js
@@ -85,6 +85,8 @@ var Texture2D = cc.Class(/** @lends cc.Texture2D# */{
this._textureLoaded = false;
this._htmlElementObj = null;
this._contentSize = cc.size(0, 0);
+ this._pixelWidth = 0;
+ this._pixelHeight = 0;
if (cc._renderType === game.RENDER_TYPE_CANVAS) {
this._pattern = "";
@@ -94,10 +96,7 @@ 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._pixelsWide = 0;
- this._pixelsHigh = 0;
this._hasPremultipliedAlpha = false;
this._hasMipmaps = false;
@@ -111,7 +110,7 @@ var Texture2D = cc.Class(/** @lends cc.Texture2D# */{
* @return {Number}
*/
getPixelWidth: function () {
- return this._contentSize.width;
+ return this._pixelWidth;
},
/**
@@ -120,7 +119,7 @@ var Texture2D = cc.Class(/** @lends cc.Texture2D# */{
* @return {Number}
*/
getPixelHeight: function () {
- return this._contentSize.height;
+ return this._pixelHeight;
},
/**
@@ -162,8 +161,8 @@ var Texture2D = cc.Class(/** @lends cc.Texture2D# */{
if (!element)
return;
this._htmlElementObj = element;
- this._contentSize.width = element.width;
- this._contentSize.height = element.height;
+ this._pixelWidth = this._contentSize.width = element.width;
+ this._pixelHeight = this._contentSize.height = element.height;
this._textureLoaded = true;
},
@@ -229,10 +228,20 @@ var Texture2D = cc.Class(/** @lends cc.Texture2D# */{
return;
var locElement = self._htmlElementObj;
- self._contentSize.width = locElement.width;
- self._contentSize.height = locElement.height;
+ self._pixelWidth = self._contentSize.width = locElement.width;
+ self._pixelHeight = self._contentSize.height = locElement.height;
self._textureLoaded = true;
+ // anti-alias
+ if(cc._renderType === cc.game.RENDER_TYPE_WEBGL) {
+ if (cc.view._antiAliasEnabled) {
+ self.setAntiAliasTexParameters();
+ }
+ else {
+ self.setAliasTexParameters();
+ }
+ }
+
//dispatch load event to listener.
self.emit("load");
},
@@ -716,13 +725,6 @@ game.once(game.EVENT_RENDERER_INITED, function () {
} else if (cc._renderType === game.RENDER_TYPE_WEBGL) {
JS.mixin(Texture2D.prototype, {
- getPixelWidth: function () {
- return this._pixelsWide;
- },
-
- getPixelHeight: function () {
- return this._pixelsHigh;
- },
initWithData: function (data, pixelFormat, pixelsWide, pixelsHigh, contentSize) {
var self = this, tex2d = Texture2D;
@@ -784,8 +786,8 @@ game.once(game.EVENT_RENDERER_INITED, function () {
self._contentSize.width = contentSize.width;
self._contentSize.height = contentSize.height;
- self._pixelsWide = pixelsWide;
- self._pixelsHigh = pixelsHigh;
+ self._pixelWidth = pixelsWide;
+ self._pixelHeight = pixelsHigh;
self._pixelFormat = pixelFormat;
self._hasPremultipliedAlpha = false;
@@ -863,14 +865,21 @@ game.once(game.EVENT_RENDERER_INITED, function () {
var pixelsWide = self._htmlElementObj.width;
var pixelsHigh = self._htmlElementObj.height;
- self._pixelsWide = self._contentSize.width = pixelsWide;
- self._pixelsHigh = self._contentSize.height = pixelsHigh;
+ self._pixelWidth = self._contentSize.width = pixelsWide;
+ self._pixelHeight = self._contentSize.height = pixelsHigh;
self._pixelFormat = Texture2D.PIXEL_FORMAT_RGBA8888;
self._hasPremultipliedAlpha = premultiplied;
self._hasMipmaps = false;
self._textureLoaded = true;
+ if (cc.view._antiAliasEnabled) {
+ self.setAntiAliasTexParameters();
+ }
+ else {
+ self.setAliasTexParameters();
+ }
+
//dispatch load event to listener.
self.emit("load");
},
@@ -882,7 +891,7 @@ game.once(game.EVENT_RENDERER_INITED, function () {
if(magFilter !== undefined)
texParams = {minFilter: texParams, magFilter: magFilter, wrapS: wrapS, wrapT: wrapT};
- cc.assert((_t._pixelsWide === misc.NextPOT(_t._pixelsWide) && _t._pixelsHigh === misc.NextPOT(_t._pixelsHigh)) ||
+ cc.assert((_t._pixelWidth === misc.NextPOT(_t._pixelWidth) && _t._pixelHeight === misc.NextPOT(_t._pixelHeight)) ||
(texParams.wrapS === gl.CLAMP_TO_EDGE && texParams.wrapT === gl.CLAMP_TO_EDGE),
"WebGLRenderingContext.CLAMP_TO_EDGE should be used in NPOT textures");
@@ -917,7 +926,7 @@ game.once(game.EVENT_RENDERER_INITED, function () {
generateMipmap: function () {
var _t = this;
- cc.assert(_t._pixelsWide === misc.NextPOT(_t._pixelsWide) && _t._pixelsHigh === misc.NextPOT(_t._pixelsHigh), "Mimpap texture only works in POT textures");
+ cc.assert(_t._pixelWidth === misc.NextPOT(_t._pixelWidth) && _t._pixelHeight === misc.NextPOT(_t._pixelHeight), "Mimpap texture only works in POT textures");
cc.gl.bindTexture2D(_t);
cc._renderContext.generateMipmap(cc._renderContext.TEXTURE_2D);
diff --git a/cocos2d/core/textures/CCTextureCache.js b/cocos2d/core/textures/CCTextureCache.js
index 657c66a408..ac6650163b 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}
@@ -125,6 +125,21 @@ var textureCache = /** @lends cc.textureCache# */{
return this._textureColorsCache[key];
},
+ /**
+ * #en get all textures
+ * #zh 获取所有贴图
+ * @method getAllTextures
+ * @return {Texture2D[]}
+ */
+ getAllTextures: function () {
+ var texs = [];
+ for (var key in this._textures) {
+ var item = this._textures[key];
+ texs.push(item);
+ }
+ return texs;
+ },
+
/**
*
Purges the dictionary of loaded textures.
* Call this method if you receive the "Memory Warning"
diff --git a/cocos2d/core/utils/base-node.js b/cocos2d/core/utils/base-node.js
index 43e078f206..60731f904a 100644
--- a/cocos2d/core/utils/base-node.js
+++ b/cocos2d/core/utils/base-node.js
@@ -688,8 +688,8 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
},
/**
- * !#en Indicate whether node's opacity value affect its child nodes, default value is false.
- * !#zh 节点的不透明度值是否影响其子节点,默认值为 false。
+ * !#en Indicate whether node's opacity value affect its child nodes, default value is true.
+ * !#zh 节点的不透明度值是否影响其子节点,默认值为 true。
* @property cascadeOpacity
* @type {Boolean}
* @example
@@ -755,10 +755,10 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
var sgNode = this._sgNode = new _ccsg.Node();
if (CC_JSB) {
sgNode.retain();
- var entity = this;
+ sgNode._entity = this;
sgNode.onEnter = function () {
_ccsg.Node.prototype.onEnter.call(this);
- if (!entity._active) {
+ if (this._entity && !this._entity._active) {
cc.director.getActionManager().pauseTarget(this);
cc.eventManager.pauseTarget(this);
}
@@ -797,6 +797,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
_onPreDestroy: function () {
if (CC_JSB) {
this._sgNode.release();
+ this._sgNode._entity = null;
this._sgNode = null;
}
cc.eventManager.removeListeners(this);
@@ -843,7 +844,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
}
},
- /**
+ /*
* !#en
* Defines the oder in which the nodes are renderer.
* Nodes that have a Global Z Order lower, are renderer first.
@@ -880,7 +881,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
this._sgNode.setGlobalZOrder(globalZOrder);
},
- /**
+ /*
* !#en Return the Node's Global Z Order.
* !#zh 获取节点的全局 Z 顺序。
* @method getGlobalZOrder
@@ -1609,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}
@@ -1885,7 +1886,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
sibling.setLocalZOrder(zOrder);
}
else {
- sibling.arrivalOrder = i;
+ sibling._arrivalOrder = i;
cc.eventManager._setDirtyForNode(siblings[i]);
}
}
@@ -1942,7 +1943,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
if (child._localZOrder < _children[j]._localZOrder) {
_children[j+1] = _children[j];
} else if (child._localZOrder === _children[j]._localZOrder &&
- child._sgNode.arrivalOrder < _children[j]._sgNode.arrivalOrder) {
+ child._sgNode._arrivalOrder < _children[j]._sgNode._arrivalOrder) {
_children[j+1] = _children[j];
} else {
break;
@@ -1971,14 +1972,18 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
sgNode.setScale(self._scaleX, self._scaleY);
sgNode.setSkewX(self._skewX);
sgNode.setSkewY(self._skewY);
- sgNode.ignoreAnchorPointForPosition(self.__ignoreAnchor);
+ sgNode.setIgnoreAnchorPointForPosition(self.__ignoreAnchor);
- var arrivalOrder = sgNode.arrivalOrder;
+ var arrivalOrder = sgNode._arrivalOrder;
sgNode.setLocalZOrder(self._localZOrder);
- sgNode.arrivalOrder = arrivalOrder; // revert arrivalOrder changed in setLocalZOrder
+ sgNode._arrivalOrder = arrivalOrder; // revert arrivalOrder changed in setLocalZOrder
sgNode.setGlobalZOrder(self._globalZOrder);
+ if (CC_JSB) {
+ // fix tintTo and tintBy action for jsb displays err for fireball/issues/4137
+ sgNode.setColor(this._color);
+ }
sgNode.setOpacity(self._opacity);
sgNode.setOpacityModifyRGB(self._opacityModifyRGB);
sgNode.setCascadeOpacityEnabled(self._cascadeOpacityEnabled);
@@ -2003,29 +2008,6 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
}
},
- /*
- * The deserializer for sgNode which will be called before components onLoad
- * @param {Boolean} [skipChildrenInEditor=false]
- */
- _onBatchCreated: function () {
- this._updateDummySgNode();
-
- if (this._parent) {
- this._parent._sgNode.addChild(this._sgNode);
- }
-
- if ( !this._activeInHierarchy ) {
- // deactivate ActionManager and EventManager by default
- cc.director.getActionManager().pauseTarget(this);
- cc.eventManager.pauseTarget(this);
- }
-
- var children = this._children;
- for (var i = 0, len = children.length; i < len; i++) {
- children[i]._onBatchCreated();
- }
- },
-
onRestore: CC_EDITOR && function () {
this._updateDummySgNode();
@@ -2055,6 +2037,13 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
}
}
+ // check activity state
+ var shouldActiveInHierarchy = (this._parent && this._parent._activeInHierarchy && this._active);
+ if (shouldActiveInHierarchy !== this._activeInHierarchy) {
+ this._onActivatedInHierarchy(shouldActiveInHierarchy);
+ this.emit('active-in-hierarchy-changed', this);
+ }
+
if (this._activeInHierarchy) {
cc.director.getActionManager().resumeTarget(this);
cc.eventManager.resumeTarget(this);
diff --git a/cocos2d/core/utils/find.js b/cocos2d/core/utils/find.js
index 986b1b9dff..fbcdd94df7 100644
--- a/cocos2d/core/utils/find.js
+++ b/cocos2d/core/utils/find.js
@@ -43,11 +43,21 @@ cc.find = module.exports = function (path, referenceNode) {
if (!referenceNode) {
var scene = cc.director.getScene();
if (!scene) {
- cc.warn('Can not get current scene.');
+ if (CC_DEV) {
+ cc.warn('Can not get current scene.');
+ }
+ return null;
+ }
+ else if (CC_DEV && !scene.isValid) {
+ cc.warn('Scene is destroyed');
return null;
}
referenceNode = scene;
}
+ else if (CC_DEV && !referenceNode.isValid) {
+ cc.warn('reference node is destroyed');
+ return null;
+ }
var match = referenceNode;
var startIndex = (path[0] !== '/') ? 0 : 1; // skip first '/'
diff --git a/cocos2d/core/utils/prefab-helper.js b/cocos2d/core/utils/prefab-helper.js
new file mode 100644
index 0000000000..89efaad05c
--- /dev/null
+++ b/cocos2d/core/utils/prefab-helper.js
@@ -0,0 +1,103 @@
+/****************************************************************************
+ Copyright (c) 2013-2016 Chukong Technologies Inc.
+
+ http://www.cocos.com
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated engine source code (the "Software"), a limited,
+ worldwide, royalty-free, non-assignable, revocable and non-exclusive license
+ to use Cocos Creator solely to develop games on your target platforms. You shall
+ not use Cocos Creator software for developing other software or tools that's
+ used for developing games. You are not granted to publish, distribute,
+ sublicense, and/or sell copies of Cocos Creator.
+
+ The software or tools in this License Agreement are licensed, not sold.
+ Chukong Aipu reserves all rights not expressly granted to you.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+ ****************************************************************************/
+
+// 保存编辑器下用到的 prefab 相关信息
+cc._PrefabInfo = cc.Class({
+ name: 'cc.PrefabInfo',
+ properties: {
+ //// the serialized version
+ //VER: {
+ // default: 1
+ //},
+
+ // the most top node of this prefab in the scene
+ root: null,
+
+ // 所属的 prefab 资源对象 (cc.Prefab)
+ // (这个属性在场景中是会保存的,但是不会保存在 prefab 里面,因为创建 prefab 时还不知道自己的 uuid 是多少。)
+ asset: null,
+
+ // 用来标识别该节点在 prefab 资源中的位置,因此这个 ID 只需要保证在 Assets 里不重复就行
+ fileId: '',
+
+ // Indicates whether this node should always synchronize with the prefab asset, only available in the root node
+ sync: false,
+
+ // Indicates whether this node is synchronized, only available in the root node
+ _synced: {
+ default: false,
+ serializable: false
+ },
+ }
+});
+
+// prefab helper function
+module.exports = {
+ // update node to make it sync with prefab
+ syncWithPrefab: function (node) {
+
+ // save preserved props to avoid overwritten by prefabRoot
+ var _objFlags = node._objFlags;
+ var _parent = node._parent;
+ var _id = node._id;
+ var _prefab = node._prefab;
+ var _name = node._name;
+ var _active = node._active;
+ var _position = node._position;
+ var _rotationX = node._rotationX;
+ var _rotationY = node._rotationY;
+ var _localZOrder = node._localZOrder;
+ var _globalZOrder = node._globalZOrder;
+
+ // non-reentrant
+ _prefab._synced = true;
+
+ var prefabRoot = _prefab.asset.data;
+
+ // prefab asset is always synced
+ prefabRoot._prefab._synced = true;
+
+ // use node as the instantiated prefabRoot to make references to prefabRoot in prefab redirect to node
+ prefabRoot._iN$t = node;
+
+ // instantiate prefab and apply to node
+ cc.game._isCloning = true;
+ cc.instantiate._clone(prefabRoot, prefabRoot);
+ cc.game._isCloning = false;
+
+ // restore preserved props
+ node._objFlags = _objFlags;
+ node._parent = _parent;
+ node._id = _id;
+ node._prefab = _prefab;
+ node._name = _name;
+ node._active = _active;
+ node._position = _position;
+ node._rotationX = _rotationX;
+ node._rotationY = _rotationY;
+ node._localZOrder = _localZOrder;
+ node._globalZOrder = _globalZOrder;
+ }
+};
diff --git a/cocos2d/core/utils/scene-graph-helper.js b/cocos2d/core/utils/scene-graph-helper.js
index 5b6d2ffcb7..1b0fc22a10 100644
--- a/cocos2d/core/utils/scene-graph-helper.js
+++ b/cocos2d/core/utils/scene-graph-helper.js
@@ -34,6 +34,9 @@ var SceneGraphUtils = {
parent.removeChild(node);
}
node.release();
+ if (this._sgNode._entity) {
+ this._sgNode._entity = null;
+ }
}
},
};
diff --git a/cocos2d/core/value-types/CCAffineTransform.js b/cocos2d/core/value-types/CCAffineTransform.js
index 0dcd42023b..243bea76fb 100644
--- a/cocos2d/core/value-types/CCAffineTransform.js
+++ b/cocos2d/core/value-types/CCAffineTransform.js
@@ -154,40 +154,45 @@ cc.affineTransformIdentity = function () {
* @param {AffineTransform} anAffineTransform
* @return {Rect}
*/
-cc.rectApplyAffineTransform = function (rect, anAffineTransform) {
- var top = cc.rectGetMinY(rect);
- var left = cc.rectGetMinX(rect);
- var right = cc.rectGetMaxX(rect);
- var bottom = cc.rectGetMaxY(rect);
-
- var topLeft = cc.pointApplyAffineTransform(left, top, anAffineTransform);
- var topRight = cc.pointApplyAffineTransform(right, top, anAffineTransform);
- var bottomLeft = cc.pointApplyAffineTransform(left, bottom, anAffineTransform);
- var bottomRight = cc.pointApplyAffineTransform(right, bottom, anAffineTransform);
-
- var minX = Math.min(topLeft.x, topRight.x, bottomLeft.x, bottomRight.x);
- var maxX = Math.max(topLeft.x, topRight.x, bottomLeft.x, bottomRight.x);
- var minY = Math.min(topLeft.y, topRight.y, bottomLeft.y, bottomRight.y);
- var maxY = Math.max(topLeft.y, topRight.y, bottomLeft.y, bottomRight.y);
+cc.rectApplyAffineTransform = function (rect, t) {
+ var ol = rect.x;
+ var ob = rect.y;
+ var or = ol + rect.width;
+ var ot = ob + rect.height;
+ var lbx = t.a * ol + t.c * ob + t.tx;
+ var lby = t.b * ol + t.d * ob + t.ty;
+ var rbx = t.a * or + t.c * ob + t.tx;
+ var rby = t.b * or + t.d * ob + t.ty;
+ var ltx = t.a * ol + t.c * ot + t.tx;
+ var lty = t.b * ol + t.d * ot + t.ty;
+ var rtx = t.a * or + t.c * ot + t.tx;
+ var rty = t.b * or + t.d * ot + t.ty;
+ var minX = Math.min(lbx, rbx, ltx, rtx);
+ var maxX = Math.max(lbx, rbx, ltx, rtx);
+ var minY = Math.min(lby, rby, lty, rty);
+ var maxY = Math.max(lby, rby, lty, rty);
return cc.rect(minX, minY, (maxX - minX), (maxY - minY));
};
-cc._rectApplyAffineTransformIn = function(rect, anAffineTransform){
- var top = cc.rectGetMinY(rect);
- var left = cc.rectGetMinX(rect);
- var right = cc.rectGetMaxX(rect);
- var bottom = cc.rectGetMaxY(rect);
+cc._rectApplyAffineTransformIn = function(rect, t){
+ var ol = rect.x;
+ var ob = rect.y;
+ var or = ol + rect.width;
+ var ot = ob + rect.height;
+ var lbx = t.a * ol + t.c * ob + t.tx;
+ var lby = t.b * ol + t.d * ob + t.ty;
+ var rbx = t.a * or + t.c * ob + t.tx;
+ var rby = t.b * or + t.d * ob + t.ty;
+ var ltx = t.a * ol + t.c * ot + t.tx;
+ var lty = t.b * ol + t.d * ot + t.ty;
+ var rtx = t.a * or + t.c * ot + t.tx;
+ var rty = t.b * or + t.d * ot + t.ty;
- var topLeft = cc.pointApplyAffineTransform(left, top, anAffineTransform);
- var topRight = cc.pointApplyAffineTransform(right, top, anAffineTransform);
- var bottomLeft = cc.pointApplyAffineTransform(left, bottom, anAffineTransform);
- var bottomRight = cc.pointApplyAffineTransform(right, bottom, anAffineTransform);
-
- var minX = Math.min(topLeft.x, topRight.x, bottomLeft.x, bottomRight.x);
- var maxX = Math.max(topLeft.x, topRight.x, bottomLeft.x, bottomRight.x);
- var minY = Math.min(topLeft.y, topRight.y, bottomLeft.y, bottomRight.y);
- var maxY = Math.max(topLeft.y, topRight.y, bottomLeft.y, bottomRight.y);
+ var minX = Math.min(lbx, rbx, ltx, rtx);
+ var maxX = Math.max(lbx, rbx, ltx, rtx);
+ var minY = Math.min(lby, rby, lty, rty);
+ var maxY = Math.max(lby, rby, lty, rty);
rect.x = minX;
rect.y = minY;
diff --git a/cocos2d/core/videoplayer/CCSGVideoPlayer.js b/cocos2d/core/videoplayer/CCSGVideoPlayer.js
index 4dc4b8bfe2..831672ea52 100644
--- a/cocos2d/core/videoplayer/CCSGVideoPlayer.js
+++ b/cocos2d/core/videoplayer/CCSGVideoPlayer.js
@@ -35,7 +35,6 @@ _ccsg.VideoPlayer = _ccsg.Node.extend(/** @lends _ccsg.VideoPlayer# */{
_ccsg.Node.prototype.ctor.call(this);
// 播放结束等事件处理的队列
this._EventList = {};
- this._renderCmd.createDom();
},
_createRenderCmd: function(){
@@ -74,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();
@@ -132,9 +139,9 @@ _ccsg.VideoPlayer = _ccsg.Node.extend(/** @lends _ccsg.VideoPlayer# */{
},
cleanup: function () {
+ this._super();
+
this._renderCmd.removeDom();
- this.stopAllActions();
- this.unscheduleAllCallbacks();
},
onEnter: function () {
@@ -183,15 +190,11 @@ cc.game.on(cc.game.EVENT_SHOW, function () {
}
});
-/**
- * The VideoPlayer support list of events
- * @type {{PLAYING: string, PAUSED: string, STOPPED: string, COMPLETED: string}}
- */
_ccsg.VideoPlayer.EventType = {
- PLAYING: "play",
- PAUSED: "pause",
- STOPPED: "stop",
- COMPLETED: "complete"
+ PLAYING: 0,
+ PAUSED: 1,
+ STOPPED: 2,
+ COMPLETED: 3
};
(function (video) {
@@ -275,7 +278,7 @@ _ccsg.VideoPlayer.EventType = {
scaleX /= dpr;
scaleY /= dpr;
- var container = cc.container;
+ var container = cc.game.container;
var a = t.a * scaleX, b = t.b, c = t.c, d = t.d * scaleY;
var offsetX = container && container.style.paddingLeft && parseInt(container.style.paddingLeft);
@@ -388,9 +391,20 @@ _ccsg.VideoPlayer.EventType = {
var video = this._video;
if (node.visible) {
video.style.visibility = 'visible';
+ cc.game.container.appendChild(video);
} else {
video.style.visibility = 'hidden';
video.pause();
+ if(video){
+ var hasChild = false;
+ if('contains' in cc.game.container) {
+ hasChild = cc.game.container.contains(video);
+ }else {
+ hasChild = cc.game.container.compareDocumentPosition(video) % 16;
+ }
+ if(hasChild)
+ cc.game.container.removeChild(video);
+ }
}
};
@@ -402,20 +416,20 @@ _ccsg.VideoPlayer.EventType = {
video.className = "cocosVideo";
video.setAttribute('preload', true);
this._video = video;
- cc.container.appendChild(video);
+ cc.game.container.appendChild(video);
};
proto.removeDom = function () {
var video = this._video;
if(video){
var hasChild = false;
- if('contains' in cc.container) {
- hasChild = cc.container.contains(video);
+ if('contains' in cc.game.container) {
+ hasChild = cc.game.container.contains(video);
}else {
- hasChild = cc.container.compareDocumentPosition(video) % 16;
+ hasChild = cc.game.container.compareDocumentPosition(video) % 16;
}
if(hasChild)
- cc.container.removeChild(video);
+ cc.game.container.removeChild(video);
}
this._video = null;
this._url = "";
@@ -495,6 +509,7 @@ _ccsg.VideoPlayer.EventType = {
};
proto.isPlaying = function () {
+ var video = this._video;
if(_ccsg.VideoPlayer._polyfill.autoplayAfterOperation && this._playing){
setTimeout(function(){
video.play();
@@ -503,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/core/webview/CCSGWebView.js b/cocos2d/core/webview/CCSGWebView.js
new file mode 100644
index 0000000000..db7f3295f3
--- /dev/null
+++ b/cocos2d/core/webview/CCSGWebView.js
@@ -0,0 +1,407 @@
+/****************************************************************************
+ Copyright (c) 2013-2016 Chukong Technologies Inc.
+ http://www.cocos.com
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated engine source code (the "Software"), a limited,
+ worldwide, royalty-free, non-assignable, revocable and non-exclusive license
+ to use Cocos Creator solely to develop games on your target platforms. You shall
+ not use Cocos Creator software for developing other software or tools that's
+ used for developing games. You are not granted to publish, distribute,
+ sublicense, and/or sell copies of Cocos Creator.
+ The software or tools in this License Agreement are licensed, not sold.
+ Chukong Aipu reserves all rights not expressly granted to you.
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+ ****************************************************************************/
+
+_ccsg.WebView = _ccsg.Node.extend(/** @lends _ccsg.WebView# */{
+
+ ctor: function () {
+ _ccsg.Node.prototype.ctor.call(this);
+ this.setContentSize(cc.size(300, 200));
+ this._EventList = {};
+ },
+
+ createDomElementIfNeeded: function () {
+ if (!this._renderCmd._div) {
+ this._renderCmd.createNativeControl();
+ }
+ },
+
+ setJavascriptInterfaceScheme: function(scheme){},
+ loadData: function(data, MIMEType, encoding, baseURL){},
+ loadHTMLString: function(string, baseURL){},
+ /**
+ * Load an URL
+ * @param {String} url
+ */
+ loadURL: function(url){
+ this._renderCmd.updateURL(url);
+ this._dispatchEvent(_ccsg.WebView.EventType.LOADING);
+ },
+
+ /**
+ * Stop loading
+ */
+ stopLoading: function(){
+ cc.log("Web does not support loading");
+ },
+
+ /**
+ * Reload the WebView
+ */
+ reload: function(){
+ var iframe = this._renderCmd._iframe;
+ if(iframe){
+ var win = iframe.contentWindow;
+ if(win && win.location)
+ win.location.reload();
+ }
+ },
+
+ /**
+ * Determine whether to go back
+ */
+ canGoBack: function(){
+ cc.log("Web does not support query history");
+ return true;
+ },
+
+ /**
+ * Determine whether to go forward
+ */
+ canGoForward: function(){
+ cc.log("Web does not support query history");
+ return true;
+ },
+
+ /**
+ * go back
+ */
+ goBack: function(){
+ try{
+ if(_ccsg.WebView._polyfill.closeHistory)
+ return cc.log("The current browser does not support the GoBack");
+ var iframe = this._renderCmd._iframe;
+ if(iframe){
+ var win = iframe.contentWindow;
+ if(win && win.location)
+ win.history.back.call(win);
+ }
+ }catch(err){
+ cc.log(err);
+ }
+ },
+
+ /**
+ * go forward
+ */
+ goForward: function(){
+ try{
+ if(_ccsg.WebView._polyfill.closeHistory)
+ return cc.log("The current browser does not support the GoForward");
+ var iframe = this._renderCmd._iframe;
+ if(iframe){
+ var win = iframe.contentWindow;
+ if(win && win.location)
+ win.history.forward.call(win);
+ }
+ }catch(err){
+ cc.log(err);
+ }
+ },
+
+ /**
+ * In the webview execution within a period of js string
+ * @param {String} str
+ */
+ evaluateJS: function(str){
+ var iframe = this._renderCmd._iframe;
+ if(iframe){
+ var win = iframe.contentWindow;
+ try{
+ win.eval(str);
+ this._dispatchEvent(_ccsg.WebView.EventType.JS_EVALUATED);
+ }catch(err){
+ console.error(err);
+ }
+ }
+ },
+
+ /**
+ * Limited scale
+ */
+ setScalesPageToFit: function(){
+ cc.log("Web does not support zoom");
+ },
+
+ /**
+ * The binding event
+ * @param {_ccsg.WebView.EventType} event
+ * @param {Function} callback
+ */
+ setEventListener: function(event, callback){
+ this._EventList[event] = callback;
+ },
+
+ /**
+ * Delete events
+ * @param {_ccsg.WebView.EventType} event
+ */
+ removeEventListener: function(event){
+ this._EventList[event] = null;
+ },
+
+ _dispatchEvent: function(event) {
+ var callback = this._EventList[event];
+ if (callback)
+ callback.call(this, this, this._renderCmd._iframe.src);
+ },
+
+ _createRenderCmd: function(){
+ return new _ccsg.WebView.RenderCmd(this);
+ },
+
+ /**
+ * Set the contentSize
+ * @param {Number} width
+ * @param {Number} height
+ */
+ setContentSize: function(width, height){
+ if (width.width !== undefined && width.height !== undefined) {
+ height = width.height;
+ width = width.width;
+ }
+ _ccsg.Node.prototype.setContentSize.call(this, width, height);
+ this._renderCmd.updateSize(width, height);
+ },
+
+ /**
+ * remove node
+ */
+ cleanup: function(){
+ this._super();
+
+ this._renderCmd.removeDom();
+ },
+
+ setVisible: function ( visible ) {
+ _ccsg.Node.prototype.setVisible.call(this, visible);
+ this._renderCmd.updateVisibility();
+ }
+});
+
+_ccsg.WebView.EventType = {
+ LOADING: 0,
+ LOADED: 1,
+ ERROR: 2,
+ JS_EVALUATED: 3
+};
+
+(function(){
+
+ var polyfill = _ccsg.WebView._polyfill = {
+ devicePixelRatio: false,
+ enableDiv: false
+ };
+
+ if(cc.sys.os === cc.sys.OS_IOS)
+ polyfill.enableDiv = true;
+
+ if(cc.sys.isMobile){
+ if(cc.sys.browserType === cc.sys.BROWSER_TYPE_FIREFOX){
+ polyfill.enableBG = true;
+ }
+ }else{
+ if(cc.sys.browserType === cc.sys.BROWSER_TYPE_IE){
+ polyfill.closeHistory = true;
+ }
+ }
+
+
+})();
+
+(function(polyfill){
+
+ var RenderCmd;
+ if (cc._renderType === cc.game.RENDER_TYPE_CANVAS) {
+ RenderCmd = _ccsg.Node.CanvasRenderCmd;
+ } else {
+ RenderCmd = _ccsg.Node.WebGLRenderCmd;
+ }
+
+ _ccsg.WebView.RenderCmd = function(node){
+ RenderCmd.call(this, node);
+
+ this._parent = null;
+ this._div = null;
+ this._iframe = null;
+ this._listener = null;
+ };
+
+ var proto = _ccsg.WebView.RenderCmd.prototype = Object.create(RenderCmd.prototype);
+ proto.constructor = _ccsg.WebView.RenderCmd;
+
+ proto.transform = function (parentCmd, recursive) {
+ this.originTransform(parentCmd, recursive);
+ this.updateMatrix();
+ };
+
+ proto.updateStatus = function(){
+ polyfill.devicePixelRatio = cc.view.isRetinaEnabled();
+ var flags = _ccsg.Node._dirtyFlags, locFlag = this._dirtyFlag;
+ if(locFlag & flags.transformDirty){
+ //update the transform
+ this.transform(this.getParentRenderCmd(), true);
+ this.updateMatrix();
+ this._dirtyFlag = this._dirtyFlag & _ccsg.Node._dirtyFlags.transformDirty ^ this._dirtyFlag;
+ }
+ };
+
+ proto.initEvent = function () {
+ var node = this._node;
+ this._iframe.addEventListener("load", function(){
+ node._dispatchEvent(_ccsg.WebView.EventType.LOADED);
+ });
+ this._iframe.addEventListener("error", function(){
+ node._dispatchEvent(_ccsg.WebView.EventType.ERROR);
+ });
+ };
+
+ proto.resize = function(view){
+ view = view || cc.view;
+ var node = this._node,
+ eventManager = cc.eventManager;
+ if(node._parent && node._visible)
+ this.updateMatrix();
+ else{
+ var list = eventManager._listenersMap[cc.game.EVENT_RESIZE].getFixedPriorityListeners();
+ eventManager._removeListenerInVector(list, this._listener);
+ this._listener = null;
+ }
+ };
+
+ proto.updateMatrix = function(){
+ if (!this._div) return;
+
+ var node = this._node, scaleX = cc.view._scaleX, scaleY = cc.view._scaleY;
+ var dpr = cc.view._devicePixelRatio;
+ var t = this._worldTransform;
+
+ scaleX /= dpr;
+ scaleY /= dpr;
+
+ var container = cc.game.container;
+ var a = t.a * scaleX, b = t.b, c = t.c, d = t.d * scaleY;
+
+ var offsetX = container && container.style.paddingLeft && parseInt(container.style.paddingLeft);
+ var offsetY = container && container.style.paddingBottom && parseInt(container.style.paddingBottom);
+ var tx = t.tx * scaleX + offsetX, ty = t.ty * scaleY + offsetY;
+
+ var matrix = "matrix(" + a + "," + -b + "," + -c + "," + d + "," + tx + "," + -ty + ")";
+ this._div.style['transform'] = matrix;
+ this._div.style['-webkit-transform'] = matrix;
+ this._div.style['transform-origin'] = '0px 100% 0px';
+ this._div.style['-webkit-transform-origin'] = '0px 100% 0px';
+ };
+
+ proto.initStyle = function(){
+ if(!this._div) return;
+ var div = this._div;
+ div.style.position = "absolute";
+ div.style.bottom = "0px";
+ div.style.left = "0px";
+ };
+
+ proto.updateURL = function(url){
+ var iframe = this._iframe;
+ iframe.src = url;
+ var self = this;
+ var cb = function(){
+ self._loaded = true;
+ self.updateVisibility();
+ iframe.removeEventListener("load", cb);
+ };
+ iframe.addEventListener("load", cb);
+ };
+
+ proto.updateSize = function(w, h){
+ var div = this._div;
+ if(div){
+ div.style["width"] = w+"px";
+ div.style["height"] = h+"px";
+ }
+ };
+
+ proto.createDom = function () {
+ if(polyfill.enableDiv){
+ this._div = document.createElement("div");
+ this._div.style["-webkit-overflow"] = "auto";
+ this._div.style["-webkit-overflow-scrolling"] = "touch";
+ this._iframe = document.createElement("iframe");
+ this._div.appendChild(this._iframe);
+ }else{
+ this._div = this._iframe = document.createElement("iframe");
+ }
+
+ if(polyfill.enableBG)
+ this._div.style["background"] = "#FFF";
+
+ this._div.style["background"] = "#FFF";
+ var contentSize = this._node._contentSize;
+ this._div.style.height = contentSize.height + "px";
+ this._div.style.width = contentSize.width + "px";
+ this._div.style.overflow = "scroll";
+ this._div.style.border = "none";
+ cc.game.container.appendChild(this._div);
+ };
+
+ proto.createNativeControl = function () {
+ this.createDom();
+ this.initStyle();
+ this.initEvent();
+ };
+
+ proto.removeDom = function(){
+ var div = this._div;
+ if(div){
+ var hasChild = false;
+ if('contains' in cc.game.container) {
+ hasChild = cc.game.container.contains(div);
+ }else {
+ hasChild = cc.game.container.compareDocumentPosition(div) % 16;
+ }
+ if(hasChild)
+ cc.game.container.removeChild(div);
+ }
+ this._div = null;
+ };
+
+ proto.updateVisibility = function () {
+ var node = this._node;
+ if (!this._div) return;
+ var div = this._div;
+ if (node.visible) {
+ div.style.visibility = 'visible';
+ cc.game.container.appendChild(div);
+ } else {
+ div.style.visibility = 'hidden';
+ if(div){
+ var hasChild = false;
+ if('contains' in cc.game.container) {
+ hasChild = cc.game.container.contains(div);
+ }else {
+ hasChild = cc.game.container.compareDocumentPosition(div) % 16;
+ }
+ if(hasChild)
+ cc.game.container.removeChild(div);
+ }
+ }
+ };
+
+})(_ccsg.WebView._polyfill);
diff --git a/cocos2d/deprecated.js b/cocos2d/deprecated.js
index 9cc425071f..1b08d8831b 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
@@ -273,7 +279,9 @@ if (CC_DEV) {
}
// deprecateEnum(cc.ProgressTimer, 'cc.ProgressTimer.TYPE', 'cc.ProgressTimer.Type');
deprecateEnum(cc.game, 'cc.game.DEBUG_MODE', 'cc.DebugMode');
- deprecateEnum(cc, 'cc', 'cc.Texture2D.WrapMode', false);
+ if (!CC_JSB) {
+ deprecateEnum(cc, 'cc', 'cc.Texture2D.WrapMode', false);
+ }
if (_ccsg.EditBox) {
deprecateEnum(cc, 'cc.KEYBOARD_RETURNTYPE', '_ccsg.EditBox.KeyboardReturnType');
deprecateEnum(cc, 'cc.EDITBOX_INPUT_MODE', '_ccsg.EditBox.InputMode');
@@ -372,7 +380,6 @@ if (CC_DEV) {
'onEnterTransitionDidFinish',
'onExitTransitionDidStart',
'onExit',
- 'getNumberOfRunningActions',
'scheduleUpdate',
'scheduleUpdateWithPriority',
'unscheduleUpdate',
@@ -392,6 +399,8 @@ if (CC_DEV) {
'transform',
'getCamera',
'grid',
+ 'getOrderOfArrival',
+ 'setOrderOfArrival',
'getGrid',
'setGrid',
'getShaderProgram',
@@ -422,8 +431,6 @@ if (CC_DEV) {
_detachChild: 'removeChild',
getZOrder: 'getLocalZOrder',
setZOrder: 'setLocalZOrder',
- getOrderOfArrival: 'getSiblingIndex',
- setOrderOfArrival: 'setSiblingIndex',
boundingBox: 'getBoundingBox',
removeFromParentAndCleanup: 'removeFromParent',
removeAllChildrenWithCleanup: 'removeAllChildren',
@@ -434,7 +441,7 @@ if (CC_DEV) {
removeAllComponents: 'removeComponent',
getNodeToParentAffineTransform: 'getNodeToParentTransform',
});
-
+
// RENDERERS
function shouldNotUseNodeProp (component) {
@@ -544,29 +551,33 @@ if (CC_DEV) {
Mode: 'EmitterMode'
});
- // _ccsg.Node
- markAsRemoved(_ccsg.Node, [
- '_normalizedPositionDirty',
- '_normalizedPosition',
- '_usingNormalizedPosition',
- 'grid',
- 'userData',
- 'userObject',
- 'getNormalizedPosition',
- 'setNormalizedPosition',
- 'getCamera',
- 'getUserData',
- 'setUserData',
- 'getUserObject',
- 'setUserObject',
- 'getComponent',
- 'addComponent',
- 'removeComponent',
- 'removeAllComponents',
- 'enumerateChildren',
- 'setCameraMask',
- 'getCameraMask'
- ], '_ccsg.Node');
+ if (!CC_JSB) {
+ // _ccsg.Node
+ markAsRemoved(_ccsg.Node, [
+ '_normalizedPositionDirty',
+ '_normalizedPosition',
+ '_usingNormalizedPosition',
+ 'grid',
+ 'userData',
+ 'userObject',
+ 'getNormalizedPosition',
+ 'setNormalizedPosition',
+ 'getCamera',
+ 'getUserData',
+ 'setUserData',
+ 'getUserObject',
+ 'setUserObject',
+ 'getComponent',
+ 'addComponent',
+ 'removeComponent',
+ 'removeAllComponents',
+ 'enumerateChildren',
+ 'setCameraMask',
+ 'getCameraMask'
+ ], '_ccsg.Node');
+ }
+
+ js.obsolete(_ccsg.Node.prototype, '_ccsg.Node.ignoreAnchorPointForPosition', 'setIgnoreAnchorPointForPosition');
js.obsoletes(cc.Scale9Sprite.prototype, 'cc.Scale9Sprite', {
setPreferredSize: 'setContentSize',
@@ -612,4 +623,214 @@ 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;
+ };
+ }
+ },
+ });
+
+ (function (audioEngine) {
+ if (typeof audioEngine === 'undefined') return;
+
+ (function (prop) {
+ function error () {
+ cc.error('Sorry, %s.%s is removed.', 'cc.audioEngine', prop);
+ }
+ js.getset(audioEngine, prop, error, error);
+ })('willPlayMusic');
+
+ var musicId = -1;
+ var musicVolume = 1;
+ var effectsVolume = 1;
+ var pauseIDCache = [];
+ js.get(audioEngine, 'playMusic', function () {
+ cc.warn(INFO, 'audioEngine.playMusic', 'audioEngine.play');
+ return function (url, loop) {
+ musicId = audioEngine.play(url, loop, musicVolume);
+ return musicId;
+ }
+ });
+ js.get(audioEngine, 'stopMusic', function () {
+ cc.warn(INFO, 'audioEngine.stopMusic', 'audioEngine.stop');
+ return function () {
+ audioEngine.stop(musicId);
+ return musicId;
+ }
+ });
+ js.get(audioEngine, 'pauseMusic', function () {
+ cc.warn(INFO, 'audioEngine.pauseMusic', 'audioEngine.pause');
+ return function () {
+ audioEngine.pause(musicId);
+ return musicId;
+ }
+ });
+ js.get(audioEngine, 'resumeMusic', function () {
+ cc.warn(INFO, 'audioEngine.resumeMusic', 'audioEngine.resume');
+ return function () {
+ audioEngine.resume(musicId);
+ return musicId;
+ }
+ });
+ js.get(audioEngine, 'rewindMusic', function () {
+ cc.warn(INFO, 'audioEngine.rewindMusic', 'audioEngine.setCurrentTime');
+ return function () {
+ audioEngine.setCurrentTime(musicId, 0);
+ return musicId;
+ }
+ });
+ js.get(audioEngine, 'getMusicVolume', function () {
+ cc.warn(INFO, 'audioEngine.getMusicVolume', 'audioEngine.getVolume');
+ return function () {
+ return musicVolume;
+ }
+ });
+ js.get(audioEngine, 'setMusicVolume', function () {
+ cc.warn(INFO, 'audioEngine.setMusicVolume', 'audioEngine.setVolume');
+ return function (volume) {
+ musicVolume = volume;
+ audioEngine.setVolume(musicId, musicVolume);
+ return musicVolume;
+ }
+ });
+ js.get(audioEngine, 'isMusicPlaying', function () {
+ cc.warn(INFO, 'audioEngine.isMusicPlaying', 'audioEngine.getState');
+ return function () {
+ return audioEngine.getState(musicId) === audioEngine.AudioState.PLAYING;
+ }
+ });
+ js.get(audioEngine, 'playEffect', function () {
+ cc.warn(INFO, 'audioEngine.playEffect', 'audioEngine.play');
+
+ return function (url, loop, volume) {
+ return audioEngine.play(url, loop, volume === undefined ? effectsVolume : volume);
+ }
+ });
+ js.get(audioEngine, 'setEffectsVolume', function (volume) {
+ cc.warn(INFO, 'audioEngine.setEffectsVolume', 'audioEngine.setVolume');
+ return function (volume) {
+ effectsVolume = volume;
+ var id2audio = audioEngine._id2audio;
+ for (var id in id2audio) {
+ if (id === musicId) continue;
+ audioEngine.setVolume(id, volume);
+ }
+ }
+ });
+ js.get(audioEngine, 'getEffectsVolume', function () {
+ cc.warn(INFO, 'audioEngine.getEffectsVolume', 'audioEngine.getVolume');
+ return function () {
+ return effectsVolume;
+ }
+ });
+ js.get(audioEngine, 'pauseEffect', function () {
+ cc.warn(INFO, 'audioEngine.pauseEffect', 'audioEngine.pause');
+
+ return function (id) {
+ return audioEngine.pause(id);
+ }
+ });
+ js.get(audioEngine, 'pauseAllEffects', function () {
+ cc.warn(INFO, 'audioEngine.pauseAllEffects', 'audioEngine.pauseAll');
+
+ return function () {
+ var id2audio = audioEngine._id2audio;
+ for (var id in id2audio) {
+ if (id === musicId) continue;
+ var audio = id2audio[id];
+ var state = audio.getState();
+ if (state === audioEngine.AudioState.PLAYING) {
+ pauseIDCache.push(id);
+ audio.pause();
+ }
+ }
+ }
+ });
+ js.get(audioEngine, 'resumeEffect', function () {
+ cc.warn(INFO, 'audioEngine.resumeEffect', 'audioEngine.resume');
+ return function (id) {
+ audioEngine.resume(id);
+ }
+ });
+ js.get(audioEngine, 'resumeAllEffects', function () {
+ cc.warn(INFO, 'audioEngine.resumeEffect', 'audioEngine.resume');
+ return function () {
+ var id2audio = audioEngine._id2audio;
+ while (pauseIDCache.length > 0) {
+ var id = pauseIDCache.pop();
+ var audio = id2audio[id];
+ if (audio && audio.resume)
+ audio.resume();
+ }
+ }
+ });
+ js.get(audioEngine, 'stopEffect', function () {
+ cc.warn(INFO, 'audioEngine.stopEffect', 'audioEngine.stop');
+ return function (id) {
+ return audioEngine.stop(id);
+ }
+ });
+ js.get(audioEngine, 'stopAllEffects', function () {
+ cc.warn(INFO, 'audioEngine.stopAllEffects', 'audioEngine.stopAll');
+ return function () {
+ var id2audio = audioEngine._id2audio;
+ for (var id in id2audio) {
+ if (id === musicId) continue;
+ var audio = id2audio[id];
+ var state = audio.getState();
+ if (state === audioEngine.AudioState.PLAYING) {
+ audio.stop();
+ }
+ }
+ }
+ });
+ js.get(audioEngine, 'unloadEffect', function () {
+ cc.warn(INFO, 'audioEngine.unloadEffect', 'audioEngine.stop');
+ return function (id) {
+ return audioEngine.stop(id);
+ }
+ });
+
+ if (!CC_JSB) {
+ js.get(audioEngine, 'end', function () {
+ cc.warn(INFO, 'audioEngine.end', 'audioEngine.stopAll');
+ return function () {
+ return audioEngine.stopAll();
+ }
+ });
+ }
+
+ })(cc.audioEngine);
+
}
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 940b8aa0f7..da8dacb4a9 100644
--- a/cocos2d/tilemap/CCSGTMXLayer.js
+++ b/cocos2d/tilemap/CCSGTMXLayer.js
@@ -145,7 +145,8 @@ _ccsg.TMXLayer = _ccsg.Node.extend(/** @lends _ccsg.TMXLayer# */{
maxGid = tileset.firstGid + count,
grids = this._texGrids,
grid = null,
- override = grids[gid] ? true : false;
+ override = grids[gid] ? true : false,
+ texelCorrect = cc.macro.FIX_ARTIFACTS_BY_STRECHING_TEXEL ? 0.5 : 0;
for (; gid < maxGid; ++gid) {
// Avoid overlapping
@@ -162,8 +163,12 @@ _ccsg.TMXLayer = _ccsg.Node.extend(/** @lends _ccsg.TMXLayer# */{
t: 0, l: 0, r: 0, b: 0
};
tileset.rectForGID(gid, grid);
- grid.t = grid.y / imageH;
- grid.l = grid.x / imageW;
+ grid.x += texelCorrect;
+ grid.y += texelCorrect;
+ grid.width -= texelCorrect*2;
+ grid.height -= texelCorrect*2;
+ grid.t = (grid.y) / imageH;
+ grid.l = (grid.x) / imageW;
grid.r = (grid.x + grid.width) / imageW;
grid.b = (grid.y + grid.height) / imageH;
grids[gid] = grid;
@@ -321,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;
},
@@ -329,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;
},
@@ -434,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) {
@@ -477,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 fad0e201b3..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);
@@ -167,14 +169,16 @@ proto.rendering = function (ctx, scaleX, scaleY) {
wrapper.setTransform(wt, scaleX, scaleY);
wrapper.setGlobalAlpha(alpha);
+ var axis, tileOffset, odd_even, diffX1, diffY1;
+
if (layerOrientation === Orientation.HEX) {
- var axis = node._staggerAxis,
- index = node._staggerIndex,
- hexSideLength = node._hexSideLength,
- tileOffset = node.tileset.tileOffset;
- var odd_even = (index === StaggerIndex.STAGGERINDEX_ODD) ? 1 : -1;
- var diffX1 = (axis === StaggerAxis.STAGGERAXIS_X) ? ((maptw - hexSideLength)/2) : 0;
- var diffY1 = (axis === StaggerAxis.STAGGERAXIS_Y) ? ((mapth - hexSideLength)/2) : 0;
+ var index = node._staggerIndex,
+ hexSideLength = node._hexSideLength;
+ axis = node._staggerAxis;
+ tileOffset = node.tileset.tileOffset;
+ odd_even = (index === StaggerIndex.STAGGERINDEX_ODD) ? 1 : -1;
+ diffX1 = (axis === StaggerAxis.STAGGERAXIS_X) ? ((maptw - hexSideLength)/2) : 0;
+ diffY1 = (axis === StaggerAxis.STAGGERAXIS_Y) ? ((mapth - hexSideLength)/2) : 0;
}
for (row = startRow; row < maxRow; ++row) {
diff --git a/cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js b/cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js
index ea94ebe8e4..a26f45bc5e 100644
--- a/cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js
+++ b/cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js
@@ -121,16 +121,17 @@ proto.uploadData = function (f32buffer, ui32buffer, vertexDataOffset) {
w = tilew * a, h = tileh * d, gt, gl, gb, gr,
wa = a, wb = b, wc = c, wd = d, wtx = tx, wty = ty, // world
flagged = false, flippedX = false, flippedY = false,
- vertices = this._vertices;
+ vertices = this._vertices,
+ axis, tileOffset, diffX1, diffY1, odd_even;
if (layerOrientation === Orientation.HEX) {
- var axis = node._staggerAxis,
- index = node._staggerIndex,
- hexSideLength = node._hexSideLength,
- tileOffset = node.tileset.tileOffset;
- var odd_even = (index === StaggerIndex.STAGGERINDEX_ODD) ? 1 : -1;
- var diffX1 = (axis === StaggerAxis.STAGGERAXIS_X) ? ((maptw - hexSideLength)/2) : 0;
- var diffY1 = (axis === StaggerAxis.STAGGERAXIS_Y) ? ((mapth - hexSideLength)/2) : 0;
+ var index = node._staggerIndex,
+ hexSideLength = node._hexSideLength;
+ axis = node._staggerAxis;
+ tileOffset = node.tileset.tileOffset;
+ odd_even = (index === StaggerIndex.STAGGERINDEX_ODD) ? 1 : -1;
+ diffX1 = (axis === StaggerAxis.STAGGERAXIS_X) ? ((maptw - hexSideLength)/2) : 0;
+ diffY1 = (axis === StaggerAxis.STAGGERAXIS_Y) ? ((mapth - hexSideLength)/2) : 0;
}
for (row = startRow; row < maxRow; ++row) {
diff --git a/cocos2d/tilemap/CCTMXXMLParser.js b/cocos2d/tilemap/CCTMXXMLParser.js
index 1ab54869f8..94bb8ebb90 100644
--- a/cocos2d/tilemap/CCTMXXMLParser.js
+++ b/cocos2d/tilemap/CCTMXXMLParser.js
@@ -275,7 +275,6 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{
// tile properties
_tileProperties:null,
_resources:"",
- _currentFirstGID:0,
// hex map values
_staggerAxis: null,
@@ -299,8 +298,6 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{
this.properties = [];
this._tileProperties = {};
- this._currentFirstGID = 0;
-
if (resourcePath !== undefined) {
this.initWithXML(tmxFile,resourcePath);
} else if(tmxFile !== undefined){
@@ -589,9 +586,10 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{
/** Initalises parsing of an XML file, either a tmx (Map) file or tsx (Tileset) file
* @param {String} tmxFile
* @param {boolean} [isXmlString=false]
+ * @param {Number} tilesetFirstGid
* @return {Element}
*/
- parseXMLFile:function (tmxFile, isXmlString) {
+ parseXMLFile:function (tmxFile, isXmlString, tilesetFirstGid) {
isXmlString = isXmlString || false;
var xmlStr = isXmlString ? tmxFile : cc.loader.getRes(tmxFile);
if(!xmlStr) throw new Error("Please load the resource first : " + tmxFile);
@@ -672,19 +670,17 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{
// If this is an external tileset then start parsing that
var tsxName = selTileset.getAttribute('source');
if (tsxName) {
- //this._currentFirstGID = parseInt(selTileset.getAttribute('firstgid'));
+ var currentFirstGID = parseInt(selTileset.getAttribute('firstgid'));
var tsxPath = isXmlString ? cc.path.join(this._resources, tsxName) : cc.path.changeBasename(tmxFile, tsxName);
- this.parseXMLFile(tsxPath);
+ this.parseXMLFile(tsxPath, false, currentFirstGID);
} else {
var tileset = new cc.TMXTilesetInfo();
tileset.name = selTileset.getAttribute('name') || "";
- //TODO need fix
- //if(this._currentFirstGID === 0){
- tileset.firstGid = parseInt(selTileset.getAttribute('firstgid')) || 0;
- //}else{
- // tileset.firstGid = this._currentFirstGID;
- // this._currentFirstGID = 0;
- //}
+ if (tilesetFirstGid) {
+ tileset.firstGid = tilesetFirstGid;
+ } else {
+ tileset.firstGid = parseInt(selTileset.getAttribute('firstgid')) || 0;
+ }
tileset.spacing = parseInt(selTileset.getAttribute('spacing')) || 0;
tileset.margin = parseInt(selTileset.getAttribute('margin')) || 0;
@@ -1044,7 +1040,6 @@ cc.TMXMapInfo = cc.SAXParser.extend(/** @lends cc.TMXMapInfo# */{
this.storingCharacters = false;
this.layerAttrs = cc.TMXLayerInfo.ATTRIB_NONE;
this.parentElement = cc.TiledMap.NONE;
- this._currentFirstGID = 0;
}
});
diff --git a/cocos2d/tilemap/CCTiledLayer.js b/cocos2d/tilemap/CCTiledLayer.js
index 358048ab4f..91bea306c4 100644
--- a/cocos2d/tilemap/CCTiledLayer.js
+++ b/cocos2d/tilemap/CCTiledLayer.js
@@ -349,6 +349,24 @@ var TiledLayer = cc.Class({
}
},
+ /**
+ * !#en Set the opacity of all tiles
+ * !#zh 设置所有 Tile 的透明度
+ * @method setTileOpacity
+ * @param {Number} opacity
+ * @example
+ * tiledLayer.setTileOpacity(128);
+ */
+ setTileOpacity: function(opacity) {
+ if (this._sgNode) {
+ if (CC_JSB) {
+ this._sgNode.setTileOpacity(opacity);
+ } else {
+ this._sgNode._opacity = opacity;
+ }
+ }
+ },
+
/**
* !#en Gets layer size.
* !#zh 获得层大小。
diff --git a/cocos2d/tilemap/CCTiledMap.js b/cocos2d/tilemap/CCTiledMap.js
index e090315b7f..5e55296329 100644
--- a/cocos2d/tilemap/CCTiledMap.js
+++ b/cocos2d/tilemap/CCTiledMap.js
@@ -814,6 +814,9 @@ var TiledMap = cc.Class({
var ret = sgNode.initWithXML(file.tmxXmlStr, resPath);
if (ret) {
+ // Asset is changed, the layers are recreated.
+ // The layers of pre asset should be cleaned.
+ self._detachedLayers.length = 0;
self._onMapLoaded();
}
} else {
diff --git a/extends.js b/extends.js
index acea5b0d64..7c32d5e406 100644
--- a/extends.js
+++ b/extends.js
@@ -57,3 +57,7 @@ if (!(CC_EDITOR && Editor.isMainProcess)) {
require('./extensions/ccpool/CCNodePool.js');
require('./extensions/ccpool/CCPool.js');
}
+
+if (!CC_EDITOR || !Editor.isMainProcess) {
+ require('./cocos2d/deprecated');
+}
\ No newline at end of file
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/SGSkeleton.js b/extensions/spine/SGSkeleton.js
index 386d7b4614..43fd396091 100644
--- a/extensions/spine/SGSkeleton.js
+++ b/extensions/spine/SGSkeleton.js
@@ -208,7 +208,8 @@ sp._SGSkeleton = _ccsg.Node.extend({
},
/**
- * Finds a bone by name. This does a string comparison for every bone.
+ * Finds a bone by name. This does a string comparison for every bone.
+ * Returns a {{#crossLinkModule "spine"}}spine{{/crossLinkModule}}.Bone object.
* @param {String} boneName
* @returns {spine.Bone}
*/
@@ -217,7 +218,9 @@ sp._SGSkeleton = _ccsg.Node.extend({
},
/**
- * Finds a slot by name. This does a string comparison for every slot.
+ * Finds a slot by name. This does a string comparison for every slot.
+ * Returns a {{#crossLinkModule "spine"}}spine{{/crossLinkModule}}.Slot object.
+ *
* @param {String} slotName
* @returns {spine.Slot}
*/
@@ -226,7 +229,9 @@ sp._SGSkeleton = _ccsg.Node.extend({
},
/**
- * Finds a skin by name and makes it the active skin. This does a string comparison for every skin. Note that setting the skin does not change which attachments are visible.
+ * Finds a skin by name and makes it the active skin. This does a string comparison for every skin. Note that setting the skin does not change which attachments are visible.
+ * Returns a {{#crossLinkModule "spine"}}spine{{/crossLinkModule}}.Skin object.
+ *
* @param {string} skinName
* @returns {spine.Skin}
*/
@@ -235,10 +240,12 @@ sp._SGSkeleton = _ccsg.Node.extend({
},
/**
- * Returns the attachment for the slot and attachment name. The skeleton looks first in its skin, then in the skeleton data’s default skin.
+ * Returns the attachment for the slot and attachment name. The skeleton looks first in its skin, then in the skeleton data’s default skin.
+ * Returns a {{#crossLinkModule "spine"}}spine{{/crossLinkModule}}.Attachment object.
+ *
* @param {String} slotName
* @param {String} attachmentName
- * @returns {spine.RegionAttachment|spine.BoundingBoxAttachment}
+ * @returns {spine.Attachment}
*/
getAttachment: function (slotName, attachmentName) {
return this._skeleton.getAttachmentBySlotName(slotName, attachmentName);
diff --git a/extensions/spine/SGSkeletonCanvasRenderCmd.js b/extensions/spine/SGSkeletonCanvasRenderCmd.js
index c1bc03ab05..21081a582f 100644
--- a/extensions/spine/SGSkeletonCanvasRenderCmd.js
+++ b/extensions/spine/SGSkeletonCanvasRenderCmd.js
@@ -162,6 +162,7 @@ proto._createSprite = function(slot, attachment){
proto._updateChild = function(){
var locSkeleton = this._node._skeleton, slots = locSkeleton.slots;
+ var color = this._displayedColor, opacity = this._displayedOpacity;
var i, n, selSprite, ax, ay;
var slot, attachment, slotNode;
@@ -218,8 +219,8 @@ proto._updateChild = function(){
}
//hack for sprite
- selSprite._renderCmd._displayedOpacity = 0 | (this._node.getOpacity() * locSkeleton.a * slot.a);
- var r = 0 | (locSkeleton.r * slot.r * 255), g = 0 | (locSkeleton.g * slot.g * 255), b = 0 | (locSkeleton.b * slot.b * 255);
+ selSprite._renderCmd._displayedOpacity = 0 | (opacity * slot.a);
+ var r = 0 | (color.r * slot.r), g = 0 | (color.g * slot.g), b = 0 | (color.b * slot.b);
selSprite.setColor(cc.color(r,g,b));
selSprite._renderCmd._updateColor();
} else if (type === spine.AttachmentType.skinnedmesh) {
diff --git a/extensions/spine/SGSkeletonWebGLRenderCmd.js b/extensions/spine/SGSkeletonWebGLRenderCmd.js
index 657806792c..979c321bed 100644
--- a/extensions/spine/SGSkeletonWebGLRenderCmd.js
+++ b/extensions/spine/SGSkeletonWebGLRenderCmd.js
@@ -39,7 +39,7 @@ proto.constructor = sp._SGSkeleton.WebGLRenderCmd;
proto.rendering = function (ctx) {
var node = this._node, tmpQuad = this._tmpQuad;
- var color = node.getColor(), locSkeleton = node._skeleton;
+ var color = this._displayedColor, locSkeleton = node._skeleton;
var textureAtlas, attachment, slot, i, n;
var locBlendFunc = node._blendFunc;
@@ -60,7 +60,7 @@ proto.rendering = function (ctx) {
locSkeleton.r = color.r / 255;
locSkeleton.g = color.g / 255;
locSkeleton.b = color.b / 255;
- locSkeleton.a = node.getOpacity() / 255;
+ locSkeleton.a = this._displayedOpacity / 255;
if (premultiAlpha) {
locSkeleton.r *= locSkeleton.a;
locSkeleton.g *= locSkeleton.a;
diff --git a/extensions/spine/Skeleton.js b/extensions/spine/Skeleton.js
index 67dea2fa9a..384b68f013 100644
--- a/extensions/spine/Skeleton.js
+++ b/extensions/spine/Skeleton.js
@@ -286,6 +286,28 @@ sp.Skeleton = cc.Class({
tooltip: 'i18n:COMPONENT.skeleton.loop'
},
+ /**
+ * !#en Indicates whether to enable premultiplied alpha.
+ * You should disable this option when image's transparent area appears to have opaque pixels,
+ * or enable this option when image's half transparent area appears to be darken.
+ * !#zh 是否启用贴图预乘。
+ * 当图片的透明区域出现色块时需要关闭该选项,当图片的半透明区域颜色变黑时需要启用该选项。
+ * @property {Boolean} premultipliedAlpha
+ * @default true
+ */
+ _premultipliedAlpha: true,
+ premultipliedAlpha: {
+ get: function () {
+ return this._premultipliedAlpha;
+ },
+ set: function (value) {
+ this._premultipliedAlpha = value;
+ if (this._sgNode) {
+ this._sgNode.setPremultipliedAlpha(value);
+ }
+ },
+ tooltip: 'i18n:COMPONENT.skeleton.premultipliedAlpha'
+ },
/**
* !#en The time scale of this skeleton.
@@ -417,6 +439,9 @@ sp.Skeleton = cc.Class({
cc._throw(e);
}
}
+
+ sgNode.setPremultipliedAlpha(this._premultipliedAlpha);
+
this.animation = this.defaultAnimation;
if (CC_EDITOR) {
sgNode.setDebugSlotsEnabled(this.debugSlots);
@@ -504,10 +529,13 @@ sp.Skeleton = cc.Class({
/**
* !#en
* Finds a bone by name.
- * This does a string comparison for every bone.
+ * This does a string comparison for every bone.
+ * Returns a {{#crossLinkModule "spine"}}spine{{/crossLinkModule}}.Bone object.
* !#zh
* 通过名称查找 bone。
- * 这里对每个 bone 的名称进行了对比。
+ * 这里对每个 bone 的名称进行了对比。
+ * 返回一个 {{#crossLinkModule "spine"}}spine{{/crossLinkModule}}.Bone 对象。
+ *
* @method findBone
* @param {String} boneName
* @return {spine.Bone}
@@ -521,11 +549,12 @@ sp.Skeleton = cc.Class({
/**
* !#en
- * Finds a slot by name.
- * This does a string comparison for every slot.
+ * Finds a slot by name. This does a string comparison for every slot.
+ * Returns a {{#crossLinkModule "spine"}}spine{{/crossLinkModule}}.Slot object.
* !#zh
- * 通过名称查找 slot。
- * 这里对每个 slot 的名称进行了比较。
+ * 通过名称查找 slot。这里对每个 slot 的名称进行了比较。
+ * 返回一个 {{#crossLinkModule "spine"}}spine{{/crossLinkModule}}.Slot 对象。
+ *
* @method findSlot
* @param {String} slotName
* @return {spine.Slot}
@@ -540,12 +569,14 @@ sp.Skeleton = cc.Class({
/**
* !#en
* Finds a skin by name and makes it the active skin.
- * This does a string comparison for every skin.
- * Note that setting the skin does not change which attachments are visible.
+ * This does a string comparison for every skin.
+ * Note that setting the skin does not change which attachments are visible.
+ * Returns a {{#crossLinkModule "spine"}}spine{{/crossLinkModule}}.Skin object.
* !#zh
- * 按名称查找皮肤,激活该皮肤。
- * 这里对每个皮肤的名称进行了比较。
- * 注意:设置皮肤不会改变 attachment 的可见性。。
+ * 按名称查找皮肤,激活该皮肤。这里对每个皮肤的名称进行了比较。
+ * 注意:设置皮肤不会改变 attachment 的可见性。
+ * 返回一个 {{#crossLinkModule "spine"}}spine{{/crossLinkModule}}.Skin 对象。
+ *
* @method setSkin
* @param {String} skinName
* @return {spine.Skin}
@@ -560,14 +591,16 @@ sp.Skeleton = cc.Class({
/**
* !#en
* Returns the attachment for the slot and attachment name.
- * The skeleton looks first in its skin, then in the skeleton data’s default skin.
+ * The skeleton looks first in its skin, then in the skeleton data’s default skin.
+ * Returns a {{#crossLinkModule "spine"}}spine{{/crossLinkModule}}.Attachment object.
* !#zh
- * 通过 slot 和 attachment 的名称获取 attachment。
- * Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。
+ * 通过 slot 和 attachment 的名称获取 attachment。Skeleton 优先查找它的皮肤,然后才是 Skeleton Data 中默认的皮肤。
+ * 返回一个 {{#crossLinkModule "spine"}}spine{{/crossLinkModule}}.Attachment 对象。
+ *
* @method getAttachment
* @param {String} slotName
* @param {String} attachmentName
- * @return {spine.RegionAttachment|sp.spine.BoundingBoxAttachment}
+ * @return {spine.Attachment}
*/
getAttachment: function (slotName, attachmentName) {
if (this._sgNode) {
@@ -609,7 +642,7 @@ sp.Skeleton = cc.Class({
///**
// * Return the renderer of attachment.
// * @method getTextureAtlas
- // * @param {spine.RegionAttachment|sp.spine.BoundingBoxAttachment} regionAttachment
+ // * @param {spine.RegionAttachment|spine.BoundingBoxAttachment} regionAttachment
// * @return {_ccsg.Node}
// */
//getTextureAtlas: function (regionAttachment) {
@@ -621,8 +654,10 @@ sp.Skeleton = cc.Class({
// ANIMATION
/**
- * !#en Sets animation state data.
- * !#zh 设置动画状态数据。
+ * !#en Sets animation state data.
+ * The parameter type is {{#crossLinkModule "spine"}}spine{{/crossLinkModule}}.AnimationStateData.
+ * !#zh 设置动画状态数据。
+ * 参数是 {{#crossLinkModule "spine"}}spine{{/crossLinkModule}}.AnimationStateData。
* @method setAnimationStateData
* @param {spine.AnimationStateData} stateData
*/
@@ -662,8 +697,10 @@ sp.Skeleton = cc.Class({
},
/**
- * !#en Set the current animation. Any queued animations are cleared.
- * !#zh 设置当前动画。队列中的任何的动画将被清除。
+ * !#en Set the current animation. Any queued animations are cleared.
+ * Returns a {{#crossLinkModule "spine"}}spine{{/crossLinkModule}}.TrackEntry object.
+ * !#zh 设置当前动画。队列中的任何的动画将被清除。
+ * 返回一个 {{#crossLinkModule "spine"}}spine{{/crossLinkModule}}.TrackEntry 对象。
* @method setAnimation
* @param {Number} trackIndex
* @param {String} name
@@ -689,8 +726,10 @@ sp.Skeleton = cc.Class({
},
/**
- * !#en Adds an animation to be played delay seconds after the current or last queued animation.
- * !#zh 添加一个动画到动画队列尾部,还可以延迟指定的秒数。
+ * !#en Adds an animation to be played delay seconds after the current or last queued animation.
+ * Returns a {{#crossLinkModule "spine"}}spine{{/crossLinkModule}}.TrackEntry object.
+ * !#zh 添加一个动画到动画队列尾部,还可以延迟指定的秒数。
+ * 返回一个 {{#crossLinkModule "spine"}}spine{{/crossLinkModule}}.TrackEntry 对象。
* @method addAnimation
* @param {Number} trackIndex
* @param {String} name
@@ -706,8 +745,10 @@ sp.Skeleton = cc.Class({
},
/**
- * !#en Returns track entry by trackIndex.
- * !#zh 通过 track 索引获取 TrackEntry。
+ * !#en Returns track entry by trackIndex.
+ * Returns a {{#crossLinkModule "spine"}}spine{{/crossLinkModule}}.TrackEntry object.
+ * !#zh 通过 track 索引获取 TrackEntry。
+ * 返回一个 {{#crossLinkModule "spine"}}spine{{/crossLinkModule}}.TrackEntry 对象。
* @method getCurrent
* @param trackIndex
* @return {spine.TrackEntry}
diff --git a/extensions/spine/SkeletonData.js b/extensions/spine/SkeletonData.js
index 191de16798..373fceae74 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: [],
@@ -187,8 +187,10 @@ var SkeletonData = cc.Class({
},
/**
- * !#en Get the included SkeletonData used in spine runtime.
- * !#zh 获取 Spine Runtime 使用的 SkeletonData。
+ * !#en Get the included SkeletonData used in spine runtime.
+ * Returns a {{#crossLinkModule "spine"}}spine{{/crossLinkModule}}.SkeletonData object.
+ * !#zh 获取 Spine Runtime 使用的 SkeletonData。
+ * 返回一个 {{#crossLinkModule "spine"}}spine{{/crossLinkModule}}.SkeletonData 对象。
* @method getRuntimeData
* @param {Boolean} [quiet=false]
* @return {spine.SkeletonData}
diff --git a/extensions/spine/index.js b/extensions/spine/index.js
index 24e2f04352..67d7db7569 100644
--- a/extensions/spine/index.js
+++ b/extensions/spine/index.js
@@ -124,3 +124,13 @@ if (!CC_EDITOR || !Editor.isMainProcess) {
else {
require('./SkeletonData');
}
+
+/**
+ * !#en
+ * `spine` is the namespace for official Spine Runtime, which officially implemented and maintained by Spine.
+ * Please refer to the official documentation for its detailed usage: [http://en.esotericsoftware.com/spine-using-runtimes](http://en.esotericsoftware.com/spine-using-runtimes)
+ * !#zh
+ * spine 模块是 Spine 官方运行库的 API 入口,由 Spine 官方统一实现和维护,具体用法请参考:[http://zh.esotericsoftware.com/spine-using-runtimes](http://zh.esotericsoftware.com/spine-using-runtimes)
+ * @module spine
+ * @main spine
+ */
diff --git a/gulp/tasks/engine.js b/gulp/tasks/engine.js
index 9c4f69b30e..c793eb6d04 100644
--- a/gulp/tasks/engine.js
+++ b/gulp/tasks/engine.js
@@ -108,7 +108,7 @@ exports.buildCocosJsMin = function (sourceFile, outputFile, excludes, callback,
var raw = rawSize.size;
var zipped = zippedSize.size;
var percent = ((zipped / raw) * 100).toFixed(2);
- console.log(`Size of ${outputFile}: minimized: ${Chalk.cyan(raw + 'B')} zipped: ${Chalk.cyan(zipped + 'B')}, compression ratio: ${percent}%`);
+ console.log(`Size of ${outputFile}: minimized: ${Chalk.cyan(raw)}B zipped: ${Chalk.cyan(zipped)}B, compression ratio: ${percent}%`);
this.emit('end');
}));
}
diff --git a/gulp/tasks/modular.js b/gulp/tasks/modular.js
index c8240efeb8..f7f511b1bf 100644
--- a/gulp/tasks/modular.js
+++ b/gulp/tasks/modular.js
@@ -112,6 +112,10 @@ var modules = {
'./cocos2d/core/videoplayer/CCSGVideoPlayer.js'
],
+ 'WebView': [
+ './cocos2d/core/webview/CCSGWebView.js'
+ ],
+
'MotionStreak': [
'./cocos2d/motion-streak/CCSGMotionStreak.js',
'./cocos2d/motion-streak/CCSGMotionStreakWebGLRenderCmd.js',
diff --git a/gulp/tasks/utils.js b/gulp/tasks/utils.js
index 6aa4955eea..582df58946 100644
--- a/gulp/tasks/utils.js
+++ b/gulp/tasks/utils.js
@@ -26,8 +26,8 @@ exports.uglifyOptions = function (minify, global_defs) {
//dead_code: true, // discard unreachable code
drop_debugger: false, // discard “debugger” statements
unsafe: false, // some unsafe optimizations (see below)
- conditionals: false, // optimize if-s and conditional expressions
- comparisons: false, // optimize comparisons
+ //conditionals: false, // optimize if-s and conditional expressions
+ //comparisons: false, // optimize comparisons
//evaluate: true, // evaluate constant expressions
booleans: false, // optimize boolean expressions
loops: false, // optimize loops
diff --git a/gulpfile.js b/gulpfile.js
index b3be965f30..7da5a86c95 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -49,7 +49,9 @@ gulp.task('build-cut-modular', function (done) {
Modular.buildModular('modular-cocos2d-cut.js', './bin', [], done);
});
-gulp.task('build-modular-cocos2d', ['build-all-modular', 'build-cut-modular']);
+gulp.task('build-modular-cocos2d', ['build-all-modular', 'build-cut-modular'], function (done) {
+ Del(['./bin/cocos2d-js.js', './bin/cocos2d-js-min.js', './bin/.cache'], done);
+});
/////////////
@@ -140,12 +142,12 @@ gulp.task('test-no-build', function (done) {
// global //
////////////
-gulp.task('build-dev', ['build-preview', 'build-jsb-extends-dev'], function (done) {
+gulp.task('build-dev', ['build-preview', 'build-jsb'], function (done) {
// make dist version dirty
- Del(['./bin/cocos2d-js.js', './bin/cocos2d-js-min.js', './bin/jsb_polyfill.js', './bin/.cache'], done);
+ Del(['./bin/.cache'], done);
});
-gulp.task('build', ['build-html5', 'build-preview', 'build-jsb-extends-min', 'build-jsb-extends-dev'], function (done) {
+gulp.task('build', ['build-html5', 'build-preview', 'build-jsb'], function (done) {
Del(['./bin/.cache'], done);
});
diff --git a/index.js b/index.js
index 82e68c17f4..131ca7f84c 100644
--- a/index.js
+++ b/index.js
@@ -75,8 +75,5 @@ if (CC_EDITOR) {
if (isMainProcess) {
Editor.versions['cocos2d'] = require('./package.json').version;
}
-else {
- require('./cocos2d/deprecated');
-}
module.exports = cc;
diff --git a/jsb/index.js b/jsb/index.js
index 18f61b6f61..26f7833650 100644
--- a/jsb/index.js
+++ b/jsb/index.js
@@ -54,21 +54,19 @@ if (_engineNumberVersion) {
}
}
+var originLog = console.log;
+
// cc.initEngine
cc.initEngine = function (config, cb) {
require('script/jsb.js');
cc._renderType = cc.game.RENDER_TYPE_OPENGL;
- if (config) {
- cc._initDebugSetting(config[cc.game.CONFIG_KEY.debugMode]);
- }
cc._engineLoaded = true;
- cc.log(cc.ENGINE_VERSION);
+ originLog(cc.ENGINE_VERSION);
if (cb) cb();
};
// overwrite original console.log
try {
- var originLog = console.log;
console.log = function () {
originLog.call(console, cc.js.formatStr.apply(null, arguments));
};
@@ -98,12 +96,14 @@ require('./jsb-scale9sprite');
require('./jsb-label');
require('./jsb-editbox');
require('./jsb-videoplayer');
+require('./jsb-webview.js');
require('./jsb-particle');
require('./jsb-spine');
require('./jsb-enums');
require('./jsb-event');
require('./jsb-action');
require('./jsb-etc');
+require('./jsb-audio');
if (cc.runtime) {
require('./versions/jsb-polyfill-runtime');
diff --git a/jsb/jsb-action.js b/jsb/jsb-action.js
index f2f0659f6f..6880d17034 100644
--- a/jsb/jsb-action.js
+++ b/jsb/jsb-action.js
@@ -112,6 +112,16 @@ for (var i = 0; i < actionArr.length; ++i) {
}
}
+cc.targetedAction = function (target, action) {
+ return new cc.TargetedAction(target, action);
+};
+
+cc.TargetedAction.prototype._ctor = function(target, action) {
+ var node = target._sgNode || target;
+ node._owner = target;
+ action && this.initWithTarget(node, action);
+};
+
cc.follow = function (followedNode, rect) {
return new cc.Follow(followedNode._sgNode, rect);
};
@@ -123,6 +133,27 @@ cc.Follow.prototype.update = function(dt) {
}
};
+function setRendererVisibility (sgNode, toggleVisible, visible) {
+ if (!sgNode) { return; }
+ var _renderComps = sgNode._owner.getComponentsInChildren(cc._SGComponent);
+ for (var i = 0; i < _renderComps.length; ++i) {
+ var render = _renderComps[i];
+ render.enabled = toggleVisible ? !render.enabled : visible;
+ }
+}
+
+cc.Show.prototype.update = function (dt) {
+ setRendererVisibility(this.getTarget(), false, true);
+};
+
+cc.Hide.prototype.update = function (dt) {
+ setRendererVisibility(this.getTarget(), false, false);
+};
+
+cc.ToggleVisibility.prototype.update = function (dt) {
+ setRendererVisibility(this.getTarget(), true);
+};
+
// Special call func
cc.callFunc = function (selector, selectorTarget, data) {
var callback = function (sender, data) {
@@ -178,6 +209,7 @@ cc.Node.prototype.runAction = function (action) {
action.release();
action._retained = false;
}
+ return action;
};
function getSGTarget (target) {
@@ -315,24 +347,22 @@ function syncColorUpdate (dt) {
// Sub classes must be registered before their super class.
// Otherwise, JSB there will be internal Error: "too much recursion".
var actionUpdate = {
- 'MoveTo': syncPositionUpdate,
'MoveBy': syncPositionUpdate,
- '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-audio.js b/jsb/jsb-audio.js
new file mode 100644
index 0000000000..e79c41cb26
--- /dev/null
+++ b/jsb/jsb-audio.js
@@ -0,0 +1,144 @@
+/****************************************************************************
+ Copyright (c) 2013-2016 Chukong Technologies Inc.
+
+ http://www.cocos.com
+
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated engine source code (the "Software"), a limited,
+ worldwide, royalty-free, non-assignable, revocable and non-exclusive license
+ to use Cocos Creator solely to develop games on your target platforms. You shall
+ not use Cocos Creator software for developing other software or tools that's
+ used for developing games. You are not granted to publish, distribute,
+ sublicense, and/or sell copies of Cocos Creator.
+
+ The software or tools in this License Agreement are licensed, not sold.
+ Chukong Aipu reserves all rights not expressly granted to you.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+ ****************************************************************************/
+
+cc.Audio = function (src) {
+ this.src = src;
+ this.volume = 1;
+ this.loop = false;
+
+ this.id = -1;
+ this._eventList = {};
+
+ this.type = cc.Audio.Type.NATIVE;
+};
+
+cc.Audio.Type = {
+ DOM: 'AUDIO',
+ WEBAUDIO: 'WEBAUDIO',
+ NATIVE: 'NATIVE',
+ UNKNOWN: 'UNKNOWN'
+};
+
+(function (proto, audioEngine) {
+
+ // Using the new audioEngine
+ cc.audioEngine = audioEngine;
+ audioEngine.play = audioEngine.play2d;
+
+ proto.State = audioEngine.AudioState;
+
+ proto.play = function () {
+ this.id = audioEngine.play2d(this.src, this.loop, this.volume);
+ };
+
+ proto.pause = function () {
+ audioEngine.pause(this.id);
+ };
+
+ proto.resume = function () {
+ audioEngine.resume(this.id);
+ };
+
+ proto.stop = function () {
+ audioEngine.stop(this.id);
+ };
+
+ proto.setLoop = function (loop) {
+ this.loop = loop;
+ audioEngine.setLoop(this.id, loop)
+ };
+
+ proto.getLoop = function () {
+ return audioEngine.getLoop(this.id)
+ };
+
+ proto.setVolume = function (volume) {
+ this.volume = volume;
+ return audioEngine.setVolume(this.id, volume)
+ };
+
+ proto.getVolume = function () {
+ return audioEngine.getVolume(this.id)
+ };
+
+ proto.setCurrentTime = function (time) {
+ audioEngine.setCurrentTime(this.id, time);
+ };
+
+ proto.getCurrentTime = function () {
+ return audioEngine.getCurrentTime(this.id)
+ };
+
+ proto.getDuration = function () {
+ return audioEngine.getDuration(this.id)
+ };
+
+ proto.getState = function () {
+ return audioEngine.getState(this.id)
+ };
+
+ proto.preload = function () {
+ this.emit('load');
+ };
+
+ proto.on = function (event, callback) {
+ var list = this._eventList[event];
+ if (!list) {
+ list = this._eventList[event] = [];
+ }
+ list.push(callback);
+ };
+ proto.once = function (event, callback) {
+ var onceCallback = function (elem) {
+ callback.call(this, elem);
+ this.off(event, onceCallback);
+ };
+ this.on(event, onceCallback);
+ };
+ proto.emit = function (event) {
+ var list = this._eventList[event];
+ if (!list) return;
+ for (var i=0; i