mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-02 00:22:43 +08:00
+18
-6
@@ -96,8 +96,6 @@ cc.DebugMode = Enum({
|
||||
* @module cc
|
||||
*/
|
||||
|
||||
var jsbLog = cc.log || console.log;
|
||||
|
||||
/**
|
||||
* !#en Init Debug setting.
|
||||
* !#zh 设置调试模式。
|
||||
@@ -259,7 +257,14 @@ cc._initDebugSetting = function (mode) {
|
||||
* @param {any} ...subst - JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
|
||||
*/
|
||||
if (CC_JSB) {
|
||||
cc.log = jsbLog;
|
||||
if (scriptEngineType === "JavaScriptCore") {
|
||||
// console.log has to use `console` as its context for iOS 8~9. Therefore, apply it.
|
||||
cc.log = function () {
|
||||
return console.log.apply(console, arguments);
|
||||
};
|
||||
} else {
|
||||
cc.log = console.log;
|
||||
}
|
||||
}
|
||||
else if (console.log.bind) {
|
||||
// use bind to avoid pollute call stacks
|
||||
@@ -283,9 +288,16 @@ cc._initDebugSetting = function (mode) {
|
||||
* @param {any} msg - A JavaScript string containing zero or more substitution strings.
|
||||
* @param {any} ...subst - JavaScript objects with which to replace substitution strings within msg. This gives you additional control over the format of the output.
|
||||
*/
|
||||
cc.info = CC_JSB ? jsbLog : function () {
|
||||
(console.info || console.log).apply(console, arguments);
|
||||
};
|
||||
if (CC_JSB) {
|
||||
cc.info = (scriptEngineType === "JavaScriptCore") ? function () {
|
||||
(console.info || console.log).apply(console, arguments);
|
||||
} : (console.info || console.log);
|
||||
} else {
|
||||
cc.info = function () {
|
||||
(console.info || console.log).apply(console, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
cc.warnID = genLogFunc(cc.warn, 'Warning');
|
||||
|
||||
+5
-3
@@ -241,9 +241,9 @@ if (CC_DEBUG) {
|
||||
"3116": "WebGLRenderingContext.CLAMP_TO_EDGE should be used in NPOT textures", //setTexParameters
|
||||
"3117": "Mimpap texture only works in POT textures", //generateMipmap
|
||||
//RectWidth: 3300
|
||||
"3300": "Rect width exceeds maximum margin: %s", //RectWidth
|
||||
"3300": "Rect width exceeds maximum margin: %s, max x: %s, texture width: %s", //RectWidth
|
||||
//RectHeight: 3400
|
||||
"3400": "Rect height exceeds maximum margin: %s", //RectHeight
|
||||
"3400": "Rect height exceeds maximum margin: %s, max y: %s, texture height: %s", //RectHeight
|
||||
//EventManager: 3500
|
||||
"3500": "0 priority is forbidden for fixed priority since it's used for scene graph based priority.", //addListener
|
||||
"3501": "Invalid listener type!", //removeListeners
|
||||
@@ -626,7 +626,9 @@ if (CC_DEBUG) {
|
||||
"8300": "Should only one camera exists, please check your project.", //cc.Camera.enabled
|
||||
"8301": "Camera does not support Canvas Mode.", //cc.Camera.enabled
|
||||
// AudioEngine: 8400
|
||||
"8400": "Wrong type arguments, 'filePath' must be a String." // cc.audioEngine.play
|
||||
"8400": "Wrong type arguments, 'filePath' must be a String.", // cc.audioEngine.play
|
||||
// ToggleGroup: 8500
|
||||
"8500": "The ToggleGroup.toggleItems api will be removed in v2.0, please obtain toggles in other ways. \uD83D\uDE30",
|
||||
};
|
||||
cc._LogInfos = logs;
|
||||
}
|
||||
|
||||
@@ -48,43 +48,6 @@ test('emit', function () {
|
||||
cb1.once('callback1 should be invoked by fire event');
|
||||
});
|
||||
|
||||
test('once', function () {
|
||||
var target = new cc.EventTarget();
|
||||
var fireEvent = new cc.Event('fire');
|
||||
var cb1 = new Callback();
|
||||
|
||||
// once
|
||||
target.once('fire', cb1.enable());
|
||||
target.dispatchEvent(fireEvent);
|
||||
cb1.once('should be invoked if registered by once')
|
||||
.disable('should only invoke once 1');
|
||||
target.dispatchEvent(fireEvent);
|
||||
|
||||
// once + on
|
||||
var cb2 = new Callback().enable();
|
||||
|
||||
target.once('fire', cb1.enable());
|
||||
target.on('fire', cb2);
|
||||
|
||||
target.dispatchEvent(fireEvent);
|
||||
cb1.once('should be invoked if registered by once and before other callback');
|
||||
cb2.once('should still be invoked if previous event was removed');
|
||||
|
||||
cb1.disable('should only invoke once 2');
|
||||
target.dispatchEvent(fireEvent);
|
||||
cb2.once('should not remove common event');
|
||||
|
||||
// on + once
|
||||
|
||||
target.once('fire', cb1.enable());
|
||||
target.dispatchEvent(fireEvent);
|
||||
cb2.once();
|
||||
cb1.once('should be invoked if registered by once and after other callback')
|
||||
.disable('should only invoke once 3');
|
||||
target.dispatchEvent(fireEvent);
|
||||
cb2.once();
|
||||
});
|
||||
|
||||
test('test useCapture in on/off', function () {
|
||||
var target = new cc.EventTarget();
|
||||
var event = new cc.Event('fire');
|
||||
|
||||
@@ -52,24 +52,13 @@ p.stopStatesExcept = function (state) {
|
||||
}
|
||||
};
|
||||
|
||||
p.on = function (type, callback, target, useCapture) {
|
||||
var array = this._anims.array;
|
||||
for (var i = 0; i < array.length; ++i) {
|
||||
array[i].on(type, callback, target, useCapture);
|
||||
}
|
||||
}
|
||||
|
||||
p.addAnimation = function (anim) {
|
||||
var index = this._anims.array.indexOf(anim);
|
||||
if (index === -1) {
|
||||
this._anims.push(anim);
|
||||
}
|
||||
|
||||
var listeners = this.animation._listeners;
|
||||
for (var i = 0, l = listeners.length; i < l; i++) {
|
||||
var listener = listeners[i];
|
||||
anim.on(listener[0], listener[1], listener[2], listener[3]);
|
||||
}
|
||||
anim._setListeners(this.animation);
|
||||
};
|
||||
|
||||
p.removeAnimation = function (anim) {
|
||||
|
||||
@@ -143,6 +143,12 @@ var proto = AnimationState.prototype;
|
||||
|
||||
cc.js.mixin(proto, cc.EventTarget.prototype);
|
||||
|
||||
proto._setListeners = function (target) {
|
||||
this._capturingListeners = target ? target._capturingListeners : null;
|
||||
this._bubblingListeners = target ? target._bubblingListeners : null;
|
||||
this._hasListenerCache = target ? target._hasListenerCache : null;
|
||||
};
|
||||
|
||||
proto.onPlay = function () {
|
||||
// replay
|
||||
this.setTime(0);
|
||||
|
||||
@@ -1018,8 +1018,7 @@ var Node = cc.Class({
|
||||
this._parent = null;
|
||||
}
|
||||
}
|
||||
else if (CC_TEST ? (/* make CC_JSB mockable*/ Function('return CC_JSB'))() : CC_JSB) {
|
||||
this._sgNode.release();
|
||||
else if (CC_JSB) {
|
||||
this._sgNode._entity = null;
|
||||
this._sgNode = null;
|
||||
}
|
||||
|
||||
@@ -183,6 +183,7 @@ cc.Asset = cc.Class({
|
||||
|
||||
/**
|
||||
* Set native file name for this asset.
|
||||
* @seealso nativeUrl
|
||||
*
|
||||
* @method _setRawAsset
|
||||
* @param {String} filename
|
||||
|
||||
@@ -94,10 +94,18 @@ var Prefab = cc.Class({
|
||||
},
|
||||
|
||||
_instantiate: function () {
|
||||
// instantiate node
|
||||
var node = this._doInstantiate();
|
||||
// initialize node
|
||||
this.data._instantiate(node);
|
||||
var node;
|
||||
if (cc.supportJit) {
|
||||
// instantiate node
|
||||
node = this._doInstantiate();
|
||||
// initialize node
|
||||
this.data._instantiate(node);
|
||||
}
|
||||
else {
|
||||
// instantiate node
|
||||
node = this.data._instantiate();
|
||||
}
|
||||
|
||||
// link prefab in editor
|
||||
if (CC_EDITOR || CC_TEST) {
|
||||
// This operation is not necessary, but some old prefab asset may not contain complete data.
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
var tempMat = new cc.math.Matrix4();
|
||||
|
||||
let CameraNode = _ccsg.Node.extend({
|
||||
ctor: function () {
|
||||
@@ -46,8 +47,10 @@ let CameraNode = _ccsg.Node.extend({
|
||||
cc.renderer._breakBatch();
|
||||
|
||||
cc.math.glMatrixMode(cc.math.KM_GL_PROJECTION);
|
||||
cc.current_stack.push();
|
||||
cc.current_stack.top.multiply(this._mat);
|
||||
|
||||
tempMat.assignFrom(cc.current_stack.top);
|
||||
tempMat.multiply(this._mat);
|
||||
cc.current_stack.push(tempMat);
|
||||
},
|
||||
|
||||
_onAfterVisit: function () {
|
||||
|
||||
@@ -38,6 +38,18 @@ var callUpdateInTryCatch = CC_EDITOR && callerFunctor('update', 'dt');
|
||||
var callLateUpdateInTryCatch = CC_EDITOR && callerFunctor('lateUpdate', 'dt');
|
||||
var callOnDisableInTryCatch = CC_EDITOR && callerFunctor('onDisable');
|
||||
|
||||
var supportJit = cc.supportJit;
|
||||
var callStart = supportJit ? 'c.start();c._objFlags|=' + IsStartCalled : function (c) {
|
||||
c.start();
|
||||
c._objFlags |= IsStartCalled;
|
||||
};
|
||||
var callUpdate = supportJit ? 'c.update(dt)' : function (c, dt) {
|
||||
c.update(dt);
|
||||
};
|
||||
var callLateUpdate = supportJit ? 'c.lateUpdate(dt)' : function (c, dt) {
|
||||
c.lateUpdate(dt);
|
||||
};
|
||||
|
||||
function sortedIndex (array, comp) {
|
||||
var order = comp.constructor._executionOrder;
|
||||
var id = comp.__instanceId;
|
||||
@@ -204,7 +216,7 @@ function enableInEditor (comp) {
|
||||
}
|
||||
|
||||
function createInvokeImpl (funcOrCode, useDt) {
|
||||
if (CC_EDITOR) {
|
||||
if (typeof funcOrCode === 'function') {
|
||||
if (useDt) {
|
||||
return function (iterator, dt) {
|
||||
var array = iterator.array;
|
||||
@@ -253,11 +265,11 @@ function createInvokeImpl (funcOrCode, useDt) {
|
||||
function ctor () {
|
||||
// invokers
|
||||
this.startInvoker = new OneOffInvoker(createInvokeImpl(
|
||||
CC_EDITOR ? callStartInTryCatch : 'c.start();c._objFlags|=' + IsStartCalled));
|
||||
CC_EDITOR ? callStartInTryCatch : callStart));
|
||||
this.updateInvoker = new ReusableInvoker(createInvokeImpl(
|
||||
CC_EDITOR ? callUpdateInTryCatch : 'c.update(dt)', true));
|
||||
CC_EDITOR ? callUpdateInTryCatch : callUpdate, true));
|
||||
this.lateUpdateInvoker = new ReusableInvoker(createInvokeImpl(
|
||||
CC_EDITOR ? callLateUpdateInTryCatch : 'c.lateUpdate(dt)', true));
|
||||
CC_EDITOR ? callLateUpdateInTryCatch : callLateUpdate, true));
|
||||
|
||||
// components deferred to next frame
|
||||
this.scheduleInNextFrame = [];
|
||||
|
||||
@@ -71,6 +71,8 @@ var Animation = cc.Class({
|
||||
},
|
||||
|
||||
ctor: function () {
|
||||
cc.EventTarget.call(this);
|
||||
|
||||
// The actual implement for Animation
|
||||
this._animator = null;
|
||||
|
||||
@@ -78,8 +80,6 @@ var Animation = cc.Class({
|
||||
this._didInit = false;
|
||||
|
||||
this._currentClip = null;
|
||||
|
||||
this._listeners = [];
|
||||
},
|
||||
|
||||
properties: {
|
||||
@@ -532,22 +532,15 @@ var Animation = cc.Class({
|
||||
*/
|
||||
on: function (type, callback, target, useCapture) {
|
||||
this._init();
|
||||
var listeners = this._listeners;
|
||||
|
||||
for (var i = 0, l = listeners.length; i < l; i++) {
|
||||
var listener = listeners[i];
|
||||
if (listener[0] === type &&
|
||||
listener[1] === callback &&
|
||||
listener[2] === target &&
|
||||
listener[3] === useCapture) {
|
||||
return;
|
||||
}
|
||||
var ret = cc.EventTarget.prototype.on.call(this, type, callback, target, useCapture);
|
||||
|
||||
var array = this._animator._anims.array;
|
||||
for (var i = 0; i < array.length; ++i) {
|
||||
array[i]._setListeners(this);
|
||||
}
|
||||
|
||||
this._animator.on(type, callback, target, useCapture);
|
||||
listeners.push([type, callback, target, useCapture]);
|
||||
|
||||
return callback;
|
||||
return ret;
|
||||
},
|
||||
|
||||
|
||||
@@ -571,23 +564,13 @@ var Animation = cc.Class({
|
||||
*/
|
||||
off: function (type, callback, target, useCapture) {
|
||||
this._init();
|
||||
var listeners = this._listeners;
|
||||
|
||||
cc.EventTarget.prototype.off.call(this, type, callback, target, useCapture);
|
||||
|
||||
var nameToState = this._nameToState;
|
||||
|
||||
for (var i = listeners.length - 1; i >= 0; i--) {
|
||||
var listener = listeners[i];
|
||||
if (listener[0] === type &&
|
||||
listener[1] === callback &&
|
||||
listener[2] === target &&
|
||||
listener[3] === useCapture) {
|
||||
|
||||
for (var name in nameToState) {
|
||||
var state = nameToState[name];
|
||||
state.off(type, callback, target, useCapture);
|
||||
}
|
||||
|
||||
listeners.splice(i, 1);
|
||||
}
|
||||
for (var name in nameToState) {
|
||||
var state = nameToState[name];
|
||||
state._setListeners(null);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -395,7 +395,7 @@ var EditBox = cc.Class({
|
||||
/**
|
||||
* !#en The event handler to be called when EditBox began to edit text.
|
||||
* !#zh 开始编辑文本输入框触发的事件回调。
|
||||
* @property {Component.EventHandler} editingDidBegan
|
||||
* @property {Component.EventHandler[]} editingDidBegan
|
||||
*/
|
||||
editingDidBegan: {
|
||||
default: [],
|
||||
@@ -405,7 +405,7 @@ var EditBox = cc.Class({
|
||||
/**
|
||||
* !#en The event handler to be called when EditBox text changes.
|
||||
* !#zh 编辑文本输入框时触发的事件回调。
|
||||
* @property {Component.EventHandler} textChanged
|
||||
* @property {Component.EventHandler[]} textChanged
|
||||
*/
|
||||
textChanged: {
|
||||
default: [],
|
||||
@@ -415,7 +415,7 @@ var EditBox = cc.Class({
|
||||
/**
|
||||
* !#en The event handler to be called when EditBox edit ends.
|
||||
* !#zh 结束编辑文本输入框时触发的事件回调。
|
||||
* @property {Component.EventHandler} editingDidEnded
|
||||
* @property {Component.EventHandler[]} editingDidEnded
|
||||
*/
|
||||
editingDidEnded: {
|
||||
default: [],
|
||||
@@ -425,7 +425,7 @@ var EditBox = cc.Class({
|
||||
/**
|
||||
* !#en The event handler to be called when return key is pressed. Windows is not supported.
|
||||
* !#zh 当用户按下回车按键时的事件回调,目前不支持 windows 平台
|
||||
* @property {Component.EventHandler} editingReturn
|
||||
* @property {Component.EventHandler[]} editingReturn
|
||||
*/
|
||||
editingReturn: {
|
||||
default: [],
|
||||
@@ -644,4 +644,5 @@ cc.EditBox = module.exports = EditBox;
|
||||
* // when you don't need editbox anymore
|
||||
* editbox.node.destroy();
|
||||
* @method destroy
|
||||
* @return {Boolean} whether it is the first time the destroy being called
|
||||
*/
|
||||
|
||||
@@ -225,7 +225,7 @@ cc.Slider = module.exports = Slider;
|
||||
* Note: This event is emitted from the node to which the component belongs.
|
||||
* !#zh
|
||||
* 注意:此事件是从该组件所属的 Node 上面派发出来的,需要用 node.on 来监听。
|
||||
* @event slider
|
||||
* @event slide
|
||||
* @param {Event.EventCustom} event
|
||||
* @param {Slider} event.detail - The slider component.
|
||||
*/
|
||||
|
||||
@@ -28,7 +28,7 @@ var Base = require('./CCRendererUnderSG');
|
||||
/**
|
||||
* !#en Enum for sprite type.
|
||||
* !#zh Sprite 类型
|
||||
* @enum Sprite.SpriteType
|
||||
* @enum Sprite.Type
|
||||
*/
|
||||
/**
|
||||
* !#en The simple type.
|
||||
|
||||
@@ -54,17 +54,6 @@ var ToggleGroup = cc.Class({
|
||||
tooltip: CC_DEV && 'i18n:COMPONENT.toggle_group.allowSwitchOff',
|
||||
default: false
|
||||
},
|
||||
|
||||
/**
|
||||
* !#en Read only property, return the toggle items array reference managed by toggleGroup.
|
||||
* !#zh 只读属性,返回 toggleGroup 管理的 toggle 数组引用
|
||||
* @property {Array} toggleItems
|
||||
*/
|
||||
toggleItems: {
|
||||
get: function (){
|
||||
return this._toggleItems;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
updateToggles: function (toggle) {
|
||||
@@ -126,4 +115,11 @@ var ToggleGroup = cc.Class({
|
||||
|
||||
});
|
||||
|
||||
var JS = require('../platform/js');
|
||||
|
||||
JS.get(ToggleGroup.prototype, 'toggleItems', function () {
|
||||
cc.warnID(8500);
|
||||
return this._toggleItems;
|
||||
});
|
||||
|
||||
cc.ToggleGroup = module.exports = ToggleGroup;
|
||||
|
||||
@@ -369,6 +369,21 @@ var VideoPlayer = cc.Class({
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* !#en if you don't need the VideoPlayer and it isn't in any running Scene, you should
|
||||
* call the destroy method on this component or the associated node explicitly.
|
||||
* Otherwise, the created DOM element won't be removed from web page.
|
||||
* !#zh
|
||||
* 如果你不再使用 VideoPlayer,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。
|
||||
* 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。
|
||||
* @example
|
||||
* videoplayer.node.parent = null; // or videoplayer.node.removeFromParent(false);
|
||||
* // when you don't need videoplayer anymore
|
||||
* videoplayer.node.destroy();
|
||||
* @method destroy
|
||||
* @return {Boolean} whether it is the first time the destroy being called
|
||||
*/
|
||||
});
|
||||
|
||||
cc.VideoPlayer = module.exports = VideoPlayer;
|
||||
@@ -443,17 +458,3 @@ cc.VideoPlayer = module.exports = VideoPlayer;
|
||||
* @param {Event.EventCustom} event
|
||||
* @param {VideoPlayer} event.detail - The VideoPlayer component.
|
||||
*/
|
||||
|
||||
/**
|
||||
* !#en if you don't need the VideoPlayer and it isn't in any running Scene, you should
|
||||
* call the destroy method on this component or the associated node explicitly.
|
||||
* Otherwise, the created DOM element won't be removed from web page.
|
||||
* !#zh
|
||||
* 如果你不再使用 VideoPlayer,并且组件未添加到场景中,那么你必须手动对组件或所在节点调用 destroy。
|
||||
* 这样才能移除网页上的 DOM 节点,避免 Web 平台内存泄露。
|
||||
* @example
|
||||
* videoplayer.node.parent = null; // or videoplayer.node.removeFromParent(false);
|
||||
* // when you don't need videoplayer anymore
|
||||
* videoplayer.node.destroy();
|
||||
* @method destroy
|
||||
*/
|
||||
|
||||
@@ -103,14 +103,14 @@ var WebView = cc.Class({
|
||||
EventType: EventType,
|
||||
},
|
||||
|
||||
onLoad: CC_JSB && function() {
|
||||
onLoad: CC_JSB && function () {
|
||||
if (cc.sys.os === cc.sys.OS_OSX || cc.sys.os === cc.sys.OS_WINDOWS) {
|
||||
this.enabled = false;
|
||||
}
|
||||
},
|
||||
|
||||
_createSgNode: function () {
|
||||
if(CC_JSB) {
|
||||
if (CC_JSB) {
|
||||
if (cc.sys.os === cc.sys.OS_OSX || cc.sys.os === cc.sys.OS_WINDOWS) {
|
||||
console.log('WebView is not supported on Mac and Windows!');
|
||||
return null;
|
||||
@@ -132,7 +132,8 @@ var WebView = cc.Class({
|
||||
if (CC_EDITOR && this._useOriginalSize) {
|
||||
this.node.setContentSize(sgNode.getContentSize());
|
||||
this._useOriginalSize = false;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
sgNode.setContentSize(this.node.getContentSize());
|
||||
}
|
||||
},
|
||||
@@ -175,11 +176,13 @@ var WebView = cc.Class({
|
||||
|
||||
/**
|
||||
* !#en
|
||||
* Set javascript interface scheme.
|
||||
* Note: only available on Android and iOS at the moment.
|
||||
* Set javascript interface scheme (see also setOnJSCallback). <br/>
|
||||
* Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.<br/>
|
||||
* Please refer to the official documentation for more details.
|
||||
* !#zh
|
||||
* 设置 javascript 接口方案。
|
||||
* 注意:目前只能在 Android 和 iOS 上使用。
|
||||
* 设置 JavaScript 接口方案(与 'setOnJSCallback' 配套使用)。<br/>
|
||||
* 注意:只支持 Android 和 iOS ,Web 端用法请前往官方文档查看。<br/>
|
||||
* 详情请参阅官方文档
|
||||
* @method setJavascriptInterfaceScheme
|
||||
* @param {String} scheme
|
||||
*/
|
||||
@@ -188,13 +191,17 @@ var WebView = cc.Class({
|
||||
this._sgNode.setJavascriptInterfaceScheme(scheme);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* !#en
|
||||
* This callback called when load URL that start with javascript interface scheme.
|
||||
* Note: only available on Android and iOS at the moment.
|
||||
* This callback called when load URL that start with javascript
|
||||
* interface scheme (see also setJavascriptInterfaceScheme). <br/>
|
||||
* Note: Supports only on the Android and iOS. For HTML5, please refer to the official documentation.<br/>
|
||||
* Please refer to the official documentation for more details.
|
||||
* !#zh
|
||||
* 当加载 URL 以 JavaScript 接口方案开始时调用这个回调函数。
|
||||
* 注意:目前只能在 Android 和 iOS 上使用。
|
||||
* 当加载 URL 以 JavaScript 接口方案开始时调用这个回调函数。<br/>
|
||||
* 注意:只支持 Android 和 iOS,Web 端用法请前往官方文档查看。
|
||||
* 详情请参阅官方文档
|
||||
* @method setOnJSCallback
|
||||
* @param {Function} callback
|
||||
*/
|
||||
@@ -202,7 +209,24 @@ var WebView = cc.Class({
|
||||
if (this._sgNode) {
|
||||
this._sgNode.setOnJSCallback(callback);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* !#en
|
||||
* Evaluates JavaScript in the context of the currently displayed page. <br/>
|
||||
* Please refer to the official document for more details <br/>
|
||||
* Note: Cross domain issues need to be resolved by yourself <br/>
|
||||
* !#zh
|
||||
* 执行 WebView 内部页面脚本(详情请参阅官方文档) <br/>
|
||||
* 注意:需要自行解决跨域问题
|
||||
* @method evaluateJS
|
||||
* @param {String} str
|
||||
*/
|
||||
evaluateJS: function (str) {
|
||||
if (this._sgNode) {
|
||||
this._sgNode.evaluateJS(str);
|
||||
}
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ var EventTarget = require('../event/event-target');
|
||||
/**
|
||||
* !#en The event type supported by SystemEvent
|
||||
* !#zh SystemEvent 支持的事件类型
|
||||
* @enum SystemEvent.EventType
|
||||
* @class SystemEvent.EventType
|
||||
* @static
|
||||
* @namespace SystemEvent
|
||||
*/
|
||||
|
||||
@@ -162,7 +162,7 @@ proto._addEventFlag = function (type, listeners, useCapture) {
|
||||
cache[type] |= flag;
|
||||
};
|
||||
|
||||
proto._removeEventFlag = function (type, listeners, useCapture) {
|
||||
proto._purgeEventFlag = function (type, listeners, useCapture) {
|
||||
var cache = this._hasListenerCache;
|
||||
|
||||
if (!cache || listeners.has(type)) {
|
||||
@@ -175,7 +175,7 @@ proto._removeEventFlag = function (type, listeners, useCapture) {
|
||||
if (cache[type] === 0) {
|
||||
delete cache[type];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
proto._resetFlagForTarget = function (target, listeners, useCapture) {
|
||||
var cache = this._hasListenerCache;
|
||||
@@ -206,13 +206,8 @@ proto.hasEventListener = function (type, checkCapture) {
|
||||
var cache = this._hasListenerCache;
|
||||
if (!cache) return false;
|
||||
|
||||
var flag = cache[type];
|
||||
if (checkCapture && (flag & CAPTURING_FLAG))
|
||||
return true;
|
||||
if (!checkCapture && (flag & BUBBLING_FLAG))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
var flag = checkCapture ? CAPTURING_FLAG : BUBBLING_FLAG;
|
||||
return (cache[type] & flag) > 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -322,7 +317,7 @@ proto.off = function (type, callback, target, useCapture) {
|
||||
fastRemove(target.__eventTargets, this);
|
||||
}
|
||||
|
||||
this._removeEventFlag(type, listeners, useCapture);
|
||||
this._purgeEventFlag(type, listeners, useCapture);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -376,12 +371,23 @@ proto.targetOff = function (target) {
|
||||
* }, node);
|
||||
*/
|
||||
proto.once = function (type, callback, target, useCapture) {
|
||||
var self = this;
|
||||
var cb = function (event) {
|
||||
self.off(type, cb, target, useCapture);
|
||||
callback.call(this, event);
|
||||
};
|
||||
this.on(type, cb, target, useCapture);
|
||||
var eventType_hasOnceListener = '__ONCE_FLAG:' + type;
|
||||
var listeners = useCapture ? this._capturingListeners : this._bubblingListeners;
|
||||
var hasOnceListener = listeners && listeners.has(eventType_hasOnceListener, callback, target);
|
||||
if (!hasOnceListener) {
|
||||
var self = this;
|
||||
var onceWrapper = function (event) {
|
||||
self.off(type, onceWrapper, target, useCapture);
|
||||
listeners.remove(eventType_hasOnceListener, callback, target);
|
||||
callback.call(this, event);
|
||||
};
|
||||
this.on(type, onceWrapper, target, useCapture);
|
||||
if (!listeners) {
|
||||
// obtain new created listeners
|
||||
listeners = useCapture ? this._capturingListeners : this._bubblingListeners;
|
||||
}
|
||||
listeners.add(eventType_hasOnceListener, callback, target);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
'use strict';
|
||||
|
||||
var GraphicsNode;
|
||||
if (!cc.sys.isNative) {
|
||||
if (!CC_JSB) {
|
||||
GraphicsNode = _ccsg.GraphicsNode = require('./graphics-node');
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -71,8 +71,7 @@ if (_IEFilter) {
|
||||
var byteMapping = {};
|
||||
for (var i = 0; i < 256; i++) {
|
||||
for (var j = 0; j < 256; j++) {
|
||||
byteMapping[ String.fromCharCode(i + j * 256) ] =
|
||||
String.fromCharCode(i) + String.fromCharCode(j);
|
||||
byteMapping[ String.fromCharCode(i + j * 256) ] = String.fromCharCode(i, j);
|
||||
}
|
||||
}
|
||||
var rawBytes = IEBinaryToArray_ByteStr(binary);
|
||||
|
||||
@@ -100,7 +100,7 @@ module.exports = {
|
||||
if (Array.isArray(packedJson)) {
|
||||
unpackerData.unpacker = new Unpackers.JsonUnpacker();
|
||||
}
|
||||
else if (packedJson.type === TextureUnpacker.ID) {
|
||||
else if (packedJson.type === Unpackers.TextureUnpacker.ID) {
|
||||
unpackerData.unpacker = new Unpackers.TextureUnpacker();
|
||||
}
|
||||
unpackerData.unpacker.load(packIndices[packUuid], packedJson);
|
||||
|
||||
@@ -43,6 +43,13 @@ var callResetInTryCatch = CC_EDITOR && callerFunctor('resetInEditor');
|
||||
var callOnFocusInTryCatch = CC_EDITOR && callerFunctor('onFocusInEditor');
|
||||
var callOnLostFocusInTryCatch = CC_EDITOR && callerFunctor('onLostFocusInEditor');
|
||||
|
||||
var supportJit = cc.supportJit;
|
||||
var callPreload = supportJit ? 'c.__preload();' : function (c) { c.__preload(); }
|
||||
var callOnLoad = supportJit ? ('c.onLoad();c._objFlags|=' + IsOnLoadCalled) : function (c) {
|
||||
c.onLoad();
|
||||
c._objFlags |= IsOnLoadCalled;
|
||||
}
|
||||
|
||||
// for __preload: use internally, no sort
|
||||
var UnsortedInvoker = cc.Class({
|
||||
extends: CompScheduler.LifeCycleInvoker,
|
||||
@@ -62,10 +69,10 @@ var UnsortedInvoker = cc.Class({
|
||||
});
|
||||
|
||||
var invokePreload = CompScheduler.createInvokeImpl(
|
||||
CC_EDITOR ? callPreloadInTryCatch : 'c.__preload();'
|
||||
CC_EDITOR ? callPreloadInTryCatch : callPreload
|
||||
);
|
||||
var invokeOnLoad = CompScheduler.createInvokeImpl(
|
||||
CC_EDITOR ? callOnLoadInTryCatch : ('c.onLoad();c._objFlags|=' + IsOnLoadCalled)
|
||||
CC_EDITOR ? callOnLoadInTryCatch : callOnLoad
|
||||
);
|
||||
|
||||
var activateTasksPool = new JS.Pool(MAX_POOL_SIZE);
|
||||
|
||||
@@ -396,33 +396,37 @@ function getNewValueTypeCode (value) {
|
||||
var clsName = JS.getClassName(value);
|
||||
var type = value.constructor;
|
||||
var res = 'new ' + clsName + '(';
|
||||
var i;
|
||||
if (type === cc.Mat3 || type === cc.Mat4) {
|
||||
var data = value.data;
|
||||
for (i = 0; i < data.length; i++) {
|
||||
res += data[i];
|
||||
if (i < data.length - 1) {
|
||||
res += ',';
|
||||
}
|
||||
for (var i = 0; i < type.__props__.length; i++) {
|
||||
var prop = type.__props__[i];
|
||||
var propVal = value[prop];
|
||||
if (typeof propVal === 'object') {
|
||||
cc.errorID(3641, clsName);
|
||||
return 'new ' + clsName + '()';
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (i = 0; i < type.__props__.length; i++) {
|
||||
var prop = type.__props__[i];
|
||||
var propVal = value[prop];
|
||||
if (typeof propVal === 'object') {
|
||||
cc.errorID(3641, clsName);
|
||||
return 'new ' + clsName + '()';
|
||||
}
|
||||
res += propVal;
|
||||
if (i < type.__props__.length - 1) {
|
||||
res += ',';
|
||||
}
|
||||
res += propVal;
|
||||
if (i < type.__props__.length - 1) {
|
||||
res += ',';
|
||||
}
|
||||
}
|
||||
return res + ')';
|
||||
}
|
||||
|
||||
function getNewValueType (value) {
|
||||
var clsName = JS.getClassName(value);
|
||||
var type = value.constructor;
|
||||
var res = new type();
|
||||
for (var i = 0; i < type.__props__.length; i++) {
|
||||
var prop = type.__props__[i];
|
||||
var propVal = value[prop];
|
||||
if (typeof propVal === 'object') {
|
||||
cc.errorID(3641, clsName);
|
||||
return res;
|
||||
}
|
||||
res[prop] = propVal;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
// TODO - move escapeForJS, IDENTIFIER_RE, getNewValueTypeCode to misc.js or a new source file
|
||||
|
||||
// convert a normal string including newlines, quotes and unicode characters into a string literal
|
||||
@@ -434,17 +438,7 @@ function escapeForJS (s) {
|
||||
replace(/\u2029/g, '\\u2029');
|
||||
}
|
||||
|
||||
// simple test variable name
|
||||
var IDENTIFIER_RE = /^[$A-Za-z_][0-9A-Za-z_$]*$/;
|
||||
function compileProps (actualClass) {
|
||||
// init deferred properties
|
||||
var attrs = Attr.getClassAttrs(actualClass);
|
||||
var propList = actualClass.__props__;
|
||||
if (propList === null) {
|
||||
deferredInitializer.init();
|
||||
propList = actualClass.__props__;
|
||||
}
|
||||
|
||||
function getInitPropsJit (attrs, propList) {
|
||||
// functions for generated code
|
||||
var F = [];
|
||||
var func = '';
|
||||
@@ -498,7 +492,6 @@ function compileProps (actualClass) {
|
||||
// console.log(func);
|
||||
// }
|
||||
|
||||
// Overwite __initProps__ to avoid compile again.
|
||||
var initProps;
|
||||
if (F.length === 0) {
|
||||
initProps = Function(func);
|
||||
@@ -506,14 +499,81 @@ function compileProps (actualClass) {
|
||||
else {
|
||||
initProps = Function('F', 'return (function(){\n' + func + '})')(F);
|
||||
}
|
||||
|
||||
return initProps;
|
||||
}
|
||||
|
||||
function getInitProps (attrs, propList) {
|
||||
// functions for generated code
|
||||
|
||||
function func () {
|
||||
var F = [];
|
||||
|
||||
for (var i = 0; i < propList.length; i++) {
|
||||
var prop = propList[i];
|
||||
var attrKey = prop + DELIMETER + 'default';
|
||||
if (attrKey in attrs) { // getter does not have default
|
||||
var expression;
|
||||
var def = attrs[attrKey];
|
||||
if (typeof def === 'object' && def) {
|
||||
if (def instanceof cc.ValueType) {
|
||||
expression = getNewValueType(def);
|
||||
}
|
||||
else if (Array.isArray(def)) {
|
||||
expression = [];
|
||||
}
|
||||
else {
|
||||
expression = {};
|
||||
}
|
||||
}
|
||||
else if (typeof def === 'function') {
|
||||
var index = F.length;
|
||||
F.push(def);
|
||||
expression = F[index]();
|
||||
if (CC_EDITOR) {
|
||||
try {
|
||||
this[prop] = expression;
|
||||
}
|
||||
catch(err) {
|
||||
cc._throw(e);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// number, boolean, null, undefined, string
|
||||
expression = def;
|
||||
}
|
||||
|
||||
this[prop] = expression;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return func;
|
||||
}
|
||||
|
||||
// simple test variable name
|
||||
var IDENTIFIER_RE = /^[$A-Za-z_][0-9A-Za-z_$]*$/;
|
||||
function compileProps (actualClass) {
|
||||
// init deferred properties
|
||||
var attrs = Attr.getClassAttrs(actualClass);
|
||||
var propList = actualClass.__props__;
|
||||
if (propList === null) {
|
||||
deferredInitializer.init();
|
||||
propList = actualClass.__props__;
|
||||
}
|
||||
|
||||
// Overwite __initProps__ to avoid compile again.
|
||||
var initProps = cc.supportJit ? getInitPropsJit(attrs, propList) : getInitProps(attrs, propList);
|
||||
actualClass.prototype.__initProps__ = initProps;
|
||||
|
||||
// call instantiateProps immediately, no need to pass actualClass into it anymore
|
||||
// (use call to manually bind `this` because `this` may not instanceof actualClass)
|
||||
initProps.call(this);
|
||||
}
|
||||
|
||||
function _createCtor (ctors, baseClass, className, options) {
|
||||
// bound super calls
|
||||
var _createCtor = cc.supportJit ? function (ctors, baseClass, className, options) {
|
||||
var superCallBounded = baseClass && boundSuperCalls(baseClass, options, className);
|
||||
|
||||
var ctorName = CC_DEV ? normalizeClassName_DEV(className) : 'CCClass';
|
||||
@@ -552,7 +612,49 @@ function _createCtor (ctors, baseClass, className, options) {
|
||||
body += '}';
|
||||
|
||||
return Function(body)();
|
||||
}
|
||||
} : function (ctors, baseClass, className, options) {
|
||||
var superCallBounded = baseClass && boundSuperCalls(baseClass, options, className);
|
||||
|
||||
return function CCClass () {
|
||||
if (superCallBounded) {
|
||||
this._super=null;
|
||||
}
|
||||
|
||||
this.__initProps__(CCClass);
|
||||
|
||||
// call user constructors
|
||||
var ctorLen = ctors.length;
|
||||
var cs = CCClass.__ctors__;
|
||||
if (ctorLen > 0) {
|
||||
var useTryCatch = ! (className && className.startsWith('cc.'));
|
||||
if (useTryCatch) {
|
||||
try {
|
||||
if (ctorLen === 1) {
|
||||
cs[0].apply(this, arguments);
|
||||
}
|
||||
else {
|
||||
for (var i = 0; i < ctorLen; i++) {
|
||||
cs[i].apply(this, arguments);;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(e) {
|
||||
cc._throw(e);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (ctorLen === 1) {
|
||||
cs[0].apply(this, arguments);
|
||||
}
|
||||
else {
|
||||
for (var i = 0; i < ctorLen; i++) {
|
||||
cs[i].apply(this, arguments);;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
function _validateCtor_DEV (ctor, baseClass, className, options) {
|
||||
if (CC_EDITOR && baseClass) {
|
||||
|
||||
@@ -555,4 +555,5 @@ var inputManager = {
|
||||
}
|
||||
};
|
||||
|
||||
cc.inputManager = inputManager;
|
||||
module.exports = inputManager;
|
||||
|
||||
@@ -340,25 +340,38 @@ function compileDestruct (obj, ctor) {
|
||||
}
|
||||
// compile code
|
||||
var skipId = obj instanceof cc._BaseNode || obj instanceof cc.Component;
|
||||
var func = '';
|
||||
for (key in propsToReset) {
|
||||
if (skipId && key === '_id') {
|
||||
continue;
|
||||
|
||||
if (cc.supportJit) {
|
||||
var func = '';
|
||||
for (key in propsToReset) {
|
||||
if (skipId && key === '_id') {
|
||||
continue;
|
||||
}
|
||||
var statement;
|
||||
if (CCClass.IDENTIFIER_RE.test(key)) {
|
||||
statement = 'o.' + key + '=';
|
||||
}
|
||||
else {
|
||||
statement = 'o[' + CCClass.escapeForJS(key) + ']=';
|
||||
}
|
||||
var val = propsToReset[key];
|
||||
if (val === '') {
|
||||
val = '""';
|
||||
}
|
||||
func += (statement + val + ';\n');
|
||||
}
|
||||
var statement;
|
||||
if (CCClass.IDENTIFIER_RE.test(key)) {
|
||||
statement = 'o.' + key + '=';
|
||||
}
|
||||
else {
|
||||
statement = 'o[' + CCClass.escapeForJS(key) + ']=';
|
||||
}
|
||||
var val = propsToReset[key];
|
||||
if (val === '') {
|
||||
val = '""';
|
||||
}
|
||||
func += (statement + val + ';\n');
|
||||
return Function('o', func);
|
||||
}
|
||||
else {
|
||||
return function (o) {
|
||||
for (key in propsToReset) {
|
||||
if (skipId && key === '_id') {
|
||||
continue;
|
||||
}
|
||||
o[key] = propsToReset[key];
|
||||
}
|
||||
};
|
||||
}
|
||||
return Function('o', func);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -589,7 +589,7 @@ else {
|
||||
/* Determine the browser type */
|
||||
(function(){
|
||||
var typeReg1 = /mqqbrowser|micromessenger|qq|sogou|qzone|liebao|maxthon|ucbrowser|360 aphone|360browser|baiduboxapp|baidubrowser|maxthon|mxbrowser|miuibrowser/i;
|
||||
var typeReg2 = /qqbrowser|chrome|safari|firefox|trident|opera|opr|oupeng/i;
|
||||
var typeReg2 = /qqbrowser|chrome|safari|firefox|trident|opera|opr\/|oupeng/i;
|
||||
var browserTypes = typeReg1.exec(ua);
|
||||
if(!browserTypes) browserTypes = typeReg2.exec(ua);
|
||||
var browserType = browserTypes ? browserTypes[0].toLowerCase() : sys.BROWSER_TYPE_UNKNOWN;
|
||||
@@ -598,14 +598,14 @@ else {
|
||||
else if (browserType === "safari" && isAndroid)
|
||||
browserType = sys.BROWSER_TYPE_ANDROID;
|
||||
else if (browserType === "qq" && ua.match(/android.*applewebkit/i))
|
||||
brwoserType = sys.BROWSER_TYPE_ANDROID;
|
||||
browserType = sys.BROWSER_TYPE_ANDROID;
|
||||
else if (browserType === "trident")
|
||||
browserType = sys.BROWSER_TYPE_IE;
|
||||
else if (browserType === "360 aphone")
|
||||
browserType = sys.BROWSER_TYPE_360;
|
||||
else if (browserType === "mxbrowser")
|
||||
browserType = sys.BROWSER_TYPE_MAXTHON;
|
||||
else if (browserType === "opr")
|
||||
else if (browserType === "opr/")
|
||||
browserType = sys.BROWSER_TYPE_OPERA;
|
||||
|
||||
sys.browserType = browserType;
|
||||
@@ -619,7 +619,7 @@ else {
|
||||
/* Determine the browser version number */
|
||||
(function(){
|
||||
var versionReg1 = /(mqqbrowser|micromessenger|qq|sogou|qzone|liebao|maxthon|uc|360 aphone|360|baiduboxapp|baidu|maxthon|mxbrowser|miui)(mobile)?(browser)?\/?([\d.]+)/i;
|
||||
var versionReg2 = /(qqbrowser|chrome|safari|firefox|trident|opera|opr|oupeng)(mobile)?(browser)?\/?([\d.]+)/i;
|
||||
var versionReg2 = /(qqbrowser|chrome|safari|firefox|trident|opera|opr\/|oupeng)(mobile)?(browser)?\/?([\d.]+)/i;
|
||||
var tmp = ua.match(versionReg1);
|
||||
if(!tmp) tmp = ua.match(versionReg2);
|
||||
sys.browserVersion = tmp ? tmp[4] : "";
|
||||
@@ -722,12 +722,6 @@ else {
|
||||
if (cc.create3DContext(document.createElement("CANVAS"))) {
|
||||
_supportWebGL = true;
|
||||
}
|
||||
if (_supportWebGL && sys.os === sys.OS_IOS && sys.osMainVersion === 9) {
|
||||
// Not activating WebGL in iOS 9 UIWebView because it may crash when entering background
|
||||
if (!win.indexedDB) {
|
||||
_supportWebGL = false;
|
||||
}
|
||||
}
|
||||
if (_supportWebGL && sys.os === sys.OS_ANDROID) {
|
||||
var browserVer = parseFloat(sys.browserVersion);
|
||||
switch (sys.browserType) {
|
||||
|
||||
@@ -69,7 +69,7 @@ Class.extend = function (props) {
|
||||
|
||||
// The dummy Class constructor
|
||||
var TheClass;
|
||||
if (cc.game && cc.game.config && cc.game.config[cc.game.CONFIG_KEY.exposeClassName]) {
|
||||
if (cc.supportJit && cc.game && cc.game.config && cc.game.config[cc.game.CONFIG_KEY.exposeClassName]) {
|
||||
var ctor =
|
||||
"return (function " + (props._className || "Class") + "(arg0,arg1,arg2,arg3,arg4) {\n" +
|
||||
"this.__instanceId = cc.ClassManager.getNewInstanceId();\n" +
|
||||
|
||||
@@ -30,7 +30,7 @@ const DELIMETER = '$_$';
|
||||
|
||||
function createAttrsSingle (owner, ownerCtor, superAttrs) {
|
||||
var AttrsCtor;
|
||||
if (CC_DEV) {
|
||||
if (CC_DEV && cc.supportJit) {
|
||||
var ctorName = ownerCtor.name;
|
||||
if (owner === ownerCtor) {
|
||||
ctorName += '_ATTRS';
|
||||
|
||||
@@ -486,7 +486,7 @@ var _Deserializer = (function () {
|
||||
// }
|
||||
// }
|
||||
|
||||
function compileObjectType (sources, defaultValue, accessorToSet, propNameLiteralToSet, assumeHavePropIfIsValue, stillUseUrl) {
|
||||
var compileObjectType = cc.supportJit ? function (sources, defaultValue, accessorToSet, propNameLiteralToSet, assumeHavePropIfIsValue, stillUseUrl) {
|
||||
if (defaultValue instanceof cc.ValueType) {
|
||||
// fast case
|
||||
if (!assumeHavePropIfIsValue) {
|
||||
@@ -508,9 +508,38 @@ var _Deserializer = (function () {
|
||||
}
|
||||
sources.push('}else o' + accessorToSet + '=null;');
|
||||
}
|
||||
}
|
||||
} : function (s, o, t, prop, defaultValue, propName, assumeHavePropIfIsValue, stillUseUrl) {
|
||||
if (defaultValue instanceof cc.ValueType) {
|
||||
var ctor = defaultValue.constructor;
|
||||
|
||||
function compileDeserialize (self, klass) {
|
||||
if (assumeHavePropIfIsValue) {
|
||||
s._deserializeTypedObject(o[propName], prop, ctor);
|
||||
}
|
||||
else {
|
||||
if (prop) {
|
||||
s._deserializeTypedObject(o[propName], prop, ctor);
|
||||
}
|
||||
else {
|
||||
o[propName] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (prop) {
|
||||
if (CC_EDITOR || CC_TEST) {
|
||||
s._deserializeObjField(o, prop, propName, t&&o, stillUseUrl);
|
||||
}
|
||||
else {
|
||||
s._deserializeObjField(o, prop, propName, null, stillUseUrl);
|
||||
}
|
||||
}
|
||||
else {
|
||||
o[propName] = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var compileDeserialize = cc.supportJit ? function (self, klass) {
|
||||
var EDITOR_ONLY = Attr.DELIMETER + 'editorOnly';
|
||||
var SERIALIZABLE = Attr.DELIMETER + 'serializable';
|
||||
var DEFAULT = Attr.DELIMETER + 'default';
|
||||
@@ -592,7 +621,72 @@ var _Deserializer = (function () {
|
||||
sources.push('s._deserializePrimitiveObject(o._$erialized,d);');
|
||||
}
|
||||
return Function('s', 'o', 'd', 'k', 't', sources.join(''));
|
||||
}
|
||||
} : function (self, klass) {
|
||||
var EDITOR_ONLY = Attr.DELIMETER + 'editorOnly';
|
||||
var SERIALIZABLE = Attr.DELIMETER + 'serializable';
|
||||
var DEFAULT = Attr.DELIMETER + 'default';
|
||||
var SAVE_URL_AS_ASSET = Attr.DELIMETER + 'saveUrlAsAsset';
|
||||
var FORMERLY_SERIALIZED_AS = Attr.DELIMETER + 'formerlySerializedAs';
|
||||
var attrs = Attr.getClassAttrs(klass);
|
||||
|
||||
var props = klass.__props__;
|
||||
var fastMode = Misc.BUILTIN_CLASSID_RE.test(JS._getClassId(klass));
|
||||
|
||||
return function (s, o, d, k, t) {
|
||||
var prop;
|
||||
for (var p = 0; p < props.length; p++) {
|
||||
var propName = props[p];
|
||||
if ((CC_PREVIEW || (CC_EDITOR && self._ignoreEditorOnly)) && attrs[propName + EDITOR_ONLY]) {
|
||||
var mayUsedInPersistRoot = (propName === '_id' && cc.isChildClassOf(klass, cc.Node));
|
||||
if (!mayUsedInPersistRoot) {
|
||||
continue; // skip editor only if in preview
|
||||
}
|
||||
}
|
||||
if (attrs[propName + SERIALIZABLE] === false) {
|
||||
continue; // skip nonSerialized
|
||||
}
|
||||
|
||||
var propNameToRead = propName;
|
||||
if (attrs[propName + FORMERLY_SERIALIZED_AS]) {
|
||||
propNameToRead = attrs[propName + FORMERLY_SERIALIZED_AS];
|
||||
}
|
||||
|
||||
prop = d[propNameToRead];
|
||||
|
||||
if (typeof prop !== 'undefined') {
|
||||
var stillUseUrl = attrs[propName + SAVE_URL_AS_ASSET];
|
||||
// function undefined object(null) string boolean number
|
||||
var defaultValue = CCClass.getDefault(attrs[propName + DEFAULT]);
|
||||
if (fastMode) {
|
||||
var defaultType = typeof defaultValue;
|
||||
var isPrimitiveType = (defaultType === 'string' && !stillUseUrl) ||
|
||||
defaultType === 'number' ||
|
||||
defaultType === 'boolean';
|
||||
if (isPrimitiveType) {
|
||||
o[propName] = prop;
|
||||
}
|
||||
else {
|
||||
compileObjectType(s, o, t, prop, defaultValue, propName, true, stillUseUrl);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (typeof prop !== 'object') {
|
||||
o[propName] = prop;
|
||||
}
|
||||
else {
|
||||
compileObjectType(s, o, t, prop, defaultValue, propName, false, stillUseUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (props[props.length - 1] === '_$erialized') {
|
||||
// deep copy original serialized data
|
||||
o._$erialized=JSON.parse(JSON.stringify(d));
|
||||
// parse the serialized data as primitive javascript object, so its __id__ will be dereferenced
|
||||
s._deserializePrimitiveObject(o._$erialized,d);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function unlinkUnusedPrefab (self, serialized, obj) {
|
||||
var uuid = serialized['asset'] && serialized['asset'].__uuid__;
|
||||
|
||||
@@ -85,8 +85,8 @@ var macro = cc.macro,
|
||||
*/
|
||||
var simpleQuadGenerator = {
|
||||
_rebuildQuads_base: function (sprite) {
|
||||
var spriteFrame = sprite._spriteFrame,
|
||||
contentSize = sprite._contentSize,
|
||||
var spriteFrame = sprite._spriteFrame,
|
||||
contentSize = sprite._contentSize,
|
||||
isTrimmedContentSize = sprite._isTrimmedContentSize;
|
||||
|
||||
//build vertices
|
||||
@@ -129,9 +129,9 @@ var simpleQuadGenerator = {
|
||||
if (webgl) {
|
||||
var wt = sprite._renderCmd._worldTransform;
|
||||
var wta = wt.a, wtb = wt.b, wtc = wt.c, wtd = wt.d, wtx = wt.tx, wty = wt.ty;
|
||||
|
||||
|
||||
var la = l * wta, lb = l * wtb, ra = r * wta, rb = r * wtb,
|
||||
tcx = t * wtc + wtx, tdy = t * wtd + wty,
|
||||
tcx = t * wtc + wtx, tdy = t * wtd + wty,
|
||||
bcx = b * wtc + wtx, bdy = b * wtd + wty;
|
||||
vertices[0] = la + bcx;
|
||||
vertices[1] = lb + bdy;
|
||||
@@ -209,11 +209,11 @@ var scale9QuadGenerator = {
|
||||
x: new Array(4),
|
||||
y: new Array(4),
|
||||
_rebuildQuads_base: function (sprite) {
|
||||
var spriteFrame = sprite._spriteFrame,
|
||||
contentSize = sprite._contentSize,
|
||||
insetLeft = sprite._insetLeft,
|
||||
insetRight = sprite._insetRight,
|
||||
insetTop = sprite._insetTop,
|
||||
var spriteFrame = sprite._spriteFrame,
|
||||
contentSize = sprite._contentSize,
|
||||
insetLeft = sprite._insetLeft,
|
||||
insetRight = sprite._insetRight,
|
||||
insetTop = sprite._insetTop,
|
||||
insetBottom = sprite._insetBottom;
|
||||
|
||||
//build vertices
|
||||
@@ -358,7 +358,7 @@ var scale9QuadGenerator = {
|
||||
var tiledQuadGenerator = {
|
||||
_rebuildQuads_base: function (sprite, spriteFrame, contentSize) {
|
||||
|
||||
var spriteFrame = sprite._spriteFrame,
|
||||
var spriteFrame = sprite._spriteFrame,
|
||||
contentSize = sprite._contentSize,
|
||||
vertices = sprite._vertices,
|
||||
corner = sprite._corner,
|
||||
@@ -477,15 +477,15 @@ var fillQuadGeneratorBar = {
|
||||
_rebuildQuads_base : function (sprite) {
|
||||
var spriteFrame = sprite._spriteFrame,
|
||||
contentSize = sprite._contentSize;
|
||||
|
||||
|
||||
var fillStart = sprite._fillStart;
|
||||
var fillRange = sprite._fillRange;
|
||||
|
||||
|
||||
if (fillRange < 0) {
|
||||
fillStart += fillRange;
|
||||
fillRange = -fillRange;
|
||||
}
|
||||
|
||||
|
||||
fillRange = fillStart + fillRange;
|
||||
fillStart = fillStart > 1.0 ? 1.0 : fillStart;
|
||||
fillStart = fillStart < 0.0 ? 0.0 : fillStart;
|
||||
@@ -645,14 +645,14 @@ var fillQuadGeneratorRadial = {
|
||||
_rebuildQuads_base : function (sprite) {
|
||||
var spriteFrame = sprite._spriteFrame,
|
||||
contentSize = sprite._contentSize;
|
||||
|
||||
|
||||
var fillStart = sprite._fillStart;
|
||||
var fillRange = sprite._fillRange;
|
||||
if (fillRange < 0) {
|
||||
fillStart += fillRange;
|
||||
fillRange = -fillRange;
|
||||
}
|
||||
|
||||
|
||||
sprite._isTriangle = true;
|
||||
if (!sprite._rawVerts) {
|
||||
sprite._rawVerts = dataPool.get(8) || new Float32Array(8);
|
||||
@@ -813,10 +813,29 @@ var fillQuadGeneratorRadial = {
|
||||
}
|
||||
sprite._vertCount = count;
|
||||
|
||||
corner[0] = 0; // bl
|
||||
corner[1] = 2; // br
|
||||
corner[2] = 4; // tl
|
||||
corner[3] = 6; // tr
|
||||
var minx = Infinity, miny = Infinity, maxx = -Infinity, maxy = -Infinity;
|
||||
var x, y;
|
||||
for (var i = 0, l = offset; i < l; i+=2) {
|
||||
x = vertices[i];
|
||||
y = vertices[i+1];
|
||||
if (x <= minx) {
|
||||
minx = x;
|
||||
corner[0] = i;
|
||||
}
|
||||
else if (x >= maxx) {
|
||||
maxx = x;
|
||||
corner[1] = i;
|
||||
}
|
||||
|
||||
if (y <= miny) {
|
||||
miny = y;
|
||||
corner[2] = i;
|
||||
}
|
||||
else if (y >= maxy) {
|
||||
maxy = y;
|
||||
corner[3] = i;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_generateTriangle: function(wt, offset, vert0, vert1, vert2) {
|
||||
@@ -1000,7 +1019,8 @@ var meshQuadGenerator = {
|
||||
return;
|
||||
}
|
||||
|
||||
var polygonInfo = sprite._meshPolygonInfo;
|
||||
var
|
||||
polygonInfo = sprite._meshPolygonInfo;
|
||||
|
||||
if (!polygonInfo) {
|
||||
return;
|
||||
@@ -1416,7 +1436,7 @@ cc.Scale9Sprite = _ccsg.Node.extend({
|
||||
quadGenerator = tiledQuadGenerator;
|
||||
break;
|
||||
case RenderingType.FILLED:
|
||||
if (this._fillType === FillType.RADIAL) {
|
||||
if (this._fillType === FillType.RADIAL) {
|
||||
quadGenerator = fillQuadGeneratorRadial;
|
||||
}
|
||||
else {
|
||||
@@ -1427,7 +1447,7 @@ cc.Scale9Sprite = _ccsg.Node.extend({
|
||||
quadGenerator = meshQuadGenerator;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (quadGenerator) {
|
||||
quadGenerator._rebuildQuads_base(this);
|
||||
}
|
||||
@@ -1436,6 +1456,48 @@ cc.Scale9Sprite = _ccsg.Node.extend({
|
||||
this._uvsDirty = false;
|
||||
this._renderCmd._needDraw = false;
|
||||
cc.errorID(2627);
|
||||
return;
|
||||
}
|
||||
|
||||
var rect = cc.visibleRect;
|
||||
if (webgl && this._renderCmd._cameraFlag > 0) {
|
||||
rect = cc.Camera.main.visibleRect;
|
||||
}
|
||||
|
||||
vl = rect.left.x;
|
||||
vr = rect.right.x;
|
||||
vt = rect.top.y;
|
||||
vb = rect.bottom.y;
|
||||
|
||||
// Culling
|
||||
if (webgl) {
|
||||
// x1, y1 leftBottom
|
||||
// x2, y2 rightBottom
|
||||
// x3, y3 leftTop
|
||||
// x4, y4 rightTop
|
||||
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) & (x1-vl) & (x2-vl) & (x3-vl)) >> 31 || // All outside left
|
||||
((vr-x0) & (vr-x1) & (vr-x2) & (vr-x3)) >> 31 || // All outside right
|
||||
((y0-vb) & (y1-vb) & (y2-vb) & (y3-vb)) >> 31 || // All outside bottom
|
||||
((vt-y0) & (vt-y1) & (vt-y2) & (vt-y3)) >> 31) // All outside top
|
||||
{
|
||||
this._renderCmd._needDraw = false;
|
||||
}
|
||||
else {
|
||||
this._renderCmd._needDraw = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
var bb = this._renderCmd._currentRegion,
|
||||
l = bb._minX, r = bb._maxX, b = bb._minY, t = bb._maxY;
|
||||
if (r < vl || l > vr || t < vb || b > vt) {
|
||||
this._renderCmd._needDraw = false;
|
||||
}
|
||||
else {
|
||||
this._renderCmd._needDraw = true;
|
||||
}
|
||||
}
|
||||
|
||||
this._quadsDirty = false;
|
||||
|
||||
@@ -452,11 +452,11 @@ var SpriteFrame = cc.Class(/** @lends cc.SpriteFrame# */{
|
||||
maxX += rect.width;
|
||||
maxY += rect.height;
|
||||
}
|
||||
if (maxX > texture.getPixelWidth()) {
|
||||
cc.errorID(3300, texture.url + '/' + this.name);
|
||||
if (maxX > texture.width) {
|
||||
cc.errorID(3300, texture.url + '/' + this.name, maxX, texture.width);
|
||||
}
|
||||
if (maxY > texture.getPixelHeight()) {
|
||||
cc.errorID(3400, texture.url + '/' + this.name);
|
||||
if (maxY > texture.height) {
|
||||
cc.errorID(3400, texture.url + '/' + this.name, maxY, texture.height);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -494,7 +494,7 @@ var Texture2D = cc.Class({
|
||||
*/
|
||||
destroy () {
|
||||
this._releaseTexture();
|
||||
cc.textureCache.removeTextureForKey(this.url);
|
||||
cc.textureCache.removeTextureForKey(this.url); // item.rawUrl || item.url
|
||||
this._super();
|
||||
},
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ misc.imagePool.get = function () {
|
||||
};
|
||||
misc.imagePool._smallImg = "data:image/gif;base64,R0lGODlhAQABAAAAACwAAAAAAQABAAA=";
|
||||
// Avoid problems on windows IE kernels, Edge, Firefox and Linux Firefox
|
||||
if ((sys.os === sys.OS_WINDOWS || sys.os === sys.OS_LINUX) && sys.browser !== sys.BROWSER_TYPE_CHROME) {
|
||||
if ((sys.os === sys.OS_WINDOWS || sys.os === sys.OS_LINUX) && sys.browserType !== sys.BROWSER_TYPE_CHROME) {
|
||||
misc.imagePool.resize(0);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,15 +27,23 @@
|
||||
|
||||
var SceneGraphUtils = {
|
||||
removeSgNode: function () {
|
||||
var node = this._sgNode;
|
||||
if (node) {
|
||||
var parent = node._parent;
|
||||
var sgNode = this._sgNode;
|
||||
if (sgNode) {
|
||||
var parent = sgNode._parent;
|
||||
if (parent) {
|
||||
parent.removeChild(node);
|
||||
parent.removeChild(sgNode);
|
||||
}
|
||||
node.release();
|
||||
if (this._sgNode._entity) {
|
||||
this._sgNode._entity = null;
|
||||
else {
|
||||
// cleanup was skipped when its node was detaching
|
||||
if (CC_JSB) {
|
||||
sgNode.cleanup();
|
||||
}
|
||||
else {
|
||||
sgNode.performRecursive(_ccsg.Node.performType.cleanup);
|
||||
}
|
||||
}
|
||||
if (sgNode._entity) {
|
||||
sgNode._entity = null;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -34,15 +34,15 @@ _ccsg.WebView = _ccsg.Node.extend(/** @lends _ccsg.WebView# */{
|
||||
}
|
||||
},
|
||||
|
||||
setOnJSCallback: function(callback){},
|
||||
setJavascriptInterfaceScheme: function(scheme){},
|
||||
loadData: function(data, MIMEType, encoding, baseURL){},
|
||||
loadHTMLString: function(string, baseURL){},
|
||||
setOnJSCallback: function (callback) {},
|
||||
setJavascriptInterfaceScheme: function (scheme) {},
|
||||
loadData: function (data, MIMEType, encoding, baseURL) {},
|
||||
loadHTMLString: function (string, baseURL) {},
|
||||
/**
|
||||
* Load an URL
|
||||
* @param {String} url
|
||||
*/
|
||||
loadURL: function(url){
|
||||
loadURL: function (url) {
|
||||
this._renderCmd.updateURL(url);
|
||||
this._dispatchEvent(_ccsg.WebView.EventType.LOADING);
|
||||
},
|
||||
@@ -50,18 +50,18 @@ _ccsg.WebView = _ccsg.Node.extend(/** @lends _ccsg.WebView# */{
|
||||
/**
|
||||
* Stop loading
|
||||
*/
|
||||
stopLoading: function(){
|
||||
stopLoading: function () {
|
||||
cc.logID(7800);
|
||||
},
|
||||
|
||||
/**
|
||||
* Reload the WebView
|
||||
*/
|
||||
reload: function(){
|
||||
reload: function () {
|
||||
var iframe = this._renderCmd._iframe;
|
||||
if(iframe){
|
||||
if (iframe) {
|
||||
var win = iframe.contentWindow;
|
||||
if(win && win.location)
|
||||
if (win && win.location)
|
||||
win.location.reload();
|
||||
}
|
||||
},
|
||||
@@ -69,7 +69,7 @@ _ccsg.WebView = _ccsg.Node.extend(/** @lends _ccsg.WebView# */{
|
||||
/**
|
||||
* Determine whether to go back
|
||||
*/
|
||||
canGoBack: function(){
|
||||
canGoBack: function () {
|
||||
cc.logID(7801);
|
||||
return true;
|
||||
},
|
||||
@@ -77,7 +77,7 @@ _ccsg.WebView = _ccsg.Node.extend(/** @lends _ccsg.WebView# */{
|
||||
/**
|
||||
* Determine whether to go forward
|
||||
*/
|
||||
canGoForward: function(){
|
||||
canGoForward: function () {
|
||||
cc.logID(7802);
|
||||
return true;
|
||||
},
|
||||
@@ -85,17 +85,17 @@ _ccsg.WebView = _ccsg.Node.extend(/** @lends _ccsg.WebView# */{
|
||||
/**
|
||||
* go back
|
||||
*/
|
||||
goBack: function(){
|
||||
try{
|
||||
if(_ccsg.WebView._polyfill.closeHistory)
|
||||
goBack: function () {
|
||||
try {
|
||||
if (_ccsg.WebView._polyfill.closeHistory)
|
||||
return cc.logID(7803);
|
||||
var iframe = this._renderCmd._iframe;
|
||||
if(iframe){
|
||||
if (iframe) {
|
||||
var win = iframe.contentWindow;
|
||||
if(win && win.location)
|
||||
if (win && win.location)
|
||||
win.history.back.call(win);
|
||||
}
|
||||
}catch(err){
|
||||
} catch (err) {
|
||||
cc.log(err);
|
||||
}
|
||||
},
|
||||
@@ -103,17 +103,17 @@ _ccsg.WebView = _ccsg.Node.extend(/** @lends _ccsg.WebView# */{
|
||||
/**
|
||||
* go forward
|
||||
*/
|
||||
goForward: function(){
|
||||
try{
|
||||
if(_ccsg.WebView._polyfill.closeHistory)
|
||||
goForward: function () {
|
||||
try {
|
||||
if (_ccsg.WebView._polyfill.closeHistory)
|
||||
return cc.logID(7804);
|
||||
var iframe = this._renderCmd._iframe;
|
||||
if(iframe){
|
||||
if (iframe) {
|
||||
var win = iframe.contentWindow;
|
||||
if(win && win.location)
|
||||
if (win && win.location)
|
||||
win.history.forward.call(win);
|
||||
}
|
||||
}catch(err){
|
||||
} catch (err) {
|
||||
cc.log(err);
|
||||
}
|
||||
},
|
||||
@@ -122,14 +122,14 @@ _ccsg.WebView = _ccsg.Node.extend(/** @lends _ccsg.WebView# */{
|
||||
* In the webview execution within a period of js string
|
||||
* @param {String} str
|
||||
*/
|
||||
evaluateJS: function(str){
|
||||
evaluateJS: function (str) {
|
||||
var iframe = this._renderCmd._iframe;
|
||||
if(iframe){
|
||||
if (iframe) {
|
||||
var win = iframe.contentWindow;
|
||||
try{
|
||||
try {
|
||||
win.eval(str);
|
||||
this._dispatchEvent(_ccsg.WebView.EventType.JS_EVALUATED);
|
||||
}catch(err){
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
@@ -138,7 +138,7 @@ _ccsg.WebView = _ccsg.Node.extend(/** @lends _ccsg.WebView# */{
|
||||
/**
|
||||
* Limited scale
|
||||
*/
|
||||
setScalesPageToFit: function(){
|
||||
setScalesPageToFit: function () {
|
||||
cc.logID(7805);
|
||||
},
|
||||
|
||||
@@ -147,7 +147,7 @@ _ccsg.WebView = _ccsg.Node.extend(/** @lends _ccsg.WebView# */{
|
||||
* @param {_ccsg.WebView.EventType} event
|
||||
* @param {Function} callback
|
||||
*/
|
||||
setEventListener: function(event, callback){
|
||||
setEventListener: function (event, callback) {
|
||||
this._EventList[event] = callback;
|
||||
},
|
||||
|
||||
@@ -155,17 +155,17 @@ _ccsg.WebView = _ccsg.Node.extend(/** @lends _ccsg.WebView# */{
|
||||
* Delete events
|
||||
* @param {_ccsg.WebView.EventType} event
|
||||
*/
|
||||
removeEventListener: function(event){
|
||||
removeEventListener: function (event) {
|
||||
this._EventList[event] = null;
|
||||
},
|
||||
|
||||
_dispatchEvent: function(event) {
|
||||
_dispatchEvent: function (event) {
|
||||
var callback = this._EventList[event];
|
||||
if (callback)
|
||||
callback.call(this, this, this._renderCmd._iframe.src);
|
||||
},
|
||||
|
||||
_createRenderCmd: function(){
|
||||
_createRenderCmd: function () {
|
||||
return new _ccsg.WebView.RenderCmd(this);
|
||||
},
|
||||
|
||||
@@ -174,7 +174,7 @@ _ccsg.WebView = _ccsg.Node.extend(/** @lends _ccsg.WebView# */{
|
||||
* @param {Number} width
|
||||
* @param {Number} height
|
||||
*/
|
||||
setContentSize: function(width, height){
|
||||
setContentSize: function (width, height) {
|
||||
if (width.width !== undefined && width.height !== undefined) {
|
||||
height = width.height;
|
||||
width = width.width;
|
||||
@@ -188,7 +188,7 @@ _ccsg.WebView = _ccsg.Node.extend(/** @lends _ccsg.WebView# */{
|
||||
this._renderCmd.removeDom();
|
||||
},
|
||||
|
||||
setVisible: function ( visible ) {
|
||||
setVisible: function (visible) {
|
||||
_ccsg.Node.prototype.setVisible.call(this, visible);
|
||||
this._renderCmd.updateVisibility();
|
||||
}
|
||||
@@ -201,22 +201,23 @@ _ccsg.WebView.EventType = {
|
||||
JS_EVALUATED: 3
|
||||
};
|
||||
|
||||
(function(){
|
||||
(function() {
|
||||
|
||||
var polyfill = _ccsg.WebView._polyfill = {
|
||||
devicePixelRatio: false,
|
||||
enableDiv: false
|
||||
};
|
||||
|
||||
if(cc.sys.os === cc.sys.OS_IOS)
|
||||
if (cc.sys.os === cc.sys.OS_IOS)
|
||||
polyfill.enableDiv = true;
|
||||
|
||||
if(cc.sys.isMobile){
|
||||
if(cc.sys.browserType === cc.sys.BROWSER_TYPE_FIREFOX){
|
||||
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){
|
||||
}
|
||||
else {
|
||||
if (cc.sys.browserType === cc.sys.BROWSER_TYPE_IE) {
|
||||
polyfill.closeHistory = true;
|
||||
}
|
||||
}
|
||||
@@ -224,16 +225,17 @@ _ccsg.WebView.EventType = {
|
||||
|
||||
})();
|
||||
|
||||
(function(polyfill){
|
||||
(function(polyfill) {
|
||||
|
||||
var RenderCmd;
|
||||
if (cc._renderType === cc.game.RENDER_TYPE_CANVAS) {
|
||||
RenderCmd = _ccsg.Node.CanvasRenderCmd;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
RenderCmd = _ccsg.Node.WebGLRenderCmd;
|
||||
}
|
||||
|
||||
_ccsg.WebView.RenderCmd = function(node){
|
||||
_ccsg.WebView.RenderCmd = function (node) {
|
||||
this._rootCtor(node);
|
||||
|
||||
this._parent = null;
|
||||
@@ -250,10 +252,10 @@ _ccsg.WebView.EventType = {
|
||||
this.updateMatrix();
|
||||
};
|
||||
|
||||
proto.updateStatus = function(){
|
||||
proto.updateStatus = function () {
|
||||
polyfill.devicePixelRatio = cc.view.isRetinaEnabled();
|
||||
var flags = _ccsg.Node._dirtyFlags, locFlag = this._dirtyFlag;
|
||||
if(locFlag & flags.transformDirty){
|
||||
if (locFlag & flags.transformDirty) {
|
||||
//update the transform
|
||||
this.transform(this.getParentRenderCmd(), true);
|
||||
this.updateMatrix();
|
||||
@@ -263,28 +265,28 @@ _ccsg.WebView.EventType = {
|
||||
|
||||
proto.initEvent = function () {
|
||||
var node = this._node;
|
||||
this._iframe.addEventListener("load", function(){
|
||||
this._iframe.addEventListener("load", function () {
|
||||
node._dispatchEvent(_ccsg.WebView.EventType.LOADED);
|
||||
});
|
||||
this._iframe.addEventListener("error", function(){
|
||||
this._iframe.addEventListener("error", function () {
|
||||
node._dispatchEvent(_ccsg.WebView.EventType.ERROR);
|
||||
});
|
||||
};
|
||||
|
||||
proto.resize = function(view){
|
||||
proto.resize = function (view) {
|
||||
view = view || cc.view;
|
||||
var node = this._node,
|
||||
eventManager = cc.eventManager;
|
||||
if(node._parent && node._visible)
|
||||
if (node._parent && node._visible)
|
||||
this.updateMatrix();
|
||||
else{
|
||||
else {
|
||||
var list = eventManager._listenersMap[cc.game.EVENT_RESIZE].getFixedPriorityListeners();
|
||||
eventManager._removeListenerInVector(list, this._listener);
|
||||
this._listener = null;
|
||||
}
|
||||
};
|
||||
|
||||
proto.updateMatrix = function(){
|
||||
proto.updateMatrix = function () {
|
||||
if (!this._div) return;
|
||||
|
||||
var node = this._node, scaleX = cc.view._scaleX, scaleY = cc.view._scaleY;
|
||||
@@ -297,7 +299,7 @@ _ccsg.WebView.EventType = {
|
||||
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 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;
|
||||
|
||||
@@ -308,19 +310,19 @@ _ccsg.WebView.EventType = {
|
||||
this._div.style['-webkit-transform-origin'] = '0px 100% 0px';
|
||||
};
|
||||
|
||||
proto.initStyle = function(){
|
||||
if(!this._div) return;
|
||||
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){
|
||||
proto.updateURL = function (url) {
|
||||
var iframe = this._iframe;
|
||||
iframe.src = url;
|
||||
var self = this;
|
||||
var cb = function(){
|
||||
var cb = function () {
|
||||
self._loaded = true;
|
||||
self.updateVisibility();
|
||||
iframe.removeEventListener("load", cb);
|
||||
@@ -328,16 +330,16 @@ _ccsg.WebView.EventType = {
|
||||
iframe.addEventListener("load", cb);
|
||||
};
|
||||
|
||||
proto.updateSize = function(w, h){
|
||||
proto.updateSize = function (w, h) {
|
||||
var div = this._div;
|
||||
if(div){
|
||||
div.style["width"] = w+"px";
|
||||
div.style["height"] = h+"px";
|
||||
if (div) {
|
||||
div.style["width"] = w + "px";
|
||||
div.style["height"] = h + "px";
|
||||
}
|
||||
};
|
||||
|
||||
proto.createDom = function () {
|
||||
if(polyfill.enableDiv){
|
||||
if (polyfill.enableDiv) {
|
||||
this._div = document.createElement("div");
|
||||
this._div.style["-webkit-overflow"] = "auto";
|
||||
this._div.style["-webkit-overflow-scrolling"] = "touch";
|
||||
@@ -345,11 +347,12 @@ _ccsg.WebView.EventType = {
|
||||
this._div.appendChild(this._iframe);
|
||||
this._iframe.style.width = "100%";
|
||||
this._iframe.style.height = "100%";
|
||||
}else{
|
||||
}
|
||||
else {
|
||||
this._div = this._iframe = document.createElement("iframe");
|
||||
}
|
||||
|
||||
if(polyfill.enableBG)
|
||||
if (polyfill.enableBG)
|
||||
this._div.style["background"] = "#FFF";
|
||||
|
||||
this._div.style["background"] = "#FFF";
|
||||
@@ -368,11 +371,11 @@ _ccsg.WebView.EventType = {
|
||||
this.initEvent();
|
||||
};
|
||||
|
||||
proto.removeDom = function(){
|
||||
proto.removeDom = function () {
|
||||
var div = this._div;
|
||||
if(div){
|
||||
if (div) {
|
||||
var hasChild = Utils.contains(cc.game.container, div);
|
||||
if(hasChild)
|
||||
if (hasChild)
|
||||
cc.game.container.removeChild(div);
|
||||
}
|
||||
this._div = null;
|
||||
@@ -384,7 +387,8 @@ _ccsg.WebView.EventType = {
|
||||
var div = this._div;
|
||||
if (node.visible) {
|
||||
div.style.visibility = 'visible';
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
div.style.visibility = 'hidden';
|
||||
}
|
||||
};
|
||||
|
||||
@@ -605,6 +605,13 @@ if (CC_DEV) {
|
||||
});
|
||||
}
|
||||
|
||||
cc.js.get(cc.Texture2D.prototype, 'getName', function () {
|
||||
cc.warnID(1400, 'texture.getName()', 'texture._glID');
|
||||
return function () {
|
||||
return this._glID || null;
|
||||
};
|
||||
});
|
||||
|
||||
//ui
|
||||
if (cc.Layout) {
|
||||
js.obsolete(cc.Layout, 'cc.Layout.ResizeType', 'ResizeMode');
|
||||
|
||||
+70
-6
@@ -41,6 +41,62 @@ const Chalk = require('chalk');
|
||||
const HandleErrors = require('../util/handleErrors');
|
||||
const Optimizejs = require('gulp-optimize-js');
|
||||
|
||||
var jsbSkipModules = [
|
||||
'../../cocos2d/core/CCGame',
|
||||
'../../cocos2d/core/CCDrawingPrimitives.js',
|
||||
// '../../cocos2d/core/textures/CCTexture2D',
|
||||
// '../../cocos2d/core/sprites/CCSpriteFrame',
|
||||
'../../cocos2d/core/load-pipeline/audio-downloader',
|
||||
'../../cocos2d/core/physics/platform/CCPhysicsDebugDraw.js',
|
||||
'../../cocos2d/core/physics/platform/CCPhysicsUtils.js',
|
||||
'../../cocos2d/core/physics/platform/CCPhysicsAABBQueryCallback.js',
|
||||
'../../cocos2d/core/physics/platform/CCPhysicsRayCastCallback.js',
|
||||
'../../cocos2d/core/physics/platform/CCPhysicsContactListner.js',
|
||||
'../../cocos2d/core/camera/CCSGCameraNode.js',
|
||||
'../../cocos2d/core/label/CCSGLabel.js',
|
||||
'../../cocos2d/core/label/CCSGLabelCanvasRenderCmd.js',
|
||||
'../../cocos2d/core/label/CCSGLabelWebGLRenderCmd.js',
|
||||
'../../cocos2d/core/videoplayer/CCSGVideoPlayer.js',
|
||||
'../../cocos2d/core/webview/CCSGWebView.js',
|
||||
'../../cocos2d/core/editbox/CCSGEditBox.js',
|
||||
'../../cocos2d/core/graphics/graphics-node.js',
|
||||
'../../cocos2d/core/graphics/graphics-webgl-cmd.js',
|
||||
'../../cocos2d/core/graphics/graphics-canvas-cmd.js',
|
||||
'../../cocos2d/core/graphics/earcut.js',
|
||||
'../../cocos2d/core/graphics/helper.js',
|
||||
'../../cocos2d/audio/CCAudio',
|
||||
'../../cocos2d/shape-nodes/CCDrawNode.js',
|
||||
'../../cocos2d/clipping-nodes/CCClippingNode.js',
|
||||
'../../cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js',
|
||||
'../../cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js',
|
||||
'../../cocos2d/particle/CCSGParticleSystem.js',
|
||||
'../../cocos2d/particle/CCSGParticleSystemCanvasRenderCmd.js',
|
||||
'../../cocos2d/particle/CCSGParticleSystemWebGLRenderCmd.js',
|
||||
'../../cocos2d/tilemap/CCSGTMXTiledMap.js',
|
||||
'../../cocos2d/tilemap/CCTMXXMLParser.js',
|
||||
'../../cocos2d/tilemap/CCSGTMXObjectGroup.js',
|
||||
'../../cocos2d/tilemap/CCSGTMXObject.js',
|
||||
'../../cocos2d/tilemap/CCSGTMXLayer.js',
|
||||
'../../cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js',
|
||||
'../../cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js',
|
||||
'../../cocos2d/motion-streak/CCSGMotionStreak.js',
|
||||
'../../cocos2d/motion-streak/CCSGMotionStreakWebGLRenderCmd.js',
|
||||
'../../cocos2d/render-texture/CCRenderTexture.js',
|
||||
'../../cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js',
|
||||
'../../cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js',
|
||||
'../../extensions/spine/SGSkeleton',
|
||||
'../../extensions/spine/SGSkeletonAnimation',
|
||||
'../../extensions/spine/SGSkeletonCanvasRenderCmd',
|
||||
'../../extensions/spine/SGSkeletonWebGLRenderCmd',
|
||||
'../../extensions/spine/lib/spine',
|
||||
'../../extensions/dragonbones/lib/dragonBones',
|
||||
'../../extensions/dragonbones/CCFactory',
|
||||
'../../extensions/dragonbones/CCArmatureDisplay',
|
||||
'../../extensions/dragonbones/CCSlot',
|
||||
'../../extensions/dragonbones/CCTextureData',
|
||||
'../../external/box2d/box2d.js',
|
||||
];
|
||||
|
||||
exports.buildCocosJs = function (sourceFile, outputFile, excludes, callback) {
|
||||
var outDir = Path.dirname(outputFile);
|
||||
var outFile = Path.basename(outputFile);
|
||||
@@ -150,14 +206,16 @@ exports.buildPreview = function (sourceFile, outputFile, callback) {
|
||||
.on('end', callback);
|
||||
};
|
||||
|
||||
exports.buildJsbPreview = function (sourceFile, outputFile, jsbSkipModules, callback) {
|
||||
exports.buildJsbPreview = function (sourceFile, outputFile, excludes, callback) {
|
||||
var FixJavaScriptCore = require('../util/fix-jsb-javascriptcore');
|
||||
|
||||
var outFile = Path.basename(outputFile);
|
||||
var outDir = Path.dirname(outputFile);
|
||||
|
||||
excludes = excludes.concat(jsbSkipModules);
|
||||
|
||||
var bundler = createBundler(sourceFile);
|
||||
jsbSkipModules.forEach(function (module) {
|
||||
excludes.forEach(function (module) {
|
||||
bundler.ignore(require.resolve(module));
|
||||
});
|
||||
bundler.bundle()
|
||||
@@ -174,14 +232,16 @@ exports.buildJsbPreview = function (sourceFile, outputFile, jsbSkipModules, call
|
||||
.on('end', callback);
|
||||
};
|
||||
|
||||
exports.buildJsb = function (sourceFile, outputFile, jsbSkipModules, callback) {
|
||||
exports.buildJsb = function (sourceFile, outputFile, excludes, callback) {
|
||||
var FixJavaScriptCore = require('../util/fix-jsb-javascriptcore');
|
||||
|
||||
var outFile = Path.basename(outputFile);
|
||||
var outDir = Path.dirname(outputFile);
|
||||
|
||||
excludes = excludes.concat(jsbSkipModules);
|
||||
|
||||
var bundler = createBundler(sourceFile);
|
||||
jsbSkipModules.forEach(function (module) {
|
||||
excludes.forEach(function (module) {
|
||||
bundler.ignore(require.resolve(module));
|
||||
});
|
||||
bundler.bundle()
|
||||
@@ -198,14 +258,16 @@ exports.buildJsb = function (sourceFile, outputFile, jsbSkipModules, callback) {
|
||||
.on('end', callback);
|
||||
};
|
||||
|
||||
exports.buildJsbMin = function (sourceFile, outputFile, jsbSkipModules, callback) {
|
||||
exports.buildJsbMin = function (sourceFile, outputFile, excludes, callback) {
|
||||
var FixJavaScriptCore = require('../util/fix-jsb-javascriptcore');
|
||||
|
||||
var outFile = Path.basename(outputFile);
|
||||
var outDir = Path.dirname(outputFile);
|
||||
|
||||
excludes = excludes.concat(jsbSkipModules);
|
||||
|
||||
var bundler = createBundler(sourceFile);
|
||||
jsbSkipModules.forEach(function (module) {
|
||||
excludes.forEach(function (module) {
|
||||
bundler.ignore(require.resolve(module));
|
||||
});
|
||||
bundler.bundle()
|
||||
@@ -221,3 +283,5 @@ exports.buildJsbMin = function (sourceFile, outputFile, jsbSkipModules, callback
|
||||
.pipe(Gulp.dest(outDir))
|
||||
.on('end', callback);
|
||||
};
|
||||
|
||||
exports.jsbSkipModules = jsbSkipModules;
|
||||
|
||||
+4
-2
@@ -5,6 +5,8 @@ var Fs = require('fs');
|
||||
var Path = require('path');
|
||||
var through = require('through');
|
||||
|
||||
var Engine = require('./engine');
|
||||
|
||||
// var source = require('vinyl-source-stream');
|
||||
// var buffer = require('vinyl-buffer');
|
||||
// var sourcemaps = require('gulp-sourcemaps');
|
||||
@@ -91,7 +93,7 @@ exports.preview = function (sourceFile, outputFile) {
|
||||
});
|
||||
};
|
||||
|
||||
exports.jsbPolyfill = function (sourceFile, outputFile, skipModules) {
|
||||
exports.jsbPolyfill = function (sourceFile, outputFile) {
|
||||
return watchFile({
|
||||
entries: sourceFile,
|
||||
dest: outputFile,
|
||||
@@ -101,6 +103,6 @@ exports.jsbPolyfill = function (sourceFile, outputFile, skipModules) {
|
||||
|
||||
return prefix;
|
||||
},
|
||||
skips: skipModules
|
||||
skips: Engine.jsbSkipModules
|
||||
});
|
||||
};
|
||||
@@ -2,19 +2,22 @@ const ES = require('event-stream');
|
||||
const Path = require('path');
|
||||
|
||||
const getRealTypeOfObj = (function __realTypeOfObj (obj) {
|
||||
try {
|
||||
if ('' + obj === '[object CallbackConstructor]') return 'function';
|
||||
}
|
||||
catch (e) {
|
||||
// "Cannot convert object to primitive value"
|
||||
if (obj) {
|
||||
if (obj.toString) {
|
||||
if (obj.toString() === '[object CallbackConstructor]')
|
||||
return 'function';
|
||||
}
|
||||
else {
|
||||
// "Cannot convert object to primitive value"
|
||||
}
|
||||
}
|
||||
return 'object';
|
||||
}).toString();
|
||||
|
||||
const TYPEOF_SHIM = `\n${getRealTypeOfObj};\nvar __typeofVal = "";`;
|
||||
const TYPEOF_SHIM = `\n${getRealTypeOfObj}\nvar __typeofVal = "";`;
|
||||
|
||||
const TYPEOF_REG = /typeof\s+([$A-Za-z_][0-9A-Za-z_\$\.\[\]]*)/g;
|
||||
const TYPEOF_REPLACEMENT = '(__typeofVal = typeof $1, __typeofVal === "object" ? __realTypeOfObj($1) : __typeofVal)';
|
||||
const TYPEOF_REG = /typeof\s+([$A-Za-z_][0-9A-Za-z_$\.\[\]]*)([\s!=;\)])/g;
|
||||
const TYPEOF_REPLACEMENT = '(__typeofVal = typeof $1, __typeofVal === "object" ? __realTypeOfObj($1) : __typeofVal)$2';
|
||||
|
||||
module.exports = function () {
|
||||
return ES.through(function (file) {
|
||||
|
||||
@@ -43,6 +43,9 @@ exports.getUglifyOptions = function (platform, isJSB, isDebugBuild) {
|
||||
return {
|
||||
compress: {
|
||||
global_defs: global_defs,
|
||||
},
|
||||
output: {
|
||||
ascii_only: true,
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -54,6 +57,7 @@ exports.getUglifyOptions = function (platform, isJSB, isDebugBuild) {
|
||||
// http://lisperator.net/uglifyjs/codegen
|
||||
beautify: true,
|
||||
indent_level: 2,
|
||||
ascii_only: true,
|
||||
},
|
||||
compress: {
|
||||
// https://github.com/mishoo/UglifyJS2#compressor-options
|
||||
|
||||
+4
-55
@@ -52,73 +52,22 @@ gulp.task('build-html5-preview', function (done) {
|
||||
|
||||
gulp.task('build-html5', ['build-html5-preview', 'build-html5-dev', 'build-html5-min']);
|
||||
|
||||
var jsbSkipModules = [
|
||||
'../../cocos2d/core/CCGame',
|
||||
'../../cocos2d/core/CCDrawingPrimitives.js',
|
||||
// '../../cocos2d/core/textures/CCTexture2D',
|
||||
// '../../cocos2d/core/sprites/CCSpriteFrame',
|
||||
'../../cocos2d/core/load-pipeline/audio-downloader',
|
||||
'../../cocos2d/core/physics/platform/CCPhysicsDebugDraw.js',
|
||||
'../../cocos2d/core/physics/platform/CCPhysicsUtils.js',
|
||||
'../../cocos2d/core/physics/platform/CCPhysicsAABBQueryCallback.js',
|
||||
'../../cocos2d/core/physics/platform/CCPhysicsRayCastCallback.js',
|
||||
'../../cocos2d/core/physics/platform/CCPhysicsContactListner.js',
|
||||
'../../cocos2d/core/camera/CCSGCameraNode.js',
|
||||
'../../cocos2d/core/label/CCSGLabel.js',
|
||||
'../../cocos2d/core/label/CCSGLabelCanvasRenderCmd.js',
|
||||
'../../cocos2d/core/label/CCSGLabelWebGLRenderCmd.js',
|
||||
'../../cocos2d/core/videoplayer/CCSGVideoPlayer.js',
|
||||
'../../cocos2d/core/webview/CCSGWebView.js',
|
||||
'../../cocos2d/core/editbox/CCSGEditBox.js',
|
||||
'../../cocos2d/audio/CCAudio',
|
||||
'../../cocos2d/shape-nodes/CCDrawNode.js',
|
||||
'../../cocos2d/clipping-nodes/CCClippingNode.js',
|
||||
'../../cocos2d/clipping-nodes/CCClippingNodeCanvasRenderCmd.js',
|
||||
'../../cocos2d/clipping-nodes/CCClippingNodeWebGLRenderCmd.js',
|
||||
'../../cocos2d/particle/CCSGParticleSystem.js',
|
||||
'../../cocos2d/particle/CCSGParticleSystemCanvasRenderCmd.js',
|
||||
'../../cocos2d/particle/CCSGParticleSystemWebGLRenderCmd.js',
|
||||
'../../cocos2d/tilemap/CCSGTMXTiledMap.js',
|
||||
'../../cocos2d/tilemap/CCTMXXMLParser.js',
|
||||
'../../cocos2d/tilemap/CCSGTMXObjectGroup.js',
|
||||
'../../cocos2d/tilemap/CCSGTMXObject.js',
|
||||
'../../cocos2d/tilemap/CCSGTMXLayer.js',
|
||||
'../../cocos2d/tilemap/CCTMXLayerCanvasRenderCmd.js',
|
||||
'../../cocos2d/tilemap/CCTMXLayerWebGLRenderCmd.js',
|
||||
'../../cocos2d/motion-streak/CCSGMotionStreak.js',
|
||||
'../../cocos2d/motion-streak/CCSGMotionStreakWebGLRenderCmd.js',
|
||||
'../../cocos2d/render-texture/CCRenderTexture.js',
|
||||
'../../cocos2d/render-texture/CCRenderTextureCanvasRenderCmd.js',
|
||||
'../../cocos2d/render-texture/CCRenderTextureWebGLRenderCmd.js',
|
||||
'../../extensions/spine/SGSkeleton',
|
||||
'../../extensions/spine/SGSkeletonAnimation',
|
||||
'../../extensions/spine/SGSkeletonCanvasRenderCmd',
|
||||
'../../extensions/spine/SGSkeletonWebGLRenderCmd',
|
||||
'../../extensions/spine/lib/spine',
|
||||
'../../extensions/dragonbones/lib/dragonBones',
|
||||
'../../extensions/dragonbones/CCFactory',
|
||||
'../../extensions/dragonbones/CCArmatureDisplay',
|
||||
'../../extensions/dragonbones/CCSlot',
|
||||
'../../extensions/dragonbones/CCTextureData',
|
||||
'../../external/box2d/box2d.js',
|
||||
];
|
||||
|
||||
gulp.task('build-jsb-dev', function (done) {
|
||||
Engine.buildJsb([
|
||||
'./jsb/index.js',
|
||||
], './bin/jsb_polyfill.dev.js', jsbSkipModules, done);
|
||||
], './bin/jsb_polyfill.dev.js', [], done);
|
||||
});
|
||||
|
||||
gulp.task('build-jsb-min', function (done) {
|
||||
Engine.buildJsbMin([
|
||||
'./jsb/index.js',
|
||||
], './bin/jsb_polyfill.js', jsbSkipModules, done);
|
||||
], './bin/jsb_polyfill.js', [], done);
|
||||
});
|
||||
|
||||
gulp.task('build-jsb-preview', function (done) {
|
||||
Engine.buildJsbPreview([
|
||||
'./jsb/index.js',
|
||||
], './bin/jsb_polyfill-for-preview.js', jsbSkipModules, done);
|
||||
], './bin/jsb_polyfill-for-preview.js', [], done);
|
||||
});
|
||||
|
||||
gulp.task('build-jsb', ['build-jsb-preview', 'build-jsb-dev', 'build-jsb-min']);
|
||||
@@ -203,7 +152,7 @@ gulp.task('watch-preview', function () {
|
||||
gulp.task('watch-jsb-polyfill', function () {
|
||||
Watch.jsbPolyfill([
|
||||
'./jsb/index.js',
|
||||
], './bin/jsb_polyfill.dev.js', jsbSkipModules);
|
||||
], './bin/jsb_polyfill.dev.js');
|
||||
});
|
||||
|
||||
gulp.task('watch-dev-files', ['watch-preview', 'watch-jsb-polyfill']);
|
||||
|
||||
@@ -106,25 +106,28 @@
|
||||
/**
|
||||
* @property {Boolean} CC_TEST - Running in the engine's unit test.
|
||||
*/
|
||||
|
||||
// window may be undefined when first load engine from editor
|
||||
var _global = typeof window === 'undefined' ? global : window;
|
||||
function defineMacro (name, defaultValue) {
|
||||
// if "global_defs" not preprocessed by uglify, just declare them globally,
|
||||
// this may happened in release version's preview page.
|
||||
// (use evaled code to prevent mangle by uglify)
|
||||
return 'if(typeof ' + name + '=="undefined")' +
|
||||
name + '=' + defaultValue + ';';
|
||||
if (typeof _global[name] == 'undefined') {
|
||||
_global[name] = defaultValue;
|
||||
}
|
||||
}
|
||||
function defined (name) {
|
||||
return 'typeof ' + name + '=="object"';
|
||||
return typeof _global[name] == 'object';
|
||||
}
|
||||
Function(
|
||||
defineMacro('CC_TEST', defined('tap') + '||' + defined('QUnit')) +
|
||||
defineMacro('CC_EDITOR', defined('Editor') + '&&' + defined('process') + '&&"electron" in process.versions') +
|
||||
defineMacro('CC_PREVIEW', '!CC_EDITOR') +
|
||||
defineMacro('CC_DEV', true) + // (CC_EDITOR && !CC_BUILD) || CC_PREVIEW || CC_TEST
|
||||
defineMacro('CC_DEBUG', true) + // CC_DEV || Debug Build
|
||||
defineMacro('CC_JSB', defined('jsb')) +
|
||||
defineMacro('CC_BUILD', false)
|
||||
)();
|
||||
|
||||
defineMacro('CC_TEST', defined('tap') || defined('QUnit'));
|
||||
defineMacro('CC_EDITOR', defined('Editor') && defined('process') && ('electron' in process.versions));
|
||||
defineMacro('CC_PREVIEW', !CC_EDITOR);
|
||||
defineMacro('CC_DEV', true); // (CC_EDITOR && !CC_BUILD) || CC_PREVIEW || CC_TEST
|
||||
defineMacro('CC_DEBUG', true); // CC_DEV || Debug Build
|
||||
defineMacro('CC_JSB', defined('jsb'));
|
||||
defineMacro('CC_BUILD', false);
|
||||
|
||||
// PREDEFINE
|
||||
|
||||
@@ -138,6 +141,9 @@ Function(
|
||||
*/
|
||||
cc = {};
|
||||
|
||||
// check whether support jit
|
||||
cc.supportJit = typeof Function('') === 'function';
|
||||
|
||||
// The namespace for original nodes rendering in scene graph.
|
||||
_ccsg = {};
|
||||
|
||||
|
||||
+17
-22
@@ -25,36 +25,29 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
var originLog = console.log;
|
||||
|
||||
// overwrite original console.log
|
||||
try {
|
||||
console.log = function (...args) {
|
||||
originLog(cc.js.formatStr.apply(null, args));
|
||||
};
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
// check whether support jit
|
||||
cc.supportJit = typeof Function('') === 'function';
|
||||
|
||||
function defineMacro (name, defaultValue) {
|
||||
// if "global_defs" not preprocessed by uglify, just declare them globally,
|
||||
// this may happened in release version's preview page.
|
||||
// (use evaled code to prevent mangle by uglify)
|
||||
return 'if(typeof ' + name + '=="undefined")' +
|
||||
name + '=' + defaultValue + ';';
|
||||
if (typeof window[name] == 'undefined') {
|
||||
window[name] = defaultValue;
|
||||
}
|
||||
}
|
||||
function defined (name) {
|
||||
return 'typeof ' + name + '=="object"';
|
||||
return typeof window[name] == 'object';
|
||||
}
|
||||
Function(
|
||||
defineMacro('CC_TEST', defined('tap') + '||' + defined('QUnit')) +
|
||||
defineMacro('CC_EDITOR', defined('Editor') + '&&' + defined('process') + '&&"electron" in process.versions') +
|
||||
defineMacro('CC_PREVIEW', '!CC_EDITOR') +
|
||||
defineMacro('CC_DEV', true) + // (CC_EDITOR && !CC_BUILD) || CC_PREVIEW || CC_TEST
|
||||
defineMacro('CC_DEBUG', true) + // CC_DEV || Debug Build
|
||||
defineMacro('CC_JSB', defined('jsb')) +
|
||||
defineMacro('CC_BUILD', false)
|
||||
)();
|
||||
|
||||
defineMacro('CC_TEST', defined('tap') || defined('QUnit'));
|
||||
defineMacro('CC_EDITOR', defined('Editor') && defined('process') && ('electron' in process.versions));
|
||||
defineMacro('CC_PREVIEW', !CC_EDITOR);
|
||||
defineMacro('CC_DEV', true); // (CC_EDITOR && !CC_BUILD) || CC_PREVIEW || CC_TEST
|
||||
defineMacro('CC_DEBUG', true); // CC_DEV || Debug Build
|
||||
defineMacro('CC_JSB', defined('jsb'));
|
||||
defineMacro('CC_BUILD', false);
|
||||
|
||||
|
||||
if (!cc.ClassManager) {
|
||||
cc.ClassManager = window.ClassManager;
|
||||
@@ -70,6 +63,8 @@ if (CC_DEV) {
|
||||
|
||||
// polyfills
|
||||
require('../polyfill/misc');
|
||||
// str.startswith isn't supported in JavaScriptCore which is shipped with iOS8.
|
||||
require('../polyfill/string');
|
||||
if (!(CC_EDITOR && Editor.isMainProcess)) {
|
||||
require('../polyfill/typescript');
|
||||
}
|
||||
|
||||
+6
-3
@@ -295,10 +295,13 @@ cc.ActionManager.prototype.addAction = function (action, target, paused) {
|
||||
function actionMgrFuncReplacer (funcName, targetPos) {
|
||||
var proto = cc.ActionManager.prototype;
|
||||
var oldFunc = proto[funcName];
|
||||
proto[funcName] = function (...args) {
|
||||
for (var i = 0; i < args.length; i++) {
|
||||
proto[funcName] = function () {
|
||||
var args = [];
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
if (i === targetPos)
|
||||
args[i] = getSGTarget(args[i]);
|
||||
args[i] = getSGTarget(arguments[i]);
|
||||
else
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
if (!args[targetPos]) {
|
||||
return;
|
||||
|
||||
@@ -43,13 +43,9 @@ proto.removeEvent = function(type, listener, target) {
|
||||
|
||||
var armatureProto = dragonBones.Armature.prototype;
|
||||
armatureProto.addEventListener = function (type, listener, target) {
|
||||
var display = this.display;
|
||||
jsb.registerNativeRef(this, display);
|
||||
display.addEvent(type, listener, target);
|
||||
this.display.addEvent(type, listener, target);
|
||||
};
|
||||
|
||||
armatureProto.removeEventListener = function (type, listener, target) {
|
||||
var display = this.display;
|
||||
jsb.unregisterNativeRef(this, display);
|
||||
display.removeEvent(type, listener, target);
|
||||
this.display.removeEvent(type, listener, target);
|
||||
};
|
||||
|
||||
@@ -59,3 +59,98 @@ _p.getTabIndex = function () { return -1; };
|
||||
_p.setFocus = function () {};
|
||||
_p.isFocused = function () { return false; };
|
||||
_p.stayOnTop = function () {};
|
||||
|
||||
|
||||
|
||||
cc.EditBox.InputMode = cc.Enum({
|
||||
|
||||
ANY: 0,
|
||||
|
||||
/**
|
||||
* The user is allowed to enter an e-mail address.
|
||||
*/
|
||||
EMAIL_ADDR: 1,
|
||||
|
||||
/**
|
||||
* The user is allowed to enter an integer value.
|
||||
*/
|
||||
NUMERIC: 2,
|
||||
|
||||
/**
|
||||
* The user is allowed to enter a phone number.
|
||||
*/
|
||||
PHONE_NUMBER: 3,
|
||||
|
||||
/**
|
||||
* The user is allowed to enter a URL.
|
||||
*/
|
||||
URL: 4,
|
||||
|
||||
/**
|
||||
* The user is allowed to enter a real number value.
|
||||
* This extends kEditBoxInputModeNumeric by allowing a decimal point.
|
||||
*/
|
||||
DECIMAL: 5,
|
||||
|
||||
/**
|
||||
* The user is allowed to enter any text, except for line breaks.
|
||||
*/
|
||||
SINGLE_LINE: 6
|
||||
});
|
||||
|
||||
/**
|
||||
* Enum for the EditBox's input flags
|
||||
* @readonly
|
||||
* @enum {number}
|
||||
* @memberof cc.EditBox
|
||||
*/
|
||||
cc.EditBox.InputFlag = cc.Enum({
|
||||
/**
|
||||
* Indicates that the text entered is confidential data that should be
|
||||
* obscured whenever possible. This implies EDIT_BOX_INPUT_FLAG_SENSITIVE.
|
||||
*/
|
||||
PASSWORD: 0,
|
||||
|
||||
/**
|
||||
* Indicates that the text entered is sensitive data that the
|
||||
* implementation must never store into a dictionary or table for use
|
||||
* in predictive, auto-completing, or other accelerated input schemes.
|
||||
* A credit card number is an example of sensitive data.
|
||||
*/
|
||||
SENSITIVE: 1,
|
||||
|
||||
/**
|
||||
* This flag is a hint to the implementation that during text editing,
|
||||
* the initial letter of each word should be capitalized.
|
||||
*/
|
||||
INITIAL_CAPS_WORD: 2,
|
||||
|
||||
/**
|
||||
* This flag is a hint to the implementation that during text editing,
|
||||
* the initial letter of each sentence should be capitalized.
|
||||
*/
|
||||
INITIAL_CAPS_SENTENCE: 3,
|
||||
|
||||
/**
|
||||
* Capitalize all characters automatically.
|
||||
*/
|
||||
INITIAL_CAPS_ALL_CHARACTERS: 4,
|
||||
|
||||
/**
|
||||
* Don't do anything with the input text.
|
||||
*/
|
||||
DEFAULT: 5
|
||||
});
|
||||
|
||||
/**
|
||||
* Enum for keyboard return types
|
||||
* @readonly
|
||||
* @enum {number}
|
||||
*/
|
||||
cc.EditBox.KeyboardReturnType = cc.Enum({
|
||||
DEFAULT: 0,
|
||||
DONE: 1,
|
||||
SEND: 2,
|
||||
SEARCH: 3,
|
||||
GO: 4
|
||||
});
|
||||
@@ -25,126 +25,6 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
//FIXME: should delete this line after implementing the VideoPlayer on Mac and Windows
|
||||
if (cc.sys.os === cc.sys.OS_OSX || cc.sys.os === cc.sys.OS_WINDOWS) {
|
||||
cc.VideoPlayer = {};
|
||||
}
|
||||
|
||||
//FIXME: should delete this line after implementing the VideoPlayer on Mac and Windows
|
||||
if (cc.sys.os === cc.sys.OS_OSX || cc.sys.os === cc.sys.OS_WINDOWS) {
|
||||
cc.WebView = {};
|
||||
}
|
||||
|
||||
cc.VideoPlayer.EventType = {
|
||||
PLAYING: 0,
|
||||
PAUSED: 1,
|
||||
STOPPED: 2,
|
||||
COMPLETED: 3,
|
||||
META_LOADED: 4,
|
||||
CLICKED: 5,
|
||||
READY_TO_PLAY: 6
|
||||
};
|
||||
|
||||
cc.WebView.EventType = {
|
||||
LOADING: 0,
|
||||
LOADED: 1,
|
||||
ERROR: 2,
|
||||
JS_EVALUATED: 3
|
||||
};
|
||||
|
||||
cc.EditBox.InputMode = cc.Enum({
|
||||
|
||||
ANY: 0,
|
||||
|
||||
/**
|
||||
* The user is allowed to enter an e-mail address.
|
||||
*/
|
||||
EMAIL_ADDR: 1,
|
||||
|
||||
/**
|
||||
* The user is allowed to enter an integer value.
|
||||
*/
|
||||
NUMERIC: 2,
|
||||
|
||||
/**
|
||||
* The user is allowed to enter a phone number.
|
||||
*/
|
||||
PHONE_NUMBER: 3,
|
||||
|
||||
/**
|
||||
* The user is allowed to enter a URL.
|
||||
*/
|
||||
URL: 4,
|
||||
|
||||
/**
|
||||
* The user is allowed to enter a real number value.
|
||||
* This extends kEditBoxInputModeNumeric by allowing a decimal point.
|
||||
*/
|
||||
DECIMAL: 5,
|
||||
|
||||
/**
|
||||
* The user is allowed to enter any text, except for line breaks.
|
||||
*/
|
||||
SINGLE_LINE: 6
|
||||
});
|
||||
|
||||
/**
|
||||
* Enum for the EditBox's input flags
|
||||
* @readonly
|
||||
* @enum {number}
|
||||
* @memberof cc.EditBox
|
||||
*/
|
||||
cc.EditBox.InputFlag = cc.Enum({
|
||||
/**
|
||||
* Indicates that the text entered is confidential data that should be
|
||||
* obscured whenever possible. This implies EDIT_BOX_INPUT_FLAG_SENSITIVE.
|
||||
*/
|
||||
PASSWORD: 0,
|
||||
|
||||
/**
|
||||
* Indicates that the text entered is sensitive data that the
|
||||
* implementation must never store into a dictionary or table for use
|
||||
* in predictive, auto-completing, or other accelerated input schemes.
|
||||
* A credit card number is an example of sensitive data.
|
||||
*/
|
||||
SENSITIVE: 1,
|
||||
|
||||
/**
|
||||
* This flag is a hint to the implementation that during text editing,
|
||||
* the initial letter of each word should be capitalized.
|
||||
*/
|
||||
INITIAL_CAPS_WORD: 2,
|
||||
|
||||
/**
|
||||
* This flag is a hint to the implementation that during text editing,
|
||||
* the initial letter of each sentence should be capitalized.
|
||||
*/
|
||||
INITIAL_CAPS_SENTENCE: 3,
|
||||
|
||||
/**
|
||||
* Capitalize all characters automatically.
|
||||
*/
|
||||
INITIAL_CAPS_ALL_CHARACTERS: 4,
|
||||
|
||||
/**
|
||||
* Don't do anything with the input text.
|
||||
*/
|
||||
DEFAULT: 5
|
||||
});
|
||||
|
||||
/**
|
||||
* Enum for keyboard return types
|
||||
* @readonly
|
||||
* @enum {number}
|
||||
*/
|
||||
cc.EditBox.KeyboardReturnType = cc.Enum({
|
||||
DEFAULT: 0,
|
||||
DONE: 1,
|
||||
SEND: 2,
|
||||
SEARCH: 3,
|
||||
GO: 4
|
||||
});
|
||||
|
||||
/**
|
||||
* Enum for text alignment
|
||||
* @readonly
|
||||
|
||||
+9
-9
@@ -66,6 +66,7 @@ cc.view.setOrientation = function () {};
|
||||
var _windowTimeIntervalId = 0;
|
||||
var _windowTimeFunHash = {};
|
||||
var WindowTimeFun = function (code) {
|
||||
this.__instanceId = cc.ClassManager.getNewInstanceId();
|
||||
this._intervalId = _windowTimeIntervalId++;
|
||||
this._code = code;
|
||||
};
|
||||
@@ -87,14 +88,13 @@ WindowTimeFun.prototype.fun = function () {
|
||||
@param {number} delay
|
||||
@return {number}
|
||||
*/
|
||||
window.setTimeout = function (code, delay, ...args) {
|
||||
window.setTimeout = function (code, delay) {
|
||||
var target = new WindowTimeFun(code);
|
||||
if (args.length > 0) {
|
||||
target._args = args;
|
||||
}
|
||||
if (arguments.length > 2)
|
||||
target._args = Array.prototype.slice.call(arguments, 2);
|
||||
var original = target.fun;
|
||||
target.fun = function () {
|
||||
original.call(this);
|
||||
original.apply(this, arguments);
|
||||
clearTimeout(target._intervalId);
|
||||
};
|
||||
cc.director.getScheduler().schedule(target.fun, target, delay / 1000, 0, 0, false);
|
||||
@@ -108,11 +108,11 @@ window.setTimeout = function (code, delay, ...args) {
|
||||
@param {number} delay
|
||||
@return {number}
|
||||
*/
|
||||
window.setInterval = function (code, delay, ...args) {
|
||||
window.setInterval = function (code, delay) {
|
||||
var target = new WindowTimeFun(code);
|
||||
if (args.length > 0) {
|
||||
target._args = args;
|
||||
}
|
||||
if (arguments.length > 2)
|
||||
target._args = Array.prototype.slice.call(arguments, 2);
|
||||
|
||||
cc.director.getScheduler().schedule(target.fun, target, delay / 1000, cc.macro.REPEAT_FOREVER, 0, false);
|
||||
_windowTimeFunHash[target._intervalId] = target;
|
||||
return target._intervalId;
|
||||
|
||||
@@ -96,6 +96,7 @@ function loadImage (item, callback) {
|
||||
else if (isRemote) {
|
||||
jsb.loadRemoteImg(url, function(succeed, tex) {
|
||||
if (succeed) {
|
||||
tex.url = url;
|
||||
callback && callback(null, tex);
|
||||
}
|
||||
else {
|
||||
@@ -106,6 +107,7 @@ function loadImage (item, callback) {
|
||||
else {
|
||||
cc.textureCache._addImageAsync(url, function (tex) {
|
||||
if (tex instanceof cc.Texture2D) {
|
||||
tex.url = url;
|
||||
callback && callback(null, tex);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -170,6 +170,7 @@ prototype.getPixelHeight = prototype.getPixelsHigh;
|
||||
prototype.description = prototype.getDescription;
|
||||
cc.js.get(prototype, 'pixelWidth', prototype.getPixelWidth);
|
||||
cc.js.get(prototype, 'pixelHeight', prototype.getPixelHeight);
|
||||
cc.js.get(prototype, '_glID', prototype.getName);
|
||||
|
||||
// cc.SpriteFrame
|
||||
|
||||
@@ -331,4 +332,5 @@ prototype.clone = function () {
|
||||
return cloned;
|
||||
};
|
||||
|
||||
cc.js.getset(prototype, 'texture', prototype.getTexture, prototype.setTexture);
|
||||
cc.js.addon(prototype, WebSpriteFrame.prototype);
|
||||
|
||||
@@ -24,3 +24,18 @@
|
||||
****************************************************************************/
|
||||
|
||||
cc.VideoPlayer = ccui.VideoPlayer;
|
||||
|
||||
//FIXME: should delete this line after implementing the VideoPlayer on Mac and Windows
|
||||
if (cc.sys.os === cc.sys.OS_OSX || cc.sys.os === cc.sys.OS_WINDOWS) {
|
||||
cc.VideoPlayer = {};
|
||||
}
|
||||
|
||||
cc.VideoPlayer.EventType = {
|
||||
PLAYING: 0,
|
||||
PAUSED: 1,
|
||||
STOPPED: 2,
|
||||
COMPLETED: 3,
|
||||
META_LOADED: 4,
|
||||
CLICKED: 5,
|
||||
READY_TO_PLAY: 6
|
||||
};
|
||||
|
||||
@@ -24,3 +24,15 @@
|
||||
****************************************************************************/
|
||||
|
||||
cc.WebView = ccui.WebView;
|
||||
|
||||
//FIXME: should delete this line after implementing the VideoPlayer on Mac and Windows
|
||||
if (cc.sys.os === cc.sys.OS_OSX || cc.sys.os === cc.sys.OS_WINDOWS) {
|
||||
cc.WebView = {};
|
||||
}
|
||||
|
||||
cc.WebView.EventType = {
|
||||
LOADING: 0,
|
||||
LOADED: 1,
|
||||
ERROR: 2,
|
||||
JS_EVALUATED: 3
|
||||
};
|
||||
+17
-7
@@ -59,7 +59,8 @@
|
||||
{
|
||||
"name": "Spine Skeleton",
|
||||
"entries": [
|
||||
"./extensions/spine/index.js"
|
||||
"./extensions/spine/index.js",
|
||||
"./jsb/jsb-spine.js"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -131,19 +132,22 @@
|
||||
{
|
||||
"name": "EditorBox",
|
||||
"entries": [
|
||||
"./cocos2d/core/components/CCEditBox.js"
|
||||
"./cocos2d/core/components/CCEditBox.js",
|
||||
"./jsb/jsb-editbox.js"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "VideoPlayer",
|
||||
"entries": [
|
||||
"./cocos2d/core/components/CCVideoPlayer.js"
|
||||
"./cocos2d/core/components/CCVideoPlayer.js",
|
||||
"./jsb/jsb-videoplayer.js"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "WebView",
|
||||
"entries": [
|
||||
"./cocos2d/core/components/CCWebView.js"
|
||||
"./cocos2d/core/components/CCWebView.js",
|
||||
"./jsb/jsb-webview.js"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -155,7 +159,8 @@
|
||||
{
|
||||
"name": "AudioSource",
|
||||
"entries": [
|
||||
"./cocos2d/core/components/CCAudioSource.js"
|
||||
"./cocos2d/core/components/CCAudioSource.js",
|
||||
"./jsb/jsb-audio.js"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -198,13 +203,15 @@
|
||||
{
|
||||
"name": "DragonBones",
|
||||
"entries": [
|
||||
"./extensions/dragonbones/index.js"
|
||||
"./extensions/dragonbones/index.js",
|
||||
"./jsb/jsb-dragonbones.js"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Physics",
|
||||
"entries": [
|
||||
"./cocos2d/core/physics/index.js"
|
||||
"./cocos2d/core/physics/index.js",
|
||||
"./jsb/jsb-box2d.js"
|
||||
],
|
||||
"dependencies": ["Collider"]
|
||||
},
|
||||
@@ -239,5 +246,8 @@
|
||||
"entries": [
|
||||
"./cocos2d/core/collider/CCIntersection.js"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Native NetWork"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -44,7 +44,6 @@
|
||||
"jshint-stylish": "2.1.0",
|
||||
"multipipe": "0.3.0",
|
||||
"persistify": "^1.1.1",
|
||||
"require-dir": "0.3.0",
|
||||
"uglify-es": "^3.0.26",
|
||||
"vinyl": "1.1.0",
|
||||
"vinyl-buffer": "1.0.0",
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ if (!Number.isInteger) {
|
||||
};
|
||||
}
|
||||
|
||||
if (!console.time) {
|
||||
if (CC_JSB || !console.time) {
|
||||
var Timer = window.performance || Date;
|
||||
var _timerTable = Object.create(null);
|
||||
console.time = function (label) {
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
|
||||
module('EventTarget');
|
||||
|
||||
test('once', function () {
|
||||
var target = new cc.EventTarget();
|
||||
var fireEvent = new cc.Event('fire');
|
||||
var cb1 = new Callback();
|
||||
|
||||
// once
|
||||
target.once('fire', cb1.enable());
|
||||
target.dispatchEvent(fireEvent);
|
||||
cb1.once('should be invoked if registered by once')
|
||||
.disable('should only invoke once 1');
|
||||
target.dispatchEvent(fireEvent);
|
||||
|
||||
// once + on
|
||||
var cb2 = new Callback().enable();
|
||||
|
||||
target.once('fire', cb1.enable());
|
||||
target.on('fire', cb2);
|
||||
|
||||
target.dispatchEvent(fireEvent);
|
||||
cb1.once('should be invoked if registered by once and before other callback');
|
||||
cb2.once('should still be invoked if previous event was removed');
|
||||
|
||||
cb1.disable('should only invoke once 2');
|
||||
target.dispatchEvent(fireEvent);
|
||||
cb2.once('should not remove common event');
|
||||
|
||||
// on + once
|
||||
|
||||
target.once('fire', cb1.enable());
|
||||
target.dispatchEvent(fireEvent);
|
||||
cb2.once();
|
||||
cb1.once('should be invoked if registered by once and after other callback')
|
||||
.disable('should only invoke once 3');
|
||||
target.dispatchEvent(fireEvent);
|
||||
cb2.once();
|
||||
});
|
||||
|
||||
test('call "once" twice', function () {
|
||||
var target = new cc.EventTarget();
|
||||
var cb1 = new Callback().enable();
|
||||
var ctx = {};
|
||||
|
||||
target.once('fire', cb1, ctx, true);
|
||||
target.once('fire', cb1, ctx, true);
|
||||
target.emit('fire');
|
||||
cb1.once('should be invoked only once')
|
||||
.disable('should only invoke once');
|
||||
target.emit('fire');
|
||||
});
|
||||
@@ -365,33 +365,6 @@ test('attach events', function () {
|
||||
cc.engine.off('node-detach-from-scene', onDetach);
|
||||
});
|
||||
|
||||
test('release sg node', function () {
|
||||
var isJSB = CC_JSB;
|
||||
CC_JSB = true;
|
||||
|
||||
var parent = new cc.Node();
|
||||
var child = new cc.Node();
|
||||
child.parent = parent;
|
||||
|
||||
var childReleased = false;
|
||||
var parentReleased = false;
|
||||
|
||||
child._sgNode.release = function () {
|
||||
childReleased = true;
|
||||
};
|
||||
parent._sgNode.release = function () {
|
||||
parentReleased = true;
|
||||
};
|
||||
|
||||
parent.destroy();
|
||||
cc.Object._deferredDestroy();
|
||||
|
||||
strictEqual(parentReleased, true, 'should release parent sg node');
|
||||
strictEqual(childReleased, true, 'should release child sg node');
|
||||
|
||||
CC_JSB = isJSB;
|
||||
});
|
||||
|
||||
test('getBoundingBox', function () {
|
||||
var node = new cc.Node();
|
||||
node.anchorX = 0.5;
|
||||
|
||||
Reference in New Issue
Block a user