Skip to content

Commit

Permalink
Merge pull request cocos2d#1221 from dingpinglv/Iss3151_ReduceDependency
Browse files Browse the repository at this point in the history
Closed cocos2d#3151: Reducing Some classes' dependency in cc.Director for Performance
  • Loading branch information
dingpinglv committed Nov 12, 2013
2 parents c038ab7 + 33ffb9c commit ad1d0b4
Show file tree
Hide file tree
Showing 16 changed files with 219 additions and 354 deletions.
1 change: 0 additions & 1 deletion HelloHTML5World/build.xml
Expand Up @@ -28,7 +28,6 @@
<file name="platform/CCImage.js"/>
<file name="platform/zlib.min.js"/>
<file name="cocoa/CCNS.js"/>
<file name="cocoa/CCSet.js"/>
<file name="kazmath/vec2.js"/>
<file name="kazmath/vec3.js"/>
<file name="kazmath/vec4.js"/>
Expand Down
27 changes: 21 additions & 6 deletions cocos2d/CCDirector.js
Expand Up @@ -245,14 +245,18 @@ cc.Director = cc.Class.extend(/** @lends cc.Director# */{
this._touchDispatcher.init();

//KeyboardDispatcher
this._keyboardDispatcher = cc.KeyboardDispatcher.getInstance();
if(cc.KeyboardDispatcher)
this._keyboardDispatcher = cc.KeyboardDispatcher.getInstance();

//accelerometer
this._accelerometer = new cc.Accelerometer();
if(cc.Accelerometer)
this._accelerometer = new cc.Accelerometer();

//MouseDispatcher
this._mouseDispatcher = new cc.MouseDispatcher();
this._mouseDispatcher.init();
if(cc.MouseDispatcher){
this._mouseDispatcher = new cc.MouseDispatcher();
this._mouseDispatcher.init();
}

return true;
},
Expand Down Expand Up @@ -1057,30 +1061,41 @@ cc.Director = cc.Class.extend(/** @lends cc.Director# */{
},

getKeyboardDispatcher:function () {
if(!cc.KeyboardDispatcher)
throw "cc.KeyboardDispatcher is undefined, maybe it has been removed from js loading list.";
return this._keyboardDispatcher;
},
setKeyboardDispatcher:function (keyboardDispatcher) {
if(!cc.KeyboardDispatcher)
throw "cc.KeyboardDispatcher is undefined, maybe it has been removed from js loading list.";
this._keyboardDispatcher = keyboardDispatcher;
},

getAccelerometer:function () {
if(!cc.Accelerometer)
throw "cc.Accelerometer is undefined, maybe it has been removed from js loading list.";
return this._accelerometer;
},
setAccelerometer:function (accelerometer) {
if (this._accelerometer != accelerometer) {
if(!cc.Accelerometer)
throw "cc.Accelerometer is undefined, maybe it has been removed from js loading list.";
if (this._accelerometer != accelerometer)
this._accelerometer = accelerometer;
}
},

getDeltaTime:function(){
return this._deltaTime;
},

getMouseDispatcher:function () {
if(!cc.MouseDispatcher)
throw "cc.MouseDispatcher is undefined, maybe it has been removed from js loading list.";
return this._mouseDispatcher;
},

setMouseDispatcher:function (mouseDispatcher) {
if(!cc.MouseDispatcher)
throw "cc.MouseDispatcher is undefined, maybe it has been removed from js loading list.";
if (this._mouseDispatcher != mouseDispatcher)
this._mouseDispatcher = mouseDispatcher;
},
Expand Down
2 changes: 1 addition & 1 deletion cocos2d/CCScheduler.js
Expand Up @@ -164,7 +164,7 @@ cc.ArrayGetIndexOfObject = function (arr, findObj) {
* @return {Boolean}
*/
cc.ArrayContainsObject = function (arr, findObj) {
return cc.ArrayGetIndexOfObject(arr, findObj) != -1;
return arr.indexOf(findObj) != -1;
};

/**
Expand Down
2 changes: 1 addition & 1 deletion cocos2d/base_nodes/CCNode.js
Expand Up @@ -790,7 +790,7 @@ cc.Node = cc.Class.extend(/** @lends cc.Node# */{
/**
* Changes the tag that is used to identify the node easily. <br/>
* Please refer to getTag for the sample code.
* @param {Number} Var A interger that indentifies the node.
* @param {Number} Var A integer that identifies the node.
*/
setTag:function (Var) {
this._tag = Var;
Expand Down
1 change: 0 additions & 1 deletion cocos2d/build.xml
Expand Up @@ -28,7 +28,6 @@
<file name="platform/CCImage.js"/>
<file name="platform/zlib.min.js"/>
<file name="cocoa/CCNS.js"/>
<file name="cocoa/CCSet.js"/>
<file name="kazmath/vec2.js"/>
<file name="kazmath/vec3.js"/>
<file name="kazmath/vec4.js"/>
Expand Down
156 changes: 0 additions & 156 deletions cocos2d/cocoa/CCSet.js

This file was deleted.

0 comments on commit ad1d0b4

Please sign in to comment.