Skip to content

Commit

Permalink
Merge pull request #59 from SmallAiTT/master
Browse files Browse the repository at this point in the history
Issue #4294 : Add LoaderTest and PathTest into js-tests. Bind some api about constants into jsb.
  • Loading branch information
dingpinglv committed Mar 7, 2014
2 parents 6913e48 + 8358abf commit 5cc549f
Show file tree
Hide file tree
Showing 12 changed files with 309 additions and 267 deletions.
12 changes: 3 additions & 9 deletions build/cocos2d_jsb_samples.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
1A487B7618BF3EDF007EEB98 /* jsb_deprecated.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A487B4918BF3E7F007EEB98 /* jsb_deprecated.js */; };
1A487B7718BF3EDF007EEB98 /* jsb_opengl.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A487B4B18BF3E7F007EEB98 /* jsb_opengl.js */; };
1A487B7818BF3EDF007EEB98 /* jsb_opengl_constants.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A487B4A18BF3E7F007EEB98 /* jsb_opengl_constants.js */; };
1A487B7918BF3EDF007EEB98 /* jsb_sys.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A487B4C18BF3E7F007EEB98 /* jsb_sys.js */; };
1A487B7A18BF3EE9007EEB98 /* jsb.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A487B4D18BF3E7F007EEB98 /* jsb.js */; };
1A487B7B18BF3EE9007EEB98 /* jsb_chipmunk.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A487B4118BF3E7F007EEB98 /* jsb_chipmunk.js */; };
1A487B7C18BF3EE9007EEB98 /* jsb_chipmunk_constants.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A487B4018BF3E7F007EEB98 /* jsb_chipmunk_constants.js */; };
Expand All @@ -36,7 +35,6 @@
1A487B8418BF3EE9007EEB98 /* jsb_deprecated.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A487B4918BF3E7F007EEB98 /* jsb_deprecated.js */; };
1A487B8518BF3EE9007EEB98 /* jsb_opengl.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A487B4B18BF3E7F007EEB98 /* jsb_opengl.js */; };
1A487B8618BF3EE9007EEB98 /* jsb_opengl_constants.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A487B4A18BF3E7F007EEB98 /* jsb_opengl_constants.js */; };
1A487B8718BF3EE9007EEB98 /* jsb_sys.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A487B4C18BF3E7F007EEB98 /* jsb_sys.js */; };
1A604F3218BF1D4900CC9A93 /* res in Resources */ = {isa = PBXBuildFile; fileRef = 1A604F3018BF1D4900CC9A93 /* res */; };
1A604F3318BF1D4900CC9A93 /* res in Resources */ = {isa = PBXBuildFile; fileRef = 1A604F3018BF1D4900CC9A93 /* res */; };
1A604F3418BF1D4900CC9A93 /* src in Resources */ = {isa = PBXBuildFile; fileRef = 1A604F3118BF1D4900CC9A93 /* src */; };
Expand Down Expand Up @@ -93,7 +91,7 @@
A63D2EC718C856BE00B29B8F /* jsb_boot.js in Resources */ = {isa = PBXBuildFile; fileRef = A63D2EC618C856BE00B29B8F /* jsb_boot.js */; };
A63D2EC818C856BE00B29B8F /* jsb_boot.js in Resources */ = {isa = PBXBuildFile; fileRef = A63D2EC618C856BE00B29B8F /* jsb_boot.js */; };
A63D2ECE18C8B36600B29B8F /* jsb_loaders.js in Sources */ = {isa = PBXBuildFile; fileRef = A63D2ECD18C8B36600B29B8F /* jsb_loaders.js */; };
A63D2ECF18C8B36600B29B8F /* jsb_loaders.js in Sources */ = {isa = PBXBuildFile; fileRef = A63D2ECD18C8B36600B29B8F /* jsb_loaders.js */; };
A63D2ECF18C8B36600B29B8F /* jsb_loaders.js in Resources */ = {isa = PBXBuildFile; fileRef = A63D2ECD18C8B36600B29B8F /* jsb_loaders.js */; };
A63D2ED018C8B37100B29B8F /* jsb_loaders.js in Resources */ = {isa = PBXBuildFile; fileRef = A63D2ECD18C8B36600B29B8F /* jsb_loaders.js */; };
BA175BB418C5A2DA0040EA39 /* jsb_property_apis.js in Resources */ = {isa = PBXBuildFile; fileRef = BA175BAE18C5A2CA0040EA39 /* jsb_property_apis.js */; };
BA175BB518C5A2DA0040EA39 /* jsb_property_impls.js in Resources */ = {isa = PBXBuildFile; fileRef = BA175BAF18C5A2CA0040EA39 /* jsb_property_impls.js */; };
Expand Down Expand Up @@ -288,7 +286,6 @@
1A487B4918BF3E7F007EEB98 /* jsb_deprecated.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = jsb_deprecated.js; path = "../frameworks/js-bindings/bindings/script/jsb_deprecated.js"; sourceTree = "<group>"; };
1A487B4A18BF3E7F007EEB98 /* jsb_opengl_constants.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = jsb_opengl_constants.js; path = "../frameworks/js-bindings/bindings/script/jsb_opengl_constants.js"; sourceTree = "<group>"; };
1A487B4B18BF3E7F007EEB98 /* jsb_opengl.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = jsb_opengl.js; path = "../frameworks/js-bindings/bindings/script/jsb_opengl.js"; sourceTree = "<group>"; };
1A487B4C18BF3E7F007EEB98 /* jsb_sys.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = jsb_sys.js; path = "../frameworks/js-bindings/bindings/script/jsb_sys.js"; sourceTree = "<group>"; };
1A487B4D18BF3E7F007EEB98 /* jsb.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = jsb.js; path = "../frameworks/js-bindings/bindings/script/jsb.js"; sourceTree = "<group>"; };
1A604F0218BF1D1C00CC9A93 /* cocos2d_libs.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2d_libs.xcodeproj; path = "../frameworks/js-bindings/cocos2d-x/build/cocos2d_libs.xcodeproj"; sourceTree = "<group>"; };
1A604F2518BF1D2000CC9A93 /* cocos2d_js_bindings.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2d_js_bindings.xcodeproj; path = "../frameworks/js-bindings/bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -419,7 +416,6 @@
1A487B4918BF3E7F007EEB98 /* jsb_deprecated.js */,
1A487B4B18BF3E7F007EEB98 /* jsb_opengl.js */,
1A487B4A18BF3E7F007EEB98 /* jsb_opengl_constants.js */,
1A487B4C18BF3E7F007EEB98 /* jsb_sys.js */,
);
name = "JS Common";
sourceTree = "<group>";
Expand Down Expand Up @@ -752,7 +748,6 @@
1A487B8418BF3EE9007EEB98 /* jsb_deprecated.js in Resources */,
1A487B8518BF3EE9007EEB98 /* jsb_opengl.js in Resources */,
1A487B8618BF3EE9007EEB98 /* jsb_opengl_constants.js in Resources */,
1A487B8718BF3EE9007EEB98 /* jsb_sys.js in Resources */,
1A604F5518BF1D6000CC9A93 /* Icon-57.png in Resources */,
1A604F5218BF1D6000CC9A93 /* Icon-120.png in Resources */,
1A604F3318BF1D4900CC9A93 /* res in Resources */,
Expand All @@ -767,6 +762,7 @@
1A604F5418BF1D6000CC9A93 /* Icon-152.png in Resources */,
1A604F4F18BF1D6000CC9A93 /* Default.png in Resources */,
A63D2EC818C856BE00B29B8F /* jsb_boot.js in Resources */,
A63D2ECF18C8B36600B29B8F /* jsb_loaders.js in Resources */,
BAA7DEE518C84F5000D9A10E /* main.js in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand All @@ -775,7 +771,6 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
A63D2ED018C8B37100B29B8F /* jsb_loaders.js in Resources */,
BAA7DEDE18C7560500D9A10E /* jsb_create_apis.js in Resources */,
BA175BB418C5A2DA0040EA39 /* jsb_property_apis.js in Resources */,
BA175BB518C5A2DA0040EA39 /* jsb_property_impls.js in Resources */,
Expand All @@ -793,13 +788,13 @@
1A487B7618BF3EDF007EEB98 /* jsb_deprecated.js in Resources */,
1A487B7718BF3EDF007EEB98 /* jsb_opengl.js in Resources */,
1A487B7818BF3EDF007EEB98 /* jsb_opengl_constants.js in Resources */,
1A487B7918BF3EDF007EEB98 /* jsb_sys.js in Resources */,
1A604F3218BF1D4900CC9A93 /* res in Resources */,
1A604F6418BF1D6600CC9A93 /* InfoPlist.strings in Resources */,
1A604F6618BF1D6600CC9A93 /* Icon.icns in Resources */,
1A487B4E18BF3E7F007EEB98 /* debugger in Resources */,
1A604F3418BF1D4900CC9A93 /* src in Resources */,
1A604F6518BF1D6600CC9A93 /* MainMenu.xib in Resources */,
A63D2ED018C8B37100B29B8F /* jsb_loaders.js in Resources */,
A63D2EC718C856BE00B29B8F /* jsb_boot.js in Resources */,
BAA7DEE418C84F5000D9A10E /* main.js in Resources */,
);
Expand All @@ -816,7 +811,6 @@
1A604F3A18BF1D5600CC9A93 /* AppDelegate.cpp in Sources */,
1A604F5918BF1D6000CC9A93 /* main.m in Sources */,
1A604F4D18BF1D6000CC9A93 /* AppController.mm in Sources */,
A63D2ECF18C8B36600B29B8F /* jsb_loaders.js in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
2 changes: 1 addition & 1 deletion frameworks/cocos2d-html5
6 changes: 3 additions & 3 deletions frameworks/js-bindings/bindings/script/jsb_boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ cc._initDebugSetting = function (mode) {
if(mode != ccGame.DEBUG_MODE_ERROR && mode != ccGame.DEBUG_MODE_ERROR_FOR_WEB_PAGE){
cc.warn = bakLog.bind(cc);
}
if(mode == ccGame.DEBUG_MODE_LOG || mode == ccGame.DEBUG_MODE_LOG_FOR_WEB_PAGE){
if(mode == ccGame.DEBUG_MODE_INFO || mode == ccGame.DEBUG_MODE_INFO_FOR_WEB_PAGE){
cc.log = bakLog;
}
}
Expand All @@ -813,10 +813,10 @@ cc._initDebugSetting = function (mode) {
*/
cc.game = {
DEBUG_MODE_NONE : 0,
DEBUG_MODE_LOG : 1,
DEBUG_MODE_INFO : 1,
DEBUG_MODE_WARN : 2,
DEBUG_MODE_ERROR : 3,
DEBUG_MODE_LOG_FOR_WEB_PAGE : 4,
DEBUG_MODE_INFO_FOR_WEB_PAGE : 4,
DEBUG_MODE_WARN_FOR_WEB_PAGE : 5,
DEBUG_MODE_ERROR_FOR_WEB_PAGE : 6,

Expand Down
64 changes: 64 additions & 0 deletions frameworks/js-bindings/bindings/script/jsb_cocos2d.js
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,9 @@ var clearTimeout = clearInterval;
cc.director = cc.Director.getInstance();
cc.view = cc.director.getOpenGLView();
cc.audioEngine = cc.AudioEngine.getInstance();
cc.audioEngine.end = function(){
cc.AudioEngine.end();
};
cc.configuration = cc.Configuration.getInstance();
cc.textureCache = cc.director.getTextureCache();
cc.shaderCache = cc.ShaderCache.getInstance();
Expand Down Expand Up @@ -1082,3 +1085,64 @@ cc.FontDefinition = function () {
this.shadowBlur = 0;
this.shadowOpacity = 1.0;
};



/**
* Verify Array's Type
* @param {Array} arr
* @param {function} type
* @return {Boolean}
* @function
*/
cc.arrayVerifyType = function (arr, type) {
if (arr && arr.length > 0) {
for (var i = 0; i < arr.length; i++) {
if (!(arr[i] instanceof type)) {
cc.log("element type is wrong!");
return false;
}
}
}
return true;
};

/**
* Searches for the first occurance of object and removes it. If object is not found the function has no effect.
* @function
* @param {Array} arr Source Array
* @param {*} delObj remove object
*/
cc.arrayRemoveObject = function (arr, delObj) {
for (var i = 0, l = arr.length; i < l; i++) {
if (arr[i] == delObj) {
arr.splice(i, 1);
break;
}
}
};

/**
* Removes from arr all values in minusArr. For each Value in minusArr, the first matching instance in arr will be removed.
* @function
* @param {Array} arr Source Array
* @param {Array} minusArr minus Array
*/
cc.arrayRemoveArray = function (arr, minusArr) {
for (var i = 0, l = minusArr.length; i < l; i++) {
cc.arrayRemoveObject(arr, minusArr[i]);
}
};

/**
* Inserts some objects at index
* @function
* @param {Array} arr
* @param {Array} addObjs
* @param {Number} index
* @return {Array}
*/
cc.arrayAppendObjectsToIndex = function(arr, addObjs,index){
arr.splice.apply(arr, [index, 0].concat(addObjs));
return arr;
};
31 changes: 19 additions & 12 deletions frameworks/js-bindings/bindings/script/jsb_cocos2d_constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ cc.POSITION_TYPE_FREE = 0x0;
cc.POSITION_TYPE_GROUPED = 0x2;
cc.POSITION_TYPE_RELATIVE = 0x1;
cc.PRIORITY_NON_SYSTEM_MIN = -2147483647;
cc.PRIORITY_SYSTEM = -2147483648;
cc.PROGRESS_TIMER_TYPE_BAR = 0x1;
cc.PROGRESS_TIMER_TYPE_RADIAL = 0x0;
cc.REPEAT_FOREVER = 0xfffffffe;
Expand All @@ -93,17 +92,7 @@ cc.TMX_TILE_VERTICAL_FLAG = 0x40000000;
cc.TEXT_ALIGNMENT_CENTER = 0x1;
cc.TEXT_ALIGNMENT_LEFT = 0x0;
cc.TEXT_ALIGNMENT_RIGHT = 0x2;
cc.TEXTURE_2D_PIXEL_FORMAT_A8 = 0x3;
cc.TEXTURE_2D_PIXEL_FORMAT_AI88 = 0x5;
cc.TEXTURE_2D_PIXEL_FORMAT_DEFAULT = 0x0;
cc.TEXTURE_2D_PIXEL_FORMAT_I8 = 0x4;
cc.TEXTURE_2D_PIXEL_FORMAT_PVRTC2 = 0x9;
cc.TEXTURE_2D_PIXEL_FORMAT_PVRTC4 = 0x8;
cc.TEXTURE_2D_PIXEL_FORMAT_RGB565 = 0x2;
cc.TEXTURE_2D_PIXEL_FORMAT_RGB5A1 = 0x7;
cc.TEXTURE_2D_PIXEL_FORMAT_RGB888 = 0x1;
cc.TEXTURE_2D_PIXEL_FORMAT_RGBA4444 = 0x6;
cc.TEXTURE_2D_PIXEL_FORMAT_RGBA8888 = 0x0;

cc.TOUCHES_ALL_AT_ONCE = 0x0;
cc.TOUCHES_ONE_BY_ONE = 0x1;
cc.TRANSITION_ORIENTATION_DOWN_OVER = 0x1;
Expand Down Expand Up @@ -168,3 +157,21 @@ cc.UNIFORM_RANDOM01_S = 'CC_Random01';
cc.UNIFORM_SAMPLER_S = 'CC_Texture0';
cc.UNIFORM_SIN_TIME_S = 'CC_SinTime';
cc.UNIFORM_TIME_S = 'CC_Time';



cc.Scheduler.PRIORITY_SYSTEM = -2147483648;

var _Class = cc.Texture2D;
_Class.PIXEL_FORMAT_RGBA8888 = 0;
_Class.PIXEL_FORMAT_RGB888 = 1;
_Class.PIXEL_FORMAT_RGB565 = 2;
_Class.PIXEL_FORMAT_A8 = 3;
_Class.PIXEL_FORMAT_I8 = 4;
_Class.PIXEL_FORMAT_AI88 = 5;
_Class.PIXEL_FORMAT_RGBA4444 = 6;
_Class.PIXEL_FORMAT_RGB5A1 = 7;
_Class.PIXEL_FORMAT_PVRTC4 = 8;
_Class.PIXEL_FORMAT_PVRTC2 = 9;
_Class.PIXEL_FORMAT_DEFAULT = _Class.PIXEL_FORMAT_RGBA8888;
_Class.defaultPixelFormat = _Class.PIXEL_FORMAT_DEFAULT;
4 changes: 3 additions & 1 deletion samples/js-tests/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"src/tests_resources.js",
"src/tests-main.js",

"src/PathTest/PathTest.js",
"src/LoaderTest/LoaderTest.js",

"src/TouchesTest/Ball.js",
"src/TouchesTest/Paddle.js",
"src/TouchesTest/TouchesTest.js",
Expand Down Expand Up @@ -57,7 +60,6 @@
"src/EventTest/EventTest.js",
"src/UnitTest/UnitTest.js",
"src/SysTest/SysTest.js",
"src/FileTest/FileTest.js",
"src/EffectsTest/EffectsTest.js",
"src/EffectsAdvancedTest/EffectsAdvancedTest.js",
"src/MotionStreakTest/MotionStreakTest.js",
Expand Down
Loading

0 comments on commit 5cc549f

Please sign in to comment.