Merge branch 'develop' of https://github.com/cocos2d/cocos2d-x into develop

# By samuele3hu (3) and others
# Via James Chen (3) and others
* 'develop' of https://github.com/cocos2d/cocos2d-x:
  Update CHANGELOG [ci skip]
  issue #3708:Remove some comments
  issue #3708:Remove the useless test case
  #3947 Simulate 'setTimeout' and 'setInterval' in JSB.
  issue #3708:Performance Test: data structure conversion in lua binding
This commit is contained in:
bmanGH 2014-02-17 15:57:50 +08:00
commit 7b4f15dae9
3 changed files with 1469 additions and 1189 deletions

View File

@ -6,6 +6,7 @@ cocos2d-x-3.0rc0 Feb.?? 2014
[NEW] Using python to automatically generate script bindings codes. [NEW] Using python to automatically generate script bindings codes.
[NEW] Linux javascript bindings support. [NEW] Linux javascript bindings support.
[FIX] Supports 'setTimeout' and 'setInterval' in JSB.
[FIX] Exposes the missing data structures of Spine to JS. [FIX] Exposes the missing data structures of Spine to JS.
[FIX] Node::setRotation() moves opposite when node has a physics body. [FIX] Node::setRotation() moves opposite when node has a physics body.
[FIX] A string which only contains CJK characters can't make a line-break when it's needed. [FIX] A string which only contains CJK characters can't make a line-break when it's needed.

View File

@ -3,6 +3,7 @@
// //
var cc = cc || {}; var cc = cc || {};
var window = window || this;
cc.TARGET_PLATFORM = { cc.TARGET_PLATFORM = {
WINDOWS:0, WINDOWS:0,
@ -821,3 +822,62 @@ cc.VisibleRect = {
} }
}; };
var _windowTimeIntervalId = 0;
var _windowTimeFunHash = {};
var WindowTimeFun = cc.Class.extend({
_code: null,
_intervalId: 0,
ctor: function (code) {
this._intervalId = _windowTimeIntervalId++;
this._code = code;
},
fun: function () {
if (!this._code) return;
var code = this._code;
if (typeof code == "string") {
Function(code)();
}
else if (typeof code == "function") {
code();
}
}
});
/**
* overwrite window's setTimeout
@param {String|Function} code
@param {number} delay
@return {number}
*/
var setTimeout = function (code, delay) {
var target = new WindowTimeFun(code);
cc.Director.getInstance().getScheduler().scheduleCallbackForTarget(target, target.fun, delay / 1000, 0, 0, false);
_windowTimeFunHash[target._intervalId] = target;
return target._intervalId;
};
/**
* overwrite window's setInterval
@param {String|Function} code
@param {number} delay
@return {number}
*/
var setInterval = function (code, delay) {
var target = new WindowTimeFun(code);
cc.Director.getInstance().getScheduler().scheduleCallbackForTarget(target, target.fun, delay / 1000, cc.REPEAT_FOREVER, 0, false);
_windowTimeFunHash[target._intervalId] = target;
return target._intervalId;
};
/**
* overwrite window's clearInterval
@param {number} intervalId
*/
var clearInterval = function (intervalId) {
var target = _windowTimeFunHash[intervalId];
if (target) {
cc.Director.getInstance().getScheduler().unscheduleCallbackForTarget(target, target.fun);
delete _windowTimeFunHash[intervalId];
}
};
var clearTimeout = clearInterval;