diff --git a/build/cocos2d_jsb_samples.xcodeproj/project.pbxproj b/build/cocos2d_jsb_samples.xcodeproj/project.pbxproj index e6b78b8365..a8284e4be1 100644 --- a/build/cocos2d_jsb_samples.xcodeproj/project.pbxproj +++ b/build/cocos2d_jsb_samples.xcodeproj/project.pbxproj @@ -1498,7 +1498,6 @@ FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(SRCROOT)/../frameworks/js-bindings/cocos2d-x/plugin/plugins/facebook/proj.ios", - "$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.0.sdk/System/Library/Frameworks", ); GCC_DYNAMIC_NO_PIC = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; @@ -1532,7 +1531,6 @@ FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(SRCROOT)/../frameworks/js-bindings/cocos2d-x/plugin/plugins/facebook/proj.ios", - "$(DEVELOPER_DIR)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.0.sdk/System/Library/Frameworks", ); GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_INLINES_ARE_PRIVATE_EXTERN = NO; diff --git a/frameworks/cocos2d-html5 b/frameworks/cocos2d-html5 index 86cf76b562..a7ce94a07e 160000 --- a/frameworks/cocos2d-html5 +++ b/frameworks/cocos2d-html5 @@ -1 +1 @@ -Subproject commit 86cf76b5627be037729f79520d46e86c46a1d102 +Subproject commit a7ce94a07eadeb3c3e19ef63a6158b8166ab7a00 diff --git a/frameworks/js-bindings/bindings/manual/ScriptingCore.h b/frameworks/js-bindings/bindings/manual/ScriptingCore.h index 8d56c6bcc2..50364a767b 100644 --- a/frameworks/js-bindings/bindings/manual/ScriptingCore.h +++ b/frameworks/js-bindings/bindings/manual/ScriptingCore.h @@ -39,7 +39,7 @@ #include #include -#define ENGINE_VERSION "Cocos2d-JS v3.4" +#define ENGINE_VERSION "Cocos2d-JS v3.5" void js_log(const char *format, ...); diff --git a/frameworks/js-bindings/bindings/script/jsb_cocos2d.js b/frameworks/js-bindings/bindings/script/jsb_cocos2d.js index bf9ded4bc5..621aa3ad89 100644 --- a/frameworks/js-bindings/bindings/script/jsb_cocos2d.js +++ b/frameworks/js-bindings/bindings/script/jsb_cocos2d.js @@ -26,7 +26,7 @@ // CCConfig.js // -cc.ENGINE_VERSION = "Cocos2d-JS v3.4"; +cc.ENGINE_VERSION = "Cocos2d-JS v3.5"; cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0; cc.DIRECTOR_STATS_POSITION = {x: 0, y: 0}; diff --git a/frameworks/js-bindings/cocos2d-x b/frameworks/js-bindings/cocos2d-x index a4548b8b06..b0f97059de 160000 --- a/frameworks/js-bindings/cocos2d-x +++ b/frameworks/js-bindings/cocos2d-x @@ -1 +1 @@ -Subproject commit a4548b8b06d837698d789b17f2cb9113523f1640 +Subproject commit b0f97059de5ccbb16327b558415c55ed9c33b583 diff --git a/templates/js-template-runtime/runtime/android/PrebuiltRuntimeJs.apk b/templates/js-template-runtime/runtime/android/PrebuiltRuntimeJs.apk index a9c124f9b8..9509cad4f2 100755 Binary files a/templates/js-template-runtime/runtime/android/PrebuiltRuntimeJs.apk and b/templates/js-template-runtime/runtime/android/PrebuiltRuntimeJs.apk differ diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Info.plist b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Info.plist index f45a6c18f1..eaa5519276 100755 Binary files a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Info.plist and b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/Info.plist differ diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/PrebuiltRuntimeJs iOS b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/PrebuiltRuntimeJs iOS index 8094192364..164099c79e 100755 Binary files a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/PrebuiltRuntimeJs iOS and b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/PrebuiltRuntimeJs iOS differ diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/3d/jsb_cocos2d_3d.js b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/3d/jsb_cocos2d_3d.js new file mode 100755 index 0000000000..7db2366c2e --- /dev/null +++ b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/3d/jsb_cocos2d_3d.js @@ -0,0 +1,256 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ +cc.CameraFlag = { + DEFAULT : 1, + USER1 : 1 << 1, + USER2 : 1 << 2, + USER3 : 1 << 3, + USER4 : 1 << 4, + USER5 : 1 << 5, + USER6 : 1 << 6, + USER7 : 1 << 7, + USER8 : 1 << 8 +}; + +cc.LightType = { + DIRECTIONAL : 0, + POINT : 1, + SPOT : 2, + AMBIENT : 3, +}; + +cc.LightFlag = { + LIGHT0 : 1, + LIGHT1 : 1 << 1, + LIGHT2 : 1 << 2, + LIGHT3 : 1 << 3, + LIGHT4 : 1 << 4, + LIGHT5 : 1 << 5, + LIGHT6 : 1 << 6, + LIGHT7 : 1 << 7, + LIGHT8 : 1 << 8, + LIGHT9 : 1 << 9, + LIGHT10 : 1 << 10, + LIGHT11 : 1 << 11, + LIGHT12 : 1 << 12, + LIGHT13 : 1 << 13, + LIGHT14 : 1 << 14, + LIGHT15 : 1 << 15, +}; + +cc.AsyncTaskPool.TaskType = { + TASK_IO : 0, + TASK_NETWORK : 1, + TASK_OTHER : 2, + TASK_MAX_TYPE : 3 +}; + +jsb.BillBoard.Mode = { + VIEW_POINT_ORIENTED : 0, // orient to the camera + VIEW_PLANE_ORIENTED : 1 // orient to the XOY plane of camera +}; + +cc.attributeNames = [cc.ATTRIBUTE_NAME_POSITION, + cc.ATTRIBUTE_NAME_COLOR, + cc.ATTRIBUTE_NAME_TEX_COORD, + cc.ATTRIBUTE_NAME_TEX_COORD1, + cc.ATTRIBUTE_NAME_TEX_COORD2, + cc.ATTRIBUTE_NAME_TEX_COORD3, + cc.ATTRIBUTE_NAME_NORMAL, + cc.ATTRIBUTE_NAME_BLEND_WEIGHT, + cc.ATTRIBUTE_NAME_BLEND_INDEX]; + +cc.math = cc.math || {}; + +cc.math.Vec3 = function(x=0, y=0, z=0){ + this.x = x; + this.y = y; + this.z = z; +}; + +cc.math.Vec3.prototype.normalize = function(){ + var n = this.x * this.x + this.y * this.y + this.z * this.z; + n = 1 / Math.sqrt(n); + this.x *= n; + this.y *= n; + this.z *= n; +}; + +cc.math.vec3 = function(x, y, z){ + return new cc.math.Vec3(x, y, z); +}; + +cc.math.vec3Cross = function(v1, v2){ + return new cc.math.Vec3(v1.y * v2.z - v1.z * v2.y, + v1.z * v2.x - v1.x * v2.z, + v1.x * v2.y - v1.y * v2.x); +}; + +cc.math.vec3Dot = function(v1, v2){ + return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z; +}; + +cc.math.vec3Length = function(v){ + return Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z); +}; + +cc.math.vec3Normalize = function(v){ + var n = v.x * v.x + v.y * v.y + v.z * v.z; + n = 1 / Math.sqrt(n); + return cc.math.vec3(v.x * n, v.y * n, v.z * n); +}; + +cc.math.vec3Add = function(v1, v2){ + return new cc.math.Vec3(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z); +}; + +cc.math.vec3Sub = function(v1, v2){ + return new cc.math.Vec3(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z); +}; + +cc.math.Quaternion = function(x=0, y=0, z=0, w=0){ + this.x = x; + this.y = y; + this.z = z; + this.w = w; +}; + +cc.math.quaternion = function(xOrAxis, yOrAngle, z, w){ + if(w !== undefined){ + return new cc.math.Quaternion(xOrAxis, yOrAngle, z, w); + } + else if(yOrAngle !== undefined){ + var sinHalfAngle = Math.sin(yOrAngle / 2); + var normal = cc.math.vec3(xOrAxis.x, xOrAxis.y, xOrAxis.z); + normal.normalize(); + return cc.math.quaternion(normal.x * sinHalfAngle, normal.y * sinHalfAngle, normal.z * sinHalfAngle, Math.cos(yOrAngle / 2)); + } +}; + +cc.math.AABB = function(min=cc.math.vec3(99999, 99999, 99999), max=cc.math.vec3(-99999, -99999, -99999)){ + this.min = min; + this.max = max; +}; + +cc.math.aabb = function(min, max){ + return new cc.math.AABB(min, max); +}; + +cc.math.aabbGetCorners = function(aabb){ + var corners = new Array(8); + corners[0] = cc.math.vec3(aabb.min.x, aabb.max.y, aabb.max.z); + corners[1] = cc.math.vec3(aabb.min.x, aabb.min.y, aabb.max.z); + corners[2] = cc.math.vec3(aabb.max.x, aabb.min.y, aabb.max.z); + corners[3] = cc.math.vec3(aabb.max.x, aabb.max.y, aabb.max.z); + + corners[4] = cc.math.vec3(aabb.max.x, aabb.max.y, aabb.min.z); + corners[5] = cc.math.vec3(aabb.max.x, aabb.min.y, aabb.min.z); + corners[6] = cc.math.vec3(aabb.min.x, aabb.min.y, aabb.min.z); + corners[7] = cc.math.vec3(aabb.min.x, aabb.max.y, aabb.min.z); + return corners; +}; + +cc.math.OBB = function(aabb){ + this.center = cc.math.vec3((aabb.min.x + aabb.max.x)/2, (aabb.min.y + aabb.max.y)/2, (aabb.min.z + aabb.max.z)/2); // obb center + this.xAxis = cc.math.vec3(1, 0, 0); // x axis of obb, unit vector + this.yAxis = cc.math.vec3(0, 1, 0); // y axis of obb, unit vecotr + this.zAxis = cc.math.vec3(0, 0, 1); // z axis of obb, unit vector + this.extents = cc.math.vec3((aabb.max.x - aabb.min.x)/2, (aabb.max.y - aabb.min.y)/2, (aabb.max.z - aabb.min.z)/2); // obb length along each axis + this.extentX = cc.math.vec3((aabb.max.x - aabb.min.x)/2, 0, 0); // _xAxis * _extents.x + this.extentY = cc.math.vec3(0, (aabb.max.y - aabb.min.y)/2, 0); // _yAxis * _extents.y + this.extentZ = cc.math.vec3(0, 0, (aabb.max.z - aabb.min.z)/2); // _zAxis * _extents.z +}; + +cc.math.obb = function(aabb){ + return new cc.math.OBB(aabb); +}; + +cc.math.Ray = function(origin = cc.math.vec3(0, 0, 0), direction = cc.math.vec3(0, 0, 1)){ + this.origin = origin; + this.direction = direction; +}; + +cc.math.ray = function(origin, direction){ + return new cc.math.Ray(origin, direction); +}; + +cc.math.Vec4 = cc.math.Quaternion; + +cc.math.vec4 = function(x, y, z, w){ + return new cc.math.Vec4(x, y, z, w); +}; + +jsb.sprite3DCache = jsb.Sprite3DCache.getInstance(); + +jsb.Sprite3D.extend = cc.Class.extend; + +jsb.Sprite3D.prototype._setBlendFunc = jsb.Sprite3D.prototype.setBlendFunc; +jsb.Sprite3D.prototype.setBlendFunc = templateSetBlendFunc; + +jsb.Mesh.prototype._setBlendFunc = jsb.Mesh.prototype.setBlendFunc; +jsb.Mesh.prototype.setBlendFunc = templateSetBlendFunc; + +jsb.Sprite3D.prototype._ctor = function(modelPath, texturePath){ + if(modelPath === undefined){ + this.init(); + }else{ + if(modelPath.length < 4){ + cc.log("invalid filename for Sprite3D"); + return; + } + this.initWithFile(modelPath); + var bb = this.getBoundingBox(); + this.setContentSize(cc.size(bb.width, bb.height)); + + if(texturePath !== undefined) + this.setTexture(texturePath); + } +}; + +jsb.BillBoard.prototype._ctor = function(filename, rect, mode = jsb.BillBoard.Mode.VIEW_POINT_ORIENTED){ + if(filename !== undefined && filename instanceof cc.Texture2D){ + rect = rect || jsb.BillBoard.Mode.VIEW_POINT_ORIENTED; + this.initWithTexture(filename); + this.setMode(rect); + }else if(filename !== undefined && typeof filename === "string"){ + if(rect !== undefined){ + if(typeof rect === "object"){ + this.initWithFile(filename, rect); + this.setMode(mode); + }else{ + this.initWithFile(filename); + this.setMode(rect); + } + }else{ + this.initWithFile(filename); + this.setMode(jsb.BillBoard.Mode.VIEW_POINT_ORIENTED); + } + }else{ + filename = filename || jsb.BillBoard.Mode.VIEW_POINT_ORIENTED; + this.init(); + this.setMode(filename); + } +} \ No newline at end of file diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/3d/jsb_cocos2d_3d_ext.js b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/3d/jsb_cocos2d_3d_ext.js new file mode 100755 index 0000000000..653e88fdbe --- /dev/null +++ b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/3d/jsb_cocos2d_3d_ext.js @@ -0,0 +1,28 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +jsb.ParticleSystem3D.prototype._setBlendFunc = jsb.ParticleSystem3D.prototype.setBlendFunc; +jsb.ParticleSystem3D.prototype.setBlendFunc = templateSetBlendFunc; \ No newline at end of file diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/jsb.js b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/jsb.js index 97db22e7ac..1ae745a3c5 100755 --- a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/jsb.js +++ b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/jsb.js @@ -129,3 +129,11 @@ if (jsb.fileUtils.isFileExist('jsb_pluginx.js')) { if (window.sp) { require('script/jsb_spine.js'); } + +if (jsb.Sprite3D){ + require('script/3d/jsb_cocos2d_3d.js'); +} + +if (jsb.ParticleSystem3D) { + require('script/3d/jsb_cocos2d_3d_ext.js'); +} \ No newline at end of file diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/jsb_boot.js b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/jsb_boot.js index 9e85eeb6ad..33d2653645 100755 --- a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/jsb_boot.js +++ b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/jsb_boot.js @@ -101,7 +101,8 @@ cc.isString = function(obj) { * @returns {boolean} */ cc.isArray = function(obj) { - return Object.prototype.toString.call(obj) == '[object Array]'; + return Array.isArray(obj) || + (typeof obj === 'object' && objectToString(obj) === '[object Array]'); }; /** @@ -110,7 +111,7 @@ cc.isArray = function(obj) { * @returns {boolean} */ cc.isUndefined = function(obj) { - return typeof obj == 'undefined'; + return typeof obj === 'undefined'; }; /** @@ -119,9 +120,8 @@ cc.isUndefined = function(obj) { * @returns {boolean} */ cc.isObject = function(obj) { - var type = typeof obj; - - return type == 'function' || (obj && type == 'object'); + return obj.__nativeObj !== undefined || + ( typeof obj === "object" && Object.prototype.toString.call(obj) === '[object Object]' ); }; /** @@ -574,10 +574,11 @@ cc.loader = { }); } else { - var tex = cc.textureCache._addImage(url); - if (tex instanceof cc.Texture2D) - cb && cb(null, tex); - else cb && cb("Load image failed"); + cc.textureCache._addImageAsync(url, function (tex){ + if (tex instanceof cc.Texture2D) + cb && cb(null, tex); + else cb && cb("Load image failed"); + }); } }, /** @@ -932,8 +933,8 @@ cc.configuration = cc.Configuration.getInstance(); * cc.textureCache is the global cache for cc.Texture2D */ cc.textureCache = cc.director.getTextureCache(); -cc.TextureCache.prototype._addImage = cc.TextureCache.prototype.addImage; -cc.TextureCache.prototype.addImage = function(url, cb, target) { +cc.TextureCache.prototype._addImageAsync = cc.TextureCache.prototype.addImageAsync; +cc.TextureCache.prototype.addImageAsync = function(url, cb, target) { var localTex = null; cc.loader.loadImg(url, function(err, tex) { if (err) tex = null; @@ -944,6 +945,21 @@ cc.TextureCache.prototype.addImage = function(url, cb, target) { }); return localTex; }; +// Fix for compatibility with old APIs +cc.TextureCache.prototype._addImage = cc.TextureCache.prototype.addImage; +cc.TextureCache.prototype.addImage = function(url, cb, target) { + if (typeof cb === "function") { + return this.addImageAsync(url, cb, target); + } + else { + if (cb) { + return this._addImage(url, cb) + } + else { + return this._addImage(url); + } + } +}; /** * @type {Object} * @name cc.shaderCache @@ -1158,117 +1174,204 @@ cc._initSys = function(config, CONFIG_KEY){ */ locSys.LANGUAGE_POLISH = "pl"; - /** + * @memberof cc.sys + * @name OS_IOS * @constant - * @default * @type {string} */ - locSys.OS_WINDOWS = "Windows"; + sys.OS_IOS = "iOS"; /** + * @memberof cc.sys + * @name OS_ANDROID * @constant - * @default * @type {string} */ - locSys.OS_IOS = "iOS"; + sys.OS_ANDROID = "Android"; /** + * @memberof cc.sys + * @name OS_WINDOWS * @constant - * @default * @type {string} */ - locSys.OS_OSX = "OS X"; + sys.OS_WINDOWS = "Windows"; /** + * @memberof cc.sys + * @name OS_MARMALADE * @constant - * @default * @type {string} */ - locSys.OS_UNIX = "UNIX"; + sys.OS_MARMALADE = "Marmalade"; /** + * @memberof cc.sys + * @name OS_LINUX * @constant - * @default * @type {string} */ - locSys.OS_LINUX = "Linux"; + sys.OS_LINUX = "Linux"; /** + * @memberof cc.sys + * @name OS_BADA * @constant - * @default * @type {string} */ - locSys.OS_ANDROID = "Android"; - locSys.OS_UNKNOWN = "unknown"; + sys.OS_BADA = "Bada"; + /** + * @memberof cc.sys + * @name OS_BLACKBERRY + * @constant + * @type {string} + */ + sys.OS_BLACKBERRY = "Blackberry"; + /** + * @memberof cc.sys + * @name OS_OSX + * @constant + * @type {string} + */ + sys.OS_OSX = "OS X"; + /** + * @memberof cc.sys + * @name OS_WP8 + * @constant + * @type {string} + */ + sys.OS_WP8 = "WP8"; + /** + * @memberof cc.sys + * @name OS_WINRT + * @constant + * @type {string} + */ + sys.OS_WINRT = "WINRT"; + /** + * @memberof cc.sys + * @name OS_UNKNOWN + * @constant + * @type {string} + */ + sys.OS_UNKNOWN = "Unknown"; /** + * @memberof cc.sys + * @name UNKNOWN + * @constant + * @default + * @type {Number} + */ + sys.UNKNOWN = 0; + /** + * @memberof cc.sys + * @name IOS * @constant * @default * @type {Number} */ - locSys.WINDOWS = 0; + sys.IOS = 1; /** + * @memberof cc.sys + * @name ANDROID * @constant * @default * @type {Number} */ - locSys.LINUX = 1; + sys.ANDROID = 2; /** + * @memberof cc.sys + * @name WIN32 * @constant * @default * @type {Number} */ - locSys.MACOS = 2; + sys.WIN32 = 3; /** + * @memberof cc.sys + * @name MARMALADE * @constant * @default * @type {Number} */ - locSys.ANDROID = 3; + sys.MARMALADE = 4; /** + * @memberof cc.sys + * @name LINUX * @constant * @default * @type {Number} */ - locSys.IPHONE = 4; + sys.LINUX = 5; /** + * @memberof cc.sys + * @name BADA * @constant * @default * @type {Number} */ - locSys.IPAD = 5; + sys.BADA = 6; /** + * @memberof cc.sys + * @name BLACKBERRY * @constant * @default * @type {Number} */ - locSys.BLACKBERRY = 6; + sys.BLACKBERRY = 7; /** + * @memberof cc.sys + * @name MACOS * @constant * @default * @type {Number} */ - locSys.NACL = 7; + sys.MACOS = 8; /** + * @memberof cc.sys + * @name NACL * @constant * @default * @type {Number} */ - locSys.EMSCRIPTEN = 8; + sys.NACL = 9; /** + * @memberof cc.sys + * @name EMSCRIPTEN * @constant * @default * @type {Number} */ - locSys.TIZEN = 9; + sys.EMSCRIPTEN = 10; /** + * @memberof cc.sys + * @name TIZEN * @constant * @default * @type {Number} */ - locSys.WINRT = 10; + sys.TIZEN = 11; /** + * @memberof cc.sys + * @name QT5 * @constant * @default * @type {Number} */ - locSys.WP8 = 11; + sys.QT5 = 12; + /** + * @memberof cc.sys + * @name WP8 + * @constant + * @default + * @type {Number} + */ + sys.WP8 = 13; + /** + * @memberof cc.sys + * @name WINRT + * @constant + * @default + * @type {Number} + */ + sys.WINRT = 14; /** * @constant * @default @@ -1346,7 +1449,7 @@ cc._initSys = function(config, CONFIG_KEY){ cc.log(str); } - locSys.isMobile = (locSys.os == locSys.OS_ANDROID || locSys.os == locSys.OS_IOS) ? true : false; + locSys.isMobile = (locSys.os == locSys.OS_ANDROID || locSys.os == locSys.OS_IOS || locSys.os == locSys.OS_WP8 || locSys.os == locSys.OS_WINRT) ? true : false; locSys.language = (function(){ var language = cc.Application.getInstance().getCurrentLanguage(); @@ -1382,6 +1485,16 @@ cc._initSys = function(config, CONFIG_KEY){ capabilities["keyboard"] = true; capabilities["mouse"] = true; } + + /** + * Open a url in browser + * @memberof cc.sys + * @name openURL + * @param {String} url + */ + locSys.openURL = function(url){ + cc.Application.getInstance().openURL(url); + } }; //+++++++++++++++++++++++++something about sys end+++++++++++++++++++++++++++++ diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/jsb_cocos2d.js b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/jsb_cocos2d.js index 167af32d09..621aa3ad89 100755 --- a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/jsb_cocos2d.js +++ b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/jsb_cocos2d.js @@ -26,7 +26,7 @@ // CCConfig.js // -cc.ENGINE_VERSION = "Cocos2d-JS v3.3 RC0"; +cc.ENGINE_VERSION = "Cocos2d-JS v3.5"; cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0; cc.DIRECTOR_STATS_POSITION = {x: 0, y: 0}; @@ -2172,7 +2172,6 @@ var templateSetBlendFunc = function(src, dst) { else blendf = {src: src, dst: dst}; this._setBlendFunc(blendf); - var b = this.getBlendFunc(); }; for (var i = 0, l = protoHasBlend.length; i < l; i++) { var proto = protoHasBlend[i]; @@ -2800,3 +2799,27 @@ cc.LabelTTF.prototype.setDimensions = function (dim, height) { } this._setDimensions(dim); }; + + +// +// Label adaptation to LabelTTF/LabelBMFont/LabelAtlas +// +_p = cc.Label.prototype; +_p.enableStroke = _p.enableOutline; +_p.setBoundingWidth = _p.setWidth; +_p.setBoundingHeight = _p.setHeight; + + +// +// 3D module rename to jsb namespace +// +jsb.BaseLight = cc.BaseLight; +delete cc.BaseLight; +jsb.DirectionLight = cc.DirectionLight; +delete cc.DirectionLight; +jsb.PointLight = cc.PointLight; +delete cc.PointLight; +jsb.SpotLight = cc.SpotLight; +delete cc.SpotLight; +jsb.AmbientLight = cc.AmbientLight; +delete cc.AmbientLight; diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/jsb_cocos2d_constants.js b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/jsb_cocos2d_constants.js index 5a0b860202..42bff9663e 100755 --- a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/jsb_cocos2d_constants.js +++ b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/jsb_cocos2d_constants.js @@ -133,3 +133,9 @@ cc.CHIPMUNK_IMPORT = 'chipmunk.h'; cc.ATTRIBUTE_NAME_COLOR = 'a_color'; cc.ATTRIBUTE_NAME_POSITION = 'a_position'; cc.ATTRIBUTE_NAME_TEX_COORD = 'a_texCoord'; +cc.ATTRIBUTE_NAME_TEX_COORD1 = "a_texCoord1"; +cc.ATTRIBUTE_NAME_TEX_COORD2 = "a_texCoord2"; +cc.ATTRIBUTE_NAME_TEX_COORD3 = "a_texCoord3"; +cc.ATTRIBUTE_NAME_NORMAL = "a_normal"; +cc.ATTRIBUTE_NAME_BLEND_WEIGHT = "a_blendWeight"; +cc.ATTRIBUTE_NAME_BLEND_INDEX = "a_blendIndex"; diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/jsb_create_apis.js b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/jsb_create_apis.js index 7b0dab4c3c..5048a2dfb7 100755 --- a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/jsb_create_apis.js +++ b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/jsb_create_apis.js @@ -47,12 +47,16 @@ _p._ctor = function(color, w, h) { _p = cc.LayerGradient.prototype; -_p._ctor = function(start, end, v) { +_p._ctor = function(start, end, v, colorStops) { start = start || cc.color(0,0,0,255); end = end || cc.color(0,0,0,255); v = v || cc.p(0, -1); this.initWithColor(start, end, v); + + if (colorStops instanceof Array) { + cc.log("Warning: Color stops parameter is not supported in JSB."); + } }; @@ -232,8 +236,14 @@ _p._ctor = function(normalImage, selectedImage, three, four, five) { callback = three; } else if (five === undefined) { - callback = three; - target = four; + if (typeof three === "function") { + callback = three; + target = four; + } + else { + disabledImage = three; + callback = four; + } } else if (five) { disabledImage = three; @@ -297,8 +307,10 @@ _p._ctor = function(plistFile){ if (!plistFile || typeof(plistFile) === "number") { var ton = plistFile || 100; this.initWithTotalParticles(ton); - } else if (plistFile) { + } else if ( typeof plistFile === "string") { this.initWithFile(plistFile); + } else if(plistFile){ + this.initWithDictionary(plistFile); } }; @@ -802,7 +814,11 @@ cc.Touch.prototype._ctor = function(x, y, id) { }; cc.GLProgram.prototype._ctor = function(vShaderFileName, fShaderFileName) { - vShaderFileName !== undefined && fShaderFileName !== undefined && cc.GLProgram.prototype.init.call(this, vShaderFileName, fShaderFileName); + if(vShaderFileName !== undefined && fShaderFileName !== undefined){ + cc.GLProgram.prototype.init.call(this, vShaderFileName, fShaderFileName); + cc.GLProgram.prototype.link.call(this); + cc.GLProgram.prototype.updateUniforms.call(this); + } }; @@ -1004,7 +1020,7 @@ cc.ParticleSystem.create = function(plistFile){ var particleSystem =null; if (typeof(plistFile) === "number") { particleSystem = cc.ParticleSystem.createWithTotalParticles(plistFile); - }else if(typeof(plistFile) === "string"){ + }else if(typeof(plistFile) === "string" || typeof(plistFile) === "object"){ particleSystem = cc.ParticleSystem._create(plistFile); } return particleSystem; diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/jsb_loaders.js b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/jsb_loaders.js index 9503e9652f..035e910672 100755 --- a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/jsb_loaders.js +++ b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/jsb_loaders.js @@ -26,6 +26,18 @@ // This helper file should be required after jsb_cocos2d.js // +cc._emptyLoader = { + load : function(realUrl, url){ + return null; + } +}; + +cc.loader.register([ + "mp3", "ogg", "wav", "mp4", "m4a", + "font", "eot", "ttf", "woff", "svg" + ], + cc._emptyLoader); + cc._txtLoader = { load : function(realUrl, url){ return jsb.fileUtils.getStringFromFile(realUrl); @@ -68,13 +80,6 @@ cc._plistLoader = { }; cc.loader.register(["plist"], cc._plistLoader); -cc._fontLoader = { - load : function(realUrl, url){ - return null; - } -}; -cc.loader.register(["font", "eot", "ttf", "woff", "svg"], cc._fontLoader); - cc._binaryLoader = { load : function(realUrl, url){ return cc.loader.loadBinarySync(realUrl); diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/jsb_property_apis.js b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/jsb_property_apis.js index c50f4b9f87..e80bc6aa33 100755 --- a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/jsb_property_apis.js +++ b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/jsb_property_apis.js @@ -43,6 +43,13 @@ cc.defineGetterSetter(_proto, "opacity", _proto.getOpacity, _proto.setOpacity); cc.defineGetterSetter(_proto, "opacityModifyRGB", _proto.isOpacityModifyRGB, _proto.setOpacityModifyRGB); cc.defineGetterSetter(_proto, "color", _proto.getColor, _proto.setColor); +_proto = cc.Label.prototype; +cc.defineGetterSetter(_proto, "size", _proto.getContentSize, _proto.setContentSize); +cc.defineGetterSetter(_proto, "width", _proto._getWidth, _proto._setWidth); +cc.defineGetterSetter(_proto, "height", _proto._getHeight, _proto._setHeight); +cc.defineGetterSetter(_proto, "boundingWidth", _proto.getWidth, _proto.setWidth); +cc.defineGetterSetter(_proto, "boundingHeight", _proto.getHeight, _proto.setHeight); + _proto = cc.LabelTTF.prototype; cc.defineGetterSetter(_proto, "size", _proto.getContentSize, _proto.setContentSize); cc.defineGetterSetter(_proto, "width", _proto._getWidth, _proto._setWidth); @@ -260,6 +267,7 @@ _proto = cc.LabelBMFont.prototype; cc.defineGetterSetter(_proto, "string", _proto.getString, _proto._setStringForSetter); cc.defineGetterSetter(_proto, "textAlign", _proto._getAlignment, _proto.setAlignment); cc.defineGetterSetter(_proto, "boundingWidth", _proto._getBoundingWidth, _proto.setBoundingWidth); +cc.defineGetterSetter(_proto, "boundingHeight", _proto._getBoundingHeight, _proto.setBoundingHeight); _proto = cc.Menu.prototype; cc.defineGetterSetter(_proto, "enabled", _proto.getEnabled, _proto.setEnabled); diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/studio/jsb_cocos2d_studio.js b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/studio/jsb_cocos2d_studio.js index 7fec49dc03..71f1a443d5 100755 --- a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/studio/jsb_cocos2d_studio.js +++ b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/studio/jsb_cocos2d_studio.js @@ -63,6 +63,9 @@ if(ccs.Armature){ ccs.Armature.extend = cc.Class.extend; } +ccs.Armature.prototype._setBlendFunc = ccs.Armature.prototype.setBlendFunc; +ccs.Armature.prototype.setBlendFunc = templateSetBlendFunc; + ccs.sendEvent = function (event) { var triggerObjArr = ccs.triggerManager.get(event); diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/studio/jsb_studio_create_apis.js b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/studio/jsb_studio_create_apis.js index 1f7f7fd091..55ee7b08ac 100755 --- a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/studio/jsb_studio_create_apis.js +++ b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/studio/jsb_studio_create_apis.js @@ -96,5 +96,8 @@ ccs.ActionTimelineData.prototype._ctor = function(actionTag) { { ccs.ActionTimelineData.prototype.init.call(this,actionTag); } +}; +ccs.ObjectExtensionData.prototype._ctor = function() { + ccs.ObjectExtensionData.prototype.init.call(this); }; \ No newline at end of file diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/studio/jsb_studio_load.js b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/studio/jsb_studio_load.js index 4a46b956b7..8578034ee0 100755 --- a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/studio/jsb_studio_load.js +++ b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/studio/jsb_studio_load.js @@ -26,11 +26,12 @@ ccs._load = (function(){ /** * load file - * @param file - * @param type - ccui|node|action + * @param {String} file + * @param {String} [type=] - ccui|node|action + * @param {String} [path=] - Resource search path * @returns {*} */ - var load = function(file, type){ + var load = function(file, type, path){ var json = cc.loader.getRes(file); @@ -71,7 +72,7 @@ ccs._load = (function(){ return new cc.Node(); } - return currentParser.parse(file, json) || null; + return currentParser.parse(file, json, path) || null; }; var parser = { @@ -176,16 +177,17 @@ ccs._parser = cc.Class.extend({ * action 1.* - 2.* * scene 0.* - 1.* * @param {String} file + * @param {String} [path=] Resource path * @returns {{node: cc.Node, action: cc.Action}} */ -ccs.load = function(file){ +ccs.load = function(file, path){ var object = { node: null, action: null }; - object.node = ccs._load(file); - object.action = ccs._load(file, "action"); + object.node = ccs._load(file, null, path); + object.action = ccs._load(file, "action", path); if(object.action && object.action.tag === -1 && object.node) object.action.tag = object.node.tag; return object; diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/studio/parsers/action-2.x.js b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/studio/parsers/action-2.x.js index 56e83c834d..555ec76181 100755 --- a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/studio/parsers/action-2.x.js +++ b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/studio/parsers/action-2.x.js @@ -230,6 +230,10 @@ var singleFrameIndex = options["SingleFrameIndex"]; + var frameIndex = options["FrameIndex"]; + if(frameIndex !== undefined) + frame.setFrameIndex(frameIndex); + frame.setInnerActionType(ccs.InnerActionType[innerActionType]); frame.setSingleFrameIndex(singleFrameIndex); diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/studio/parsers/timelineParser-2.x.js b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/studio/parsers/timelineParser-2.x.js index 786ed9e867..6b5ab6ed54 100755 --- a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/studio/parsers/timelineParser-2.x.js +++ b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/studio/parsers/timelineParser-2.x.js @@ -28,8 +28,12 @@ var Parser = baseParser.extend({ - parse: function(file, json){ - var resourcePath = this._dirname(file); + parse: function(file, json, path){ + var resourcePath; + if(path !== undefined) + resourcePath = path; + else + resourcePath = this._dirname(file); this.pretreatment(json, resourcePath, file); var node = this.parseNode(this.getNodeJson(json), resourcePath); this.deferred(json, resourcePath, node, file); @@ -102,12 +106,22 @@ setContentSize(node, json["Size"]); - if (json["Alpha"] != null) + if (json["Alpha"] !== undefined) node.setOpacity(json["Alpha"]); node.setTag(json["Tag"] || 0); - node.setUserObject(new ccs.ActionTimelineData(json["ActionTag"] || 0)); + var actionTag = json["ActionTag"] || 0; + if (cc.sys.isNative){ + var extensionData = new ccs.ObjectExtensionData(); + var customProperty = json["UserData"]; + if(customProperty !== undefined) + extensionData.setCustomProperty(customProperty); + extensionData.setActionTag(actionTag); + node.setUserObject(extensionData); + } else { + node.setUserObject(new ccs.ActionTimelineData(actionTag)); + } node.setCascadeColorEnabled(true); node.setCascadeOpacityEnabled(true); @@ -169,7 +183,6 @@ var spriteFrame = cc.spriteFrameCache.getSpriteFrame(path); node.setSpriteFrame(spriteFrame); } - }); if(json["FlipX"]) @@ -209,7 +222,7 @@ // WIDGET // //////////// - parser.widgetAttributes = function(widget, json){ + parser.widgetAttributes = function(widget, json) { widget.setCascadeColorEnabled(true); widget.setCascadeOpacityEnabled(true); @@ -219,33 +232,43 @@ setContentSize(widget, json["Size"]); var name = json["Name"]; - if(name) + if (name) widget.setName(name); var actionTag = json["ActionTag"] || 0; widget.setActionTag(actionTag); - widget.setUserObject(new ccs.ActionTimelineData(actionTag)); + + if (cc.sys.isNative){ + var extensionData = new ccs.ObjectExtensionData(); + var customProperty = json["UserData"]; + if(customProperty !== undefined) + extensionData.setCustomProperty(customProperty); + extensionData.setActionTag(actionTag); + widget.setUserObject(extensionData); + } else { + widget.setUserObject(new ccs.ActionTimelineData(actionTag)); + } var rotationSkewX = json["RotationSkewX"]; - if(rotationSkewX) + if (rotationSkewX) widget.setRotationX(rotationSkewX); var rotationSkewY = json["RotationSkewY"]; - if(rotationSkewY) + if (rotationSkewY) widget.setRotationY(rotationSkewY); //var rotation = json["Rotation"]; var flipX = json["FlipX"]; - if(flipX) + if (flipX) widget.setFlippedX(true); var flipY = json["FlipY"]; - if(flipY) + if (flipY) widget.setFlippedY(true); var zOrder = json["zOrder"]; - if(zOrder != null) + if (zOrder != null) widget.setLocalZOrder(zOrder); //var visible = json["Visible"]; @@ -254,7 +277,7 @@ widget.setVisible(visible); var alpha = json["Alpha"]; - if(alpha != null) + if (alpha != null) widget.setOpacity(alpha); widget.setTag(json["Tag"] || 0); @@ -265,19 +288,19 @@ // -- var frameEvent = json["FrameEvent"]; var callBackType = json["CallBackType"]; - if(callBackType != null) + if (callBackType != null) widget.setCallbackType(callBackType); var callBackName = json["CallBackName"]; - if(callBackName) + if (callBackName) widget.setCallbackName(callBackName); var position = json["Position"]; - if(position != null) + if (position != null) widget.setPosition(position["X"] || 0, position["Y"] || 0); var scale = json["Scale"]; - if(scale != null){ + if (scale != null) { var scaleX = getParam(scale["ScaleX"], 1); var scaleY = getParam(scale["ScaleY"], 1); widget.setScaleX(scaleX); @@ -285,80 +308,79 @@ } var anchorPoint = json["AnchorPoint"]; - if(anchorPoint != null) + if (anchorPoint != null) widget.setAnchorPoint(anchorPoint["ScaleX"] || 0, anchorPoint["ScaleY"] || 0); var color = json["CColor"]; - if(color != null) + if (color != null) widget.setColor(getColor(color)); - if(widget instanceof ccui.Layout){ - var layoutComponent = ccui.LayoutComponent.bindLayoutComponent(widget); - - var positionXPercentEnabled = json["PositionPercentXEnable"] || false; - var positionYPercentEnabled = json["PositionPercentYEnable"] || false; - var positionXPercent = 0, - positionYPercent = 0, - PrePosition = json["PrePosition"]; - if(PrePosition != null){ - positionXPercent = PrePosition["X"] || 0; - positionYPercent = PrePosition["Y"] || 0; - } - var sizeXPercentEnable = json["PercentWidthEnable"] || false; - var sizeYPercentEnable = json["PercentHeightEnable"] || false; - var sizeXPercent = 0, - sizeYPercent = 0, - PreSize = json["PreSize"]; - if(PrePosition != null){ - sizeXPercent = PreSize["X"] || 0; - sizeYPercent = PreSize["Y"] || 0; - } - var stretchHorizontalEnabled = json["StretchWidthEnable"] || false; - var stretchVerticalEnabled = json["StretchHeightEnable"] || false; - var horizontalEdge = json["HorizontalEdge"];// = ccui.LayoutComponent.horizontalEdge.LEFT; - var verticalEdge = json["VerticalEdge"]; // = ccui.LayoutComponent.verticalEdge.TOP; - var leftMargin = json["LeftMargin"] || 0; - var rightMargin = json["RightMargin"] || 0; - var topMargin = json["TopMargin"] || 0; - var bottomMargin = json["BottomMargin"] || 0; - - layoutComponent.setPositionPercentXEnabled(positionXPercentEnabled); - layoutComponent.setPositionPercentYEnabled(positionYPercentEnabled); - layoutComponent.setPositionPercentX(positionXPercent); - layoutComponent.setPositionPercentY(positionYPercent); - layoutComponent.setPercentWidthEnabled(sizeXPercentEnable); - layoutComponent.setPercentHeightEnabled(sizeYPercentEnable); - layoutComponent.setPercentWidth(sizeXPercent); - layoutComponent.setPercentHeight(sizeYPercent); - layoutComponent.setStretchWidthEnabled(stretchHorizontalEnabled); - layoutComponent.setStretchHeightEnabled(stretchVerticalEnabled); - - var horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.NONE; - if (horizontalEdge == "LeftEdge"){ - horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.LEFT; - }else if (horizontalEdge == "RightEdge"){ - horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.RIGHT; - }else if (horizontalEdge == "BothEdge"){ - horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.CENTER; - } - layoutComponent.setHorizontalEdge(horizontalEdgeType); - - var verticalEdgeType = ccui.LayoutComponent.verticalEdge.NONE; - if (verticalEdge == "TopEdge"){ - verticalEdgeType = ccui.LayoutComponent.verticalEdge.TOP; - }else if (verticalEdge == "BottomEdge"){ - verticalEdgeType = ccui.LayoutComponent.verticalEdge.BOTTOM; - }else if (verticalEdge == "BothEdge"){ - verticalEdgeType = ccui.LayoutComponent.verticalEdge.CENTER; - } - layoutComponent.setVerticalEdge(verticalEdgeType); - - layoutComponent.setTopMargin(topMargin); - layoutComponent.setBottomMargin(bottomMargin); - layoutComponent.setLeftMargin(leftMargin); - layoutComponent.setRightMargin(rightMargin); + var layoutComponent = ccui.LayoutComponent.bindLayoutComponent(widget); + if(!layoutComponent) + return; + + var positionXPercentEnabled = json["PositionPercentXEnable"] || false; + var positionYPercentEnabled = json["PositionPercentYEnable"] || false; + var positionXPercent = 0, + positionYPercent = 0, + PrePosition = json["PrePosition"]; + if (PrePosition != null) { + positionXPercent = PrePosition["X"] || 0; + positionYPercent = PrePosition["Y"] || 0; + } + var sizeXPercentEnable = json["PercentWidthEnable"] || false; + var sizeYPercentEnable = json["PercentHeightEnable"] || false; + var sizeXPercent = 0, + sizeYPercent = 0, + PreSize = json["PreSize"]; + if (PrePosition != null) { + sizeXPercent = PreSize["X"] || 0; + sizeYPercent = PreSize["Y"] || 0; } + var stretchHorizontalEnabled = json["StretchWidthEnable"] || false; + var stretchVerticalEnabled = json["StretchHeightEnable"] || false; + var horizontalEdge = json["HorizontalEdge"];// = ccui.LayoutComponent.horizontalEdge.LEFT; + var verticalEdge = json["VerticalEdge"]; // = ccui.LayoutComponent.verticalEdge.TOP; + var leftMargin = json["LeftMargin"] || 0; + var rightMargin = json["RightMargin"] || 0; + var topMargin = json["TopMargin"] || 0; + var bottomMargin = json["BottomMargin"] || 0; + + layoutComponent.setPositionPercentXEnabled(positionXPercentEnabled); + layoutComponent.setPositionPercentYEnabled(positionYPercentEnabled); + layoutComponent.setPositionPercentX(positionXPercent); + layoutComponent.setPositionPercentY(positionYPercent); + layoutComponent.setPercentWidthEnabled(sizeXPercentEnable); + layoutComponent.setPercentHeightEnabled(sizeYPercentEnable); + layoutComponent.setPercentWidth(sizeXPercent); + layoutComponent.setPercentHeight(sizeYPercent); + layoutComponent.setStretchWidthEnabled(stretchHorizontalEnabled); + layoutComponent.setStretchHeightEnabled(stretchVerticalEnabled); + + var horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.NONE; + if (horizontalEdge == "LeftEdge") { + horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.LEFT; + } else if (horizontalEdge == "RightEdge") { + horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.RIGHT; + } else if (horizontalEdge == "BothEdge") { + horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.CENTER; + } + layoutComponent.setHorizontalEdge(horizontalEdgeType); + + var verticalEdgeType = ccui.LayoutComponent.verticalEdge.NONE; + if (verticalEdge == "TopEdge") { + verticalEdgeType = ccui.LayoutComponent.verticalEdge.TOP; + } else if (verticalEdge == "BottomEdge") { + verticalEdgeType = ccui.LayoutComponent.verticalEdge.BOTTOM; + } else if (verticalEdge == "BothEdge") { + verticalEdgeType = ccui.LayoutComponent.verticalEdge.CENTER; + } + layoutComponent.setVerticalEdge(verticalEdgeType); + layoutComponent.setTopMargin(topMargin); + layoutComponent.setBottomMargin(bottomMargin); + layoutComponent.setLeftMargin(leftMargin); + layoutComponent.setRightMargin(rightMargin); }; /** @@ -413,15 +435,12 @@ } - var bgStartColor = json["FirstColor"]; - var bgEndColor = json["EndColor"]; - if(bgStartColor != null && bgEndColor != null){ - var startC = getColor(bgStartColor); - if(bgEndColor["R"] == null && bgEndColor["G"] == null && bgEndColor["B"] == null) - widget.setBackGroundColor( startC ); - else - widget.setBackGroundColor( startC, getColor(bgEndColor) ); - } + var firstColor = json["FirstColor"]; + var endColor = json["EndColor"]; + if(endColor["R"] != null && endColor["G"] != null && endColor["B"] != null) + widget.setBackGroundColor(getColor(firstColor), getColor(endColor)); + else + widget.setBackGroundColor(getColor(json["SingleColor"])); var colorVector = json["ColorVector"]; if(colorVector != null) @@ -579,10 +598,10 @@ widget.setUnifySizeEnabled(false); widget.ignoreContentAdaptWithSize(false); var capInsets = cc.rect( - json["Scale9OriginX"] || 0, - json["Scale9OriginY"] || 0, - json["Scale9Width"] || 0, - json["Scale9Height"] || 0 + json["Scale9OriginX"] || 0, + json["Scale9OriginY"] || 0, + json["Scale9Width"] || 0, + json["Scale9Height"] || 0 ); widget.setCapInsets(capInsets); @@ -639,6 +658,10 @@ this.widgetAttributes(widget, json); + loadTexture(json["FileData"], resourcePath, function(path, type){ + widget.setBackGroundImage(path, type); + }); + var clipEnabled = json["ClipAble"]; widget.setClippingEnabled(clipEnabled); @@ -685,14 +708,10 @@ widget.setBackGroundColorVector(cc.p(colorVectorX, colorVectorY)); } - loadTexture(json["FileData"], resourcePath, function(path, type){ - widget.setBackGroundImage(path, type); - }); - var innerNodeSize = json["InnerNodeSize"]; var innerSize = cc.size( - innerNodeSize["Width"] || 0, - innerNodeSize["Height"] || 0 + innerNodeSize["Width"] || 0, + innerNodeSize["Height"] || 0 ); widget.setInnerContainerSize(innerSize); @@ -823,6 +842,10 @@ this.widgetAttributes(widget, json); + loadTexture(json["FileData"], resourcePath, function(path, type){ + widget.setBackGroundImage(path, type); + }); + var clipEnabled = json["ClipAble"] || false; widget.setClippingEnabled(clipEnabled); @@ -863,10 +886,6 @@ if(bgColorOpacity != null) widget.setBackGroundColorOpacity(bgColorOpacity); - loadTexture(json["FileData"], resourcePath, function(path, type){ - widget.setBackGroundImage(path, type); - }); - setContentSize(widget, json["Size"]); return widget; @@ -885,6 +904,10 @@ this.widgetAttributes(widget, json); + loadTexture(json["FileData"], resourcePath, function(path, type){ + widget.setBackGroundImage(path, type); + }); + var clipEnabled = json["ClipAble"] || false; widget.setClippingEnabled(clipEnabled); @@ -958,11 +981,6 @@ if(bgColorOpacity != null) widget.setBackGroundColorOpacity(bgColorOpacity); - - loadTexture(json["FileData"], resourcePath, function(path, type){ - widget.setBackGroundImage(path, type); - }); - setContentSize(widget, json["Size"]); return widget; @@ -1147,10 +1165,13 @@ if(projectFile != null && projectFile["Path"]){ var file = resourcePath + projectFile["Path"]; if(cc.loader.getRes(file)){ - var obj = ccs.load(file); + var obj = ccs.load(file, resourcePath); parser.generalAttributes(obj.node, json); if(obj.action && obj.node){ obj.action.tag = obj.node.tag; + var InnerActionSpeed = json["InnerActionSpeed"]; + if(InnerActionSpeed !== undefined) + obj.action.setTimeSpeed(InnerActionSpeed); obj.node.runAction(obj.action); obj.action.gotoFrameAndPause(0); } @@ -1249,8 +1270,170 @@ node.setContentSize(cc.size(x, y)); }; + var get3DVector = function(json, name, defValue){ + var x = defValue, y = defValue, z = defValue; + if(json && name && json[name]){ + x = null != json[name]["ValueX"] ? json[name]["ValueX"] : defValue; + y = null != json[name]["ValueY"] ? json[name]["ValueY"] : defValue; + z = null != json[name]["ValueZ"] ? json[name]["ValueZ"] : defValue; + } + var vec3 = cc.math.vec3(x, y, z); + return vec3; + }; + + parser.general3DAttributes = function(node, json){ + var pos = get3DVector(json, "Position3D", 0); + node.setPosition3D(pos); + + var rotation = get3DVector(json, "Rotation3D", 0); + node.setRotation3D(rotation); + + var scale = get3DVector(json, "Scale3D", 1.0); + node.setScaleX(scale.x); + node.setScaleY(scale.y); + node.setScaleZ(scale.z); + + var camMask =json["CameraFlagMode"]; + if(undefined !== camMask && null !== camMask) + node.setCameraMask(camMask); + + this.generalAttributes(node, json); + }; + + /** + * Node3D + * @param json + * @returns {*} + */ + parser.initNode3D = function(json){ + var node = cc.Node.create(); + if(node) + this.general3DAttributes(node, json); + return node; + }; + + /** + * Camera + * @param json + * @returns {*} + */ + parser.initCamera = function(json){ + var s = cc.winSize; + var fov = json["Fov"] ? json["Fov"] : 60; + + var nearClip = 1; + var farClip = 500; + if(json["ClipPlane"]){ + nearClip = json["ClipPlane"]["ValueX"]; + farClip = json["ClipPlane"]["ValueY"]; + if(null === nearClip || isNaN(nearClip)) + nearClip = 1; + if(null === farClip || isNaN(farClip)) + farClip = 500; + } + + var node = cc.Camera.createPerspective(fov, s.width/s.height, nearClip, farClip); + + if(node){ + this.general3DAttributes(node, json); + + var camMode = json["UserCameraFlagMode"]; + switch(camMode){ + case "USER1": + node.setCameraFlag(cc.CameraFlag.USER1); break; + case "USER2": + node.setCameraFlag(cc.CameraFlag.USER2); break; + case "USER3": + node.setCameraFlag(cc.CameraFlag.USER3); break; + case "USER4": + node.setCameraFlag(cc.CameraFlag.USER4); break; + case "USER5": + node.setCameraFlag(cc.CameraFlag.USER5); break; + case "USER6": + node.setCameraFlag(cc.CameraFlag.USER6); break; + case "USER7": + node.setCameraFlag(cc.CameraFlag.USER7); break; + case "USER8": + node.setCameraFlag(cc.CameraFlag.USER8); break; + case "DEFAULT": + node.setCameraFlag(cc.CameraFlag.DEFAULT); break; + default: + node.setCameraFlag(cc.CameraFlag.USER1); + } + } + + return node; + }; + + /** + * Sprite3D + * @param json + * @param resourcePath + * @returns {*} + */ + parser.initSprite3D = function(json, resourcePath){ + var resFile = null; + if(json["FileData"] && json["FileData"]["Path"]) + resFile = resourcePath + json["FileData"]["Path"]; + + var node; + if(resFile) + node = jsb.Sprite3D.create(resFile); + else + node = jsb.Sprite3D.create(); + + if(node) { + this.general3DAttributes(node, json); + + if(json["CColor"]) { + var col = getColor(json["CColor"]); + if(col && col.r !== 255 || col.g !== 255 || col.b !== 255) + node.setColor(col); + } + + var autoAction = getParam(json["RunAction3D"], false); + if(autoAction && resFile){ + var animation = jsb.Animation3D.create(resFile, ""); + if(animation){ + var animate = jsb.Animate3D.create(animation); + var action = cc.RepeatForever.create(animate); + node.runAction(action); + } + } + } + + return node; + }; + + /** + * Particle3D + * @param json + * @param resourcePath + * @returns {*} + */ + parser.initParticle3D = function(json, resourcePath){ + var node = null; + + var resFile = null; + if(json["FileData"] && json["FileData"]["Path"]) + resFile = resourcePath+json["FileData"]["Path"]; + + if(resFile) + node = jsb.PUParticleSystem3D.create(resFile); + else + node = jsb.PUParticleSystem3D.create(); + + if(node){ + this.general3DAttributes(node, json); + node.startParticleSystem(); + } + + return node; + }; + var register = [ {name: "SingleNodeObjectData", handle: parser.initSingleNode}, + {name: "NodeObjectData", handle: parser.initSingleNode}, {name: "LayerObjectData", handle: parser.initSingleNode}, {name: "SpriteObjectData", handle: parser.initSprite}, {name: "ParticleObjectData", handle: parser.initParticle}, @@ -1270,7 +1453,12 @@ {name: "SimpleAudioObjectData", handle: parser.initSimpleAudio}, {name: "GameMapObjectData", handle: parser.initGameMap}, {name: "ProjectNodeObjectData", handle: parser.initProjectNode}, - {name: "ArmatureNodeObjectData", handle: parser.initArmature} + {name: "ArmatureNodeObjectData", handle: parser.initArmature}, + + {name: "Sprite3DObjectData", handle: parser.initSprite3D}, + {name: "Particle3DObjectData", handle: parser.initParticle3D}, + {name: "UserCameraObjectData", handle: parser.initCamera}, + {name: "Node3DObjectData", handle: parser.initNode3D} ]; register.forEach(function(item){ diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/studio/parsers/uiParser-1.x.js b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/studio/parsers/uiParser-1.x.js index 41500f531f..a6762cac64 100755 --- a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/studio/parsers/uiParser-1.x.js +++ b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.app/script/studio/parsers/uiParser-1.x.js @@ -458,6 +458,7 @@ /** * Text parser (UIText) */ + var regTTF = /\.ttf$/; parser.TextAttributes = function(widget, options, resourcePath){ var touchScaleChangeAble = options["touchScaleEnable"]; widget.setTouchScaleChangeEnabled(touchScaleChangeAble); @@ -469,7 +470,15 @@ } var fn = options["fontName"]; if (fn != null){ - widget.setFontName(options["fontName"]); + if(cc.sys.isNative){ + if(regTTF.test(fn)){ + widget.setFontName(cc.path.join(cc.loader.resPath, resourcePath, fn)); + }else{ + widget.setFontName(fn); + } + }else{ + widget.setFontName(fn.replace(regTTF, '')); + } } var aw = options["areaWidth"]; var ah = options["areaHeight"]; @@ -599,7 +608,7 @@ /** * TextField parser (UITextField) */ - parser.TextFieldAttributes = function(widget, options, resoutcePath){ + parser.TextFieldAttributes = function(widget, options, resourcePath){ var ph = options["placeHolder"]; if(ph) widget.setPlaceHolder(ph); @@ -608,8 +617,17 @@ if(fs) widget.setFontSize(fs); var fn = options["fontName"]; - if(fn) - widget.setFontName(fn); + if (fn != null){ + if(cc.sys.isNative){ + if(regTTF.test(fn)){ + widget.setFontName(cc.path.join(cc.loader.resPath, resourcePath, fn)); + }else{ + widget.setFontName(fn); + } + }else{ + widget.setFontName(fn.replace(regTTF, '')); + } + } var tsw = options["touchSizeWidth"]; var tsh = options["touchSizeHeight"]; if(tsw!=null && tsh!=null) diff --git a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.ipa b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.ipa index db3b33778d..776b499deb 100755 Binary files a/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.ipa and b/templates/js-template-runtime/runtime/ios/PrebuiltRuntimeJs.ipa differ diff --git a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Info.plist b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Info.plist index 91a98d170d..e418dbdb26 100755 --- a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Info.plist +++ b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Info.plist @@ -3,7 +3,7 @@ BuildMachineOSBuild - 13D65 + 14B25 CFBundleDevelopmentRegion en CFBundleExecutable @@ -27,17 +27,17 @@ DTCompiler com.apple.compilers.llvm.clang.1_0 DTPlatformBuild - 5B1008 + 6C131e DTPlatformVersion GM DTSDKBuild - 13C64 + 14A383 DTSDKName - macosx10.9 + macosx10.10 DTXcode - 0511 + 0620 DTXcodeBuild - 5B1008 + 6C131e LSApplicationCategoryType public.app-category.games LSMinimumSystemVersion diff --git a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/MacOS/PrebuiltRuntimeJs Mac b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/MacOS/PrebuiltRuntimeJs Mac index 8eb6420804..e83eb5c34d 100755 Binary files a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/MacOS/PrebuiltRuntimeJs Mac and b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/MacOS/PrebuiltRuntimeJs Mac differ diff --git a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/MainMenu.nib b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/MainMenu.nib index 92baef14f7..c3efd24203 100755 Binary files a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/MainMenu.nib and b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/MainMenu.nib differ diff --git a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/3d/jsb_cocos2d_3d.js b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/3d/jsb_cocos2d_3d.js new file mode 100755 index 0000000000..7db2366c2e --- /dev/null +++ b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/3d/jsb_cocos2d_3d.js @@ -0,0 +1,256 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ +cc.CameraFlag = { + DEFAULT : 1, + USER1 : 1 << 1, + USER2 : 1 << 2, + USER3 : 1 << 3, + USER4 : 1 << 4, + USER5 : 1 << 5, + USER6 : 1 << 6, + USER7 : 1 << 7, + USER8 : 1 << 8 +}; + +cc.LightType = { + DIRECTIONAL : 0, + POINT : 1, + SPOT : 2, + AMBIENT : 3, +}; + +cc.LightFlag = { + LIGHT0 : 1, + LIGHT1 : 1 << 1, + LIGHT2 : 1 << 2, + LIGHT3 : 1 << 3, + LIGHT4 : 1 << 4, + LIGHT5 : 1 << 5, + LIGHT6 : 1 << 6, + LIGHT7 : 1 << 7, + LIGHT8 : 1 << 8, + LIGHT9 : 1 << 9, + LIGHT10 : 1 << 10, + LIGHT11 : 1 << 11, + LIGHT12 : 1 << 12, + LIGHT13 : 1 << 13, + LIGHT14 : 1 << 14, + LIGHT15 : 1 << 15, +}; + +cc.AsyncTaskPool.TaskType = { + TASK_IO : 0, + TASK_NETWORK : 1, + TASK_OTHER : 2, + TASK_MAX_TYPE : 3 +}; + +jsb.BillBoard.Mode = { + VIEW_POINT_ORIENTED : 0, // orient to the camera + VIEW_PLANE_ORIENTED : 1 // orient to the XOY plane of camera +}; + +cc.attributeNames = [cc.ATTRIBUTE_NAME_POSITION, + cc.ATTRIBUTE_NAME_COLOR, + cc.ATTRIBUTE_NAME_TEX_COORD, + cc.ATTRIBUTE_NAME_TEX_COORD1, + cc.ATTRIBUTE_NAME_TEX_COORD2, + cc.ATTRIBUTE_NAME_TEX_COORD3, + cc.ATTRIBUTE_NAME_NORMAL, + cc.ATTRIBUTE_NAME_BLEND_WEIGHT, + cc.ATTRIBUTE_NAME_BLEND_INDEX]; + +cc.math = cc.math || {}; + +cc.math.Vec3 = function(x=0, y=0, z=0){ + this.x = x; + this.y = y; + this.z = z; +}; + +cc.math.Vec3.prototype.normalize = function(){ + var n = this.x * this.x + this.y * this.y + this.z * this.z; + n = 1 / Math.sqrt(n); + this.x *= n; + this.y *= n; + this.z *= n; +}; + +cc.math.vec3 = function(x, y, z){ + return new cc.math.Vec3(x, y, z); +}; + +cc.math.vec3Cross = function(v1, v2){ + return new cc.math.Vec3(v1.y * v2.z - v1.z * v2.y, + v1.z * v2.x - v1.x * v2.z, + v1.x * v2.y - v1.y * v2.x); +}; + +cc.math.vec3Dot = function(v1, v2){ + return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z; +}; + +cc.math.vec3Length = function(v){ + return Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z); +}; + +cc.math.vec3Normalize = function(v){ + var n = v.x * v.x + v.y * v.y + v.z * v.z; + n = 1 / Math.sqrt(n); + return cc.math.vec3(v.x * n, v.y * n, v.z * n); +}; + +cc.math.vec3Add = function(v1, v2){ + return new cc.math.Vec3(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z); +}; + +cc.math.vec3Sub = function(v1, v2){ + return new cc.math.Vec3(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z); +}; + +cc.math.Quaternion = function(x=0, y=0, z=0, w=0){ + this.x = x; + this.y = y; + this.z = z; + this.w = w; +}; + +cc.math.quaternion = function(xOrAxis, yOrAngle, z, w){ + if(w !== undefined){ + return new cc.math.Quaternion(xOrAxis, yOrAngle, z, w); + } + else if(yOrAngle !== undefined){ + var sinHalfAngle = Math.sin(yOrAngle / 2); + var normal = cc.math.vec3(xOrAxis.x, xOrAxis.y, xOrAxis.z); + normal.normalize(); + return cc.math.quaternion(normal.x * sinHalfAngle, normal.y * sinHalfAngle, normal.z * sinHalfAngle, Math.cos(yOrAngle / 2)); + } +}; + +cc.math.AABB = function(min=cc.math.vec3(99999, 99999, 99999), max=cc.math.vec3(-99999, -99999, -99999)){ + this.min = min; + this.max = max; +}; + +cc.math.aabb = function(min, max){ + return new cc.math.AABB(min, max); +}; + +cc.math.aabbGetCorners = function(aabb){ + var corners = new Array(8); + corners[0] = cc.math.vec3(aabb.min.x, aabb.max.y, aabb.max.z); + corners[1] = cc.math.vec3(aabb.min.x, aabb.min.y, aabb.max.z); + corners[2] = cc.math.vec3(aabb.max.x, aabb.min.y, aabb.max.z); + corners[3] = cc.math.vec3(aabb.max.x, aabb.max.y, aabb.max.z); + + corners[4] = cc.math.vec3(aabb.max.x, aabb.max.y, aabb.min.z); + corners[5] = cc.math.vec3(aabb.max.x, aabb.min.y, aabb.min.z); + corners[6] = cc.math.vec3(aabb.min.x, aabb.min.y, aabb.min.z); + corners[7] = cc.math.vec3(aabb.min.x, aabb.max.y, aabb.min.z); + return corners; +}; + +cc.math.OBB = function(aabb){ + this.center = cc.math.vec3((aabb.min.x + aabb.max.x)/2, (aabb.min.y + aabb.max.y)/2, (aabb.min.z + aabb.max.z)/2); // obb center + this.xAxis = cc.math.vec3(1, 0, 0); // x axis of obb, unit vector + this.yAxis = cc.math.vec3(0, 1, 0); // y axis of obb, unit vecotr + this.zAxis = cc.math.vec3(0, 0, 1); // z axis of obb, unit vector + this.extents = cc.math.vec3((aabb.max.x - aabb.min.x)/2, (aabb.max.y - aabb.min.y)/2, (aabb.max.z - aabb.min.z)/2); // obb length along each axis + this.extentX = cc.math.vec3((aabb.max.x - aabb.min.x)/2, 0, 0); // _xAxis * _extents.x + this.extentY = cc.math.vec3(0, (aabb.max.y - aabb.min.y)/2, 0); // _yAxis * _extents.y + this.extentZ = cc.math.vec3(0, 0, (aabb.max.z - aabb.min.z)/2); // _zAxis * _extents.z +}; + +cc.math.obb = function(aabb){ + return new cc.math.OBB(aabb); +}; + +cc.math.Ray = function(origin = cc.math.vec3(0, 0, 0), direction = cc.math.vec3(0, 0, 1)){ + this.origin = origin; + this.direction = direction; +}; + +cc.math.ray = function(origin, direction){ + return new cc.math.Ray(origin, direction); +}; + +cc.math.Vec4 = cc.math.Quaternion; + +cc.math.vec4 = function(x, y, z, w){ + return new cc.math.Vec4(x, y, z, w); +}; + +jsb.sprite3DCache = jsb.Sprite3DCache.getInstance(); + +jsb.Sprite3D.extend = cc.Class.extend; + +jsb.Sprite3D.prototype._setBlendFunc = jsb.Sprite3D.prototype.setBlendFunc; +jsb.Sprite3D.prototype.setBlendFunc = templateSetBlendFunc; + +jsb.Mesh.prototype._setBlendFunc = jsb.Mesh.prototype.setBlendFunc; +jsb.Mesh.prototype.setBlendFunc = templateSetBlendFunc; + +jsb.Sprite3D.prototype._ctor = function(modelPath, texturePath){ + if(modelPath === undefined){ + this.init(); + }else{ + if(modelPath.length < 4){ + cc.log("invalid filename for Sprite3D"); + return; + } + this.initWithFile(modelPath); + var bb = this.getBoundingBox(); + this.setContentSize(cc.size(bb.width, bb.height)); + + if(texturePath !== undefined) + this.setTexture(texturePath); + } +}; + +jsb.BillBoard.prototype._ctor = function(filename, rect, mode = jsb.BillBoard.Mode.VIEW_POINT_ORIENTED){ + if(filename !== undefined && filename instanceof cc.Texture2D){ + rect = rect || jsb.BillBoard.Mode.VIEW_POINT_ORIENTED; + this.initWithTexture(filename); + this.setMode(rect); + }else if(filename !== undefined && typeof filename === "string"){ + if(rect !== undefined){ + if(typeof rect === "object"){ + this.initWithFile(filename, rect); + this.setMode(mode); + }else{ + this.initWithFile(filename); + this.setMode(rect); + } + }else{ + this.initWithFile(filename); + this.setMode(jsb.BillBoard.Mode.VIEW_POINT_ORIENTED); + } + }else{ + filename = filename || jsb.BillBoard.Mode.VIEW_POINT_ORIENTED; + this.init(); + this.setMode(filename); + } +} \ No newline at end of file diff --git a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/3d/jsb_cocos2d_3d_ext.js b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/3d/jsb_cocos2d_3d_ext.js new file mode 100755 index 0000000000..653e88fdbe --- /dev/null +++ b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/3d/jsb_cocos2d_3d_ext.js @@ -0,0 +1,28 @@ +/**************************************************************************** + Copyright (c) 2008-2010 Ricardo Quesada + Copyright (c) 2011-2012 cocos2d-x.org + Copyright (c) 2013-2014 Chukong Technologies Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +jsb.ParticleSystem3D.prototype._setBlendFunc = jsb.ParticleSystem3D.prototype.setBlendFunc; +jsb.ParticleSystem3D.prototype.setBlendFunc = templateSetBlendFunc; \ No newline at end of file diff --git a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/jsb.js b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/jsb.js index 97db22e7ac..1ae745a3c5 100755 --- a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/jsb.js +++ b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/jsb.js @@ -129,3 +129,11 @@ if (jsb.fileUtils.isFileExist('jsb_pluginx.js')) { if (window.sp) { require('script/jsb_spine.js'); } + +if (jsb.Sprite3D){ + require('script/3d/jsb_cocos2d_3d.js'); +} + +if (jsb.ParticleSystem3D) { + require('script/3d/jsb_cocos2d_3d_ext.js'); +} \ No newline at end of file diff --git a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/jsb_boot.js b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/jsb_boot.js index 9e85eeb6ad..33d2653645 100755 --- a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/jsb_boot.js +++ b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/jsb_boot.js @@ -101,7 +101,8 @@ cc.isString = function(obj) { * @returns {boolean} */ cc.isArray = function(obj) { - return Object.prototype.toString.call(obj) == '[object Array]'; + return Array.isArray(obj) || + (typeof obj === 'object' && objectToString(obj) === '[object Array]'); }; /** @@ -110,7 +111,7 @@ cc.isArray = function(obj) { * @returns {boolean} */ cc.isUndefined = function(obj) { - return typeof obj == 'undefined'; + return typeof obj === 'undefined'; }; /** @@ -119,9 +120,8 @@ cc.isUndefined = function(obj) { * @returns {boolean} */ cc.isObject = function(obj) { - var type = typeof obj; - - return type == 'function' || (obj && type == 'object'); + return obj.__nativeObj !== undefined || + ( typeof obj === "object" && Object.prototype.toString.call(obj) === '[object Object]' ); }; /** @@ -574,10 +574,11 @@ cc.loader = { }); } else { - var tex = cc.textureCache._addImage(url); - if (tex instanceof cc.Texture2D) - cb && cb(null, tex); - else cb && cb("Load image failed"); + cc.textureCache._addImageAsync(url, function (tex){ + if (tex instanceof cc.Texture2D) + cb && cb(null, tex); + else cb && cb("Load image failed"); + }); } }, /** @@ -932,8 +933,8 @@ cc.configuration = cc.Configuration.getInstance(); * cc.textureCache is the global cache for cc.Texture2D */ cc.textureCache = cc.director.getTextureCache(); -cc.TextureCache.prototype._addImage = cc.TextureCache.prototype.addImage; -cc.TextureCache.prototype.addImage = function(url, cb, target) { +cc.TextureCache.prototype._addImageAsync = cc.TextureCache.prototype.addImageAsync; +cc.TextureCache.prototype.addImageAsync = function(url, cb, target) { var localTex = null; cc.loader.loadImg(url, function(err, tex) { if (err) tex = null; @@ -944,6 +945,21 @@ cc.TextureCache.prototype.addImage = function(url, cb, target) { }); return localTex; }; +// Fix for compatibility with old APIs +cc.TextureCache.prototype._addImage = cc.TextureCache.prototype.addImage; +cc.TextureCache.prototype.addImage = function(url, cb, target) { + if (typeof cb === "function") { + return this.addImageAsync(url, cb, target); + } + else { + if (cb) { + return this._addImage(url, cb) + } + else { + return this._addImage(url); + } + } +}; /** * @type {Object} * @name cc.shaderCache @@ -1158,117 +1174,204 @@ cc._initSys = function(config, CONFIG_KEY){ */ locSys.LANGUAGE_POLISH = "pl"; - /** + * @memberof cc.sys + * @name OS_IOS * @constant - * @default * @type {string} */ - locSys.OS_WINDOWS = "Windows"; + sys.OS_IOS = "iOS"; /** + * @memberof cc.sys + * @name OS_ANDROID * @constant - * @default * @type {string} */ - locSys.OS_IOS = "iOS"; + sys.OS_ANDROID = "Android"; /** + * @memberof cc.sys + * @name OS_WINDOWS * @constant - * @default * @type {string} */ - locSys.OS_OSX = "OS X"; + sys.OS_WINDOWS = "Windows"; /** + * @memberof cc.sys + * @name OS_MARMALADE * @constant - * @default * @type {string} */ - locSys.OS_UNIX = "UNIX"; + sys.OS_MARMALADE = "Marmalade"; /** + * @memberof cc.sys + * @name OS_LINUX * @constant - * @default * @type {string} */ - locSys.OS_LINUX = "Linux"; + sys.OS_LINUX = "Linux"; /** + * @memberof cc.sys + * @name OS_BADA * @constant - * @default * @type {string} */ - locSys.OS_ANDROID = "Android"; - locSys.OS_UNKNOWN = "unknown"; + sys.OS_BADA = "Bada"; + /** + * @memberof cc.sys + * @name OS_BLACKBERRY + * @constant + * @type {string} + */ + sys.OS_BLACKBERRY = "Blackberry"; + /** + * @memberof cc.sys + * @name OS_OSX + * @constant + * @type {string} + */ + sys.OS_OSX = "OS X"; + /** + * @memberof cc.sys + * @name OS_WP8 + * @constant + * @type {string} + */ + sys.OS_WP8 = "WP8"; + /** + * @memberof cc.sys + * @name OS_WINRT + * @constant + * @type {string} + */ + sys.OS_WINRT = "WINRT"; + /** + * @memberof cc.sys + * @name OS_UNKNOWN + * @constant + * @type {string} + */ + sys.OS_UNKNOWN = "Unknown"; /** + * @memberof cc.sys + * @name UNKNOWN + * @constant + * @default + * @type {Number} + */ + sys.UNKNOWN = 0; + /** + * @memberof cc.sys + * @name IOS * @constant * @default * @type {Number} */ - locSys.WINDOWS = 0; + sys.IOS = 1; /** + * @memberof cc.sys + * @name ANDROID * @constant * @default * @type {Number} */ - locSys.LINUX = 1; + sys.ANDROID = 2; /** + * @memberof cc.sys + * @name WIN32 * @constant * @default * @type {Number} */ - locSys.MACOS = 2; + sys.WIN32 = 3; /** + * @memberof cc.sys + * @name MARMALADE * @constant * @default * @type {Number} */ - locSys.ANDROID = 3; + sys.MARMALADE = 4; /** + * @memberof cc.sys + * @name LINUX * @constant * @default * @type {Number} */ - locSys.IPHONE = 4; + sys.LINUX = 5; /** + * @memberof cc.sys + * @name BADA * @constant * @default * @type {Number} */ - locSys.IPAD = 5; + sys.BADA = 6; /** + * @memberof cc.sys + * @name BLACKBERRY * @constant * @default * @type {Number} */ - locSys.BLACKBERRY = 6; + sys.BLACKBERRY = 7; /** + * @memberof cc.sys + * @name MACOS * @constant * @default * @type {Number} */ - locSys.NACL = 7; + sys.MACOS = 8; /** + * @memberof cc.sys + * @name NACL * @constant * @default * @type {Number} */ - locSys.EMSCRIPTEN = 8; + sys.NACL = 9; /** + * @memberof cc.sys + * @name EMSCRIPTEN * @constant * @default * @type {Number} */ - locSys.TIZEN = 9; + sys.EMSCRIPTEN = 10; /** + * @memberof cc.sys + * @name TIZEN * @constant * @default * @type {Number} */ - locSys.WINRT = 10; + sys.TIZEN = 11; /** + * @memberof cc.sys + * @name QT5 * @constant * @default * @type {Number} */ - locSys.WP8 = 11; + sys.QT5 = 12; + /** + * @memberof cc.sys + * @name WP8 + * @constant + * @default + * @type {Number} + */ + sys.WP8 = 13; + /** + * @memberof cc.sys + * @name WINRT + * @constant + * @default + * @type {Number} + */ + sys.WINRT = 14; /** * @constant * @default @@ -1346,7 +1449,7 @@ cc._initSys = function(config, CONFIG_KEY){ cc.log(str); } - locSys.isMobile = (locSys.os == locSys.OS_ANDROID || locSys.os == locSys.OS_IOS) ? true : false; + locSys.isMobile = (locSys.os == locSys.OS_ANDROID || locSys.os == locSys.OS_IOS || locSys.os == locSys.OS_WP8 || locSys.os == locSys.OS_WINRT) ? true : false; locSys.language = (function(){ var language = cc.Application.getInstance().getCurrentLanguage(); @@ -1382,6 +1485,16 @@ cc._initSys = function(config, CONFIG_KEY){ capabilities["keyboard"] = true; capabilities["mouse"] = true; } + + /** + * Open a url in browser + * @memberof cc.sys + * @name openURL + * @param {String} url + */ + locSys.openURL = function(url){ + cc.Application.getInstance().openURL(url); + } }; //+++++++++++++++++++++++++something about sys end+++++++++++++++++++++++++++++ diff --git a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/jsb_cocos2d.js b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/jsb_cocos2d.js index 167af32d09..621aa3ad89 100755 --- a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/jsb_cocos2d.js +++ b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/jsb_cocos2d.js @@ -26,7 +26,7 @@ // CCConfig.js // -cc.ENGINE_VERSION = "Cocos2d-JS v3.3 RC0"; +cc.ENGINE_VERSION = "Cocos2d-JS v3.5"; cc.FIX_ARTIFACTS_BY_STRECHING_TEXEL = 0; cc.DIRECTOR_STATS_POSITION = {x: 0, y: 0}; @@ -2172,7 +2172,6 @@ var templateSetBlendFunc = function(src, dst) { else blendf = {src: src, dst: dst}; this._setBlendFunc(blendf); - var b = this.getBlendFunc(); }; for (var i = 0, l = protoHasBlend.length; i < l; i++) { var proto = protoHasBlend[i]; @@ -2800,3 +2799,27 @@ cc.LabelTTF.prototype.setDimensions = function (dim, height) { } this._setDimensions(dim); }; + + +// +// Label adaptation to LabelTTF/LabelBMFont/LabelAtlas +// +_p = cc.Label.prototype; +_p.enableStroke = _p.enableOutline; +_p.setBoundingWidth = _p.setWidth; +_p.setBoundingHeight = _p.setHeight; + + +// +// 3D module rename to jsb namespace +// +jsb.BaseLight = cc.BaseLight; +delete cc.BaseLight; +jsb.DirectionLight = cc.DirectionLight; +delete cc.DirectionLight; +jsb.PointLight = cc.PointLight; +delete cc.PointLight; +jsb.SpotLight = cc.SpotLight; +delete cc.SpotLight; +jsb.AmbientLight = cc.AmbientLight; +delete cc.AmbientLight; diff --git a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/jsb_cocos2d_constants.js b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/jsb_cocos2d_constants.js index 5a0b860202..42bff9663e 100755 --- a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/jsb_cocos2d_constants.js +++ b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/jsb_cocos2d_constants.js @@ -133,3 +133,9 @@ cc.CHIPMUNK_IMPORT = 'chipmunk.h'; cc.ATTRIBUTE_NAME_COLOR = 'a_color'; cc.ATTRIBUTE_NAME_POSITION = 'a_position'; cc.ATTRIBUTE_NAME_TEX_COORD = 'a_texCoord'; +cc.ATTRIBUTE_NAME_TEX_COORD1 = "a_texCoord1"; +cc.ATTRIBUTE_NAME_TEX_COORD2 = "a_texCoord2"; +cc.ATTRIBUTE_NAME_TEX_COORD3 = "a_texCoord3"; +cc.ATTRIBUTE_NAME_NORMAL = "a_normal"; +cc.ATTRIBUTE_NAME_BLEND_WEIGHT = "a_blendWeight"; +cc.ATTRIBUTE_NAME_BLEND_INDEX = "a_blendIndex"; diff --git a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/jsb_create_apis.js b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/jsb_create_apis.js index 7b0dab4c3c..5048a2dfb7 100755 --- a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/jsb_create_apis.js +++ b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/jsb_create_apis.js @@ -47,12 +47,16 @@ _p._ctor = function(color, w, h) { _p = cc.LayerGradient.prototype; -_p._ctor = function(start, end, v) { +_p._ctor = function(start, end, v, colorStops) { start = start || cc.color(0,0,0,255); end = end || cc.color(0,0,0,255); v = v || cc.p(0, -1); this.initWithColor(start, end, v); + + if (colorStops instanceof Array) { + cc.log("Warning: Color stops parameter is not supported in JSB."); + } }; @@ -232,8 +236,14 @@ _p._ctor = function(normalImage, selectedImage, three, four, five) { callback = three; } else if (five === undefined) { - callback = three; - target = four; + if (typeof three === "function") { + callback = three; + target = four; + } + else { + disabledImage = three; + callback = four; + } } else if (five) { disabledImage = three; @@ -297,8 +307,10 @@ _p._ctor = function(plistFile){ if (!plistFile || typeof(plistFile) === "number") { var ton = plistFile || 100; this.initWithTotalParticles(ton); - } else if (plistFile) { + } else if ( typeof plistFile === "string") { this.initWithFile(plistFile); + } else if(plistFile){ + this.initWithDictionary(plistFile); } }; @@ -802,7 +814,11 @@ cc.Touch.prototype._ctor = function(x, y, id) { }; cc.GLProgram.prototype._ctor = function(vShaderFileName, fShaderFileName) { - vShaderFileName !== undefined && fShaderFileName !== undefined && cc.GLProgram.prototype.init.call(this, vShaderFileName, fShaderFileName); + if(vShaderFileName !== undefined && fShaderFileName !== undefined){ + cc.GLProgram.prototype.init.call(this, vShaderFileName, fShaderFileName); + cc.GLProgram.prototype.link.call(this); + cc.GLProgram.prototype.updateUniforms.call(this); + } }; @@ -1004,7 +1020,7 @@ cc.ParticleSystem.create = function(plistFile){ var particleSystem =null; if (typeof(plistFile) === "number") { particleSystem = cc.ParticleSystem.createWithTotalParticles(plistFile); - }else if(typeof(plistFile) === "string"){ + }else if(typeof(plistFile) === "string" || typeof(plistFile) === "object"){ particleSystem = cc.ParticleSystem._create(plistFile); } return particleSystem; diff --git a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/jsb_loaders.js b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/jsb_loaders.js index 9503e9652f..035e910672 100755 --- a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/jsb_loaders.js +++ b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/jsb_loaders.js @@ -26,6 +26,18 @@ // This helper file should be required after jsb_cocos2d.js // +cc._emptyLoader = { + load : function(realUrl, url){ + return null; + } +}; + +cc.loader.register([ + "mp3", "ogg", "wav", "mp4", "m4a", + "font", "eot", "ttf", "woff", "svg" + ], + cc._emptyLoader); + cc._txtLoader = { load : function(realUrl, url){ return jsb.fileUtils.getStringFromFile(realUrl); @@ -68,13 +80,6 @@ cc._plistLoader = { }; cc.loader.register(["plist"], cc._plistLoader); -cc._fontLoader = { - load : function(realUrl, url){ - return null; - } -}; -cc.loader.register(["font", "eot", "ttf", "woff", "svg"], cc._fontLoader); - cc._binaryLoader = { load : function(realUrl, url){ return cc.loader.loadBinarySync(realUrl); diff --git a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/jsb_property_apis.js b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/jsb_property_apis.js index c50f4b9f87..e80bc6aa33 100755 --- a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/jsb_property_apis.js +++ b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/jsb_property_apis.js @@ -43,6 +43,13 @@ cc.defineGetterSetter(_proto, "opacity", _proto.getOpacity, _proto.setOpacity); cc.defineGetterSetter(_proto, "opacityModifyRGB", _proto.isOpacityModifyRGB, _proto.setOpacityModifyRGB); cc.defineGetterSetter(_proto, "color", _proto.getColor, _proto.setColor); +_proto = cc.Label.prototype; +cc.defineGetterSetter(_proto, "size", _proto.getContentSize, _proto.setContentSize); +cc.defineGetterSetter(_proto, "width", _proto._getWidth, _proto._setWidth); +cc.defineGetterSetter(_proto, "height", _proto._getHeight, _proto._setHeight); +cc.defineGetterSetter(_proto, "boundingWidth", _proto.getWidth, _proto.setWidth); +cc.defineGetterSetter(_proto, "boundingHeight", _proto.getHeight, _proto.setHeight); + _proto = cc.LabelTTF.prototype; cc.defineGetterSetter(_proto, "size", _proto.getContentSize, _proto.setContentSize); cc.defineGetterSetter(_proto, "width", _proto._getWidth, _proto._setWidth); @@ -260,6 +267,7 @@ _proto = cc.LabelBMFont.prototype; cc.defineGetterSetter(_proto, "string", _proto.getString, _proto._setStringForSetter); cc.defineGetterSetter(_proto, "textAlign", _proto._getAlignment, _proto.setAlignment); cc.defineGetterSetter(_proto, "boundingWidth", _proto._getBoundingWidth, _proto.setBoundingWidth); +cc.defineGetterSetter(_proto, "boundingHeight", _proto._getBoundingHeight, _proto.setBoundingHeight); _proto = cc.Menu.prototype; cc.defineGetterSetter(_proto, "enabled", _proto.getEnabled, _proto.setEnabled); diff --git a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/studio/jsb_cocos2d_studio.js b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/studio/jsb_cocos2d_studio.js index 7fec49dc03..71f1a443d5 100755 --- a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/studio/jsb_cocos2d_studio.js +++ b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/studio/jsb_cocos2d_studio.js @@ -63,6 +63,9 @@ if(ccs.Armature){ ccs.Armature.extend = cc.Class.extend; } +ccs.Armature.prototype._setBlendFunc = ccs.Armature.prototype.setBlendFunc; +ccs.Armature.prototype.setBlendFunc = templateSetBlendFunc; + ccs.sendEvent = function (event) { var triggerObjArr = ccs.triggerManager.get(event); diff --git a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/studio/jsb_studio_create_apis.js b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/studio/jsb_studio_create_apis.js index 1f7f7fd091..55ee7b08ac 100755 --- a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/studio/jsb_studio_create_apis.js +++ b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/studio/jsb_studio_create_apis.js @@ -96,5 +96,8 @@ ccs.ActionTimelineData.prototype._ctor = function(actionTag) { { ccs.ActionTimelineData.prototype.init.call(this,actionTag); } +}; +ccs.ObjectExtensionData.prototype._ctor = function() { + ccs.ObjectExtensionData.prototype.init.call(this); }; \ No newline at end of file diff --git a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/studio/jsb_studio_load.js b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/studio/jsb_studio_load.js index 4a46b956b7..8578034ee0 100755 --- a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/studio/jsb_studio_load.js +++ b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/studio/jsb_studio_load.js @@ -26,11 +26,12 @@ ccs._load = (function(){ /** * load file - * @param file - * @param type - ccui|node|action + * @param {String} file + * @param {String} [type=] - ccui|node|action + * @param {String} [path=] - Resource search path * @returns {*} */ - var load = function(file, type){ + var load = function(file, type, path){ var json = cc.loader.getRes(file); @@ -71,7 +72,7 @@ ccs._load = (function(){ return new cc.Node(); } - return currentParser.parse(file, json) || null; + return currentParser.parse(file, json, path) || null; }; var parser = { @@ -176,16 +177,17 @@ ccs._parser = cc.Class.extend({ * action 1.* - 2.* * scene 0.* - 1.* * @param {String} file + * @param {String} [path=] Resource path * @returns {{node: cc.Node, action: cc.Action}} */ -ccs.load = function(file){ +ccs.load = function(file, path){ var object = { node: null, action: null }; - object.node = ccs._load(file); - object.action = ccs._load(file, "action"); + object.node = ccs._load(file, null, path); + object.action = ccs._load(file, "action", path); if(object.action && object.action.tag === -1 && object.node) object.action.tag = object.node.tag; return object; diff --git a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/studio/parsers/action-2.x.js b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/studio/parsers/action-2.x.js index 56e83c834d..555ec76181 100755 --- a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/studio/parsers/action-2.x.js +++ b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/studio/parsers/action-2.x.js @@ -230,6 +230,10 @@ var singleFrameIndex = options["SingleFrameIndex"]; + var frameIndex = options["FrameIndex"]; + if(frameIndex !== undefined) + frame.setFrameIndex(frameIndex); + frame.setInnerActionType(ccs.InnerActionType[innerActionType]); frame.setSingleFrameIndex(singleFrameIndex); diff --git a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/studio/parsers/timelineParser-2.x.js b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/studio/parsers/timelineParser-2.x.js index 786ed9e867..6b5ab6ed54 100755 --- a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/studio/parsers/timelineParser-2.x.js +++ b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/studio/parsers/timelineParser-2.x.js @@ -28,8 +28,12 @@ var Parser = baseParser.extend({ - parse: function(file, json){ - var resourcePath = this._dirname(file); + parse: function(file, json, path){ + var resourcePath; + if(path !== undefined) + resourcePath = path; + else + resourcePath = this._dirname(file); this.pretreatment(json, resourcePath, file); var node = this.parseNode(this.getNodeJson(json), resourcePath); this.deferred(json, resourcePath, node, file); @@ -102,12 +106,22 @@ setContentSize(node, json["Size"]); - if (json["Alpha"] != null) + if (json["Alpha"] !== undefined) node.setOpacity(json["Alpha"]); node.setTag(json["Tag"] || 0); - node.setUserObject(new ccs.ActionTimelineData(json["ActionTag"] || 0)); + var actionTag = json["ActionTag"] || 0; + if (cc.sys.isNative){ + var extensionData = new ccs.ObjectExtensionData(); + var customProperty = json["UserData"]; + if(customProperty !== undefined) + extensionData.setCustomProperty(customProperty); + extensionData.setActionTag(actionTag); + node.setUserObject(extensionData); + } else { + node.setUserObject(new ccs.ActionTimelineData(actionTag)); + } node.setCascadeColorEnabled(true); node.setCascadeOpacityEnabled(true); @@ -169,7 +183,6 @@ var spriteFrame = cc.spriteFrameCache.getSpriteFrame(path); node.setSpriteFrame(spriteFrame); } - }); if(json["FlipX"]) @@ -209,7 +222,7 @@ // WIDGET // //////////// - parser.widgetAttributes = function(widget, json){ + parser.widgetAttributes = function(widget, json) { widget.setCascadeColorEnabled(true); widget.setCascadeOpacityEnabled(true); @@ -219,33 +232,43 @@ setContentSize(widget, json["Size"]); var name = json["Name"]; - if(name) + if (name) widget.setName(name); var actionTag = json["ActionTag"] || 0; widget.setActionTag(actionTag); - widget.setUserObject(new ccs.ActionTimelineData(actionTag)); + + if (cc.sys.isNative){ + var extensionData = new ccs.ObjectExtensionData(); + var customProperty = json["UserData"]; + if(customProperty !== undefined) + extensionData.setCustomProperty(customProperty); + extensionData.setActionTag(actionTag); + widget.setUserObject(extensionData); + } else { + widget.setUserObject(new ccs.ActionTimelineData(actionTag)); + } var rotationSkewX = json["RotationSkewX"]; - if(rotationSkewX) + if (rotationSkewX) widget.setRotationX(rotationSkewX); var rotationSkewY = json["RotationSkewY"]; - if(rotationSkewY) + if (rotationSkewY) widget.setRotationY(rotationSkewY); //var rotation = json["Rotation"]; var flipX = json["FlipX"]; - if(flipX) + if (flipX) widget.setFlippedX(true); var flipY = json["FlipY"]; - if(flipY) + if (flipY) widget.setFlippedY(true); var zOrder = json["zOrder"]; - if(zOrder != null) + if (zOrder != null) widget.setLocalZOrder(zOrder); //var visible = json["Visible"]; @@ -254,7 +277,7 @@ widget.setVisible(visible); var alpha = json["Alpha"]; - if(alpha != null) + if (alpha != null) widget.setOpacity(alpha); widget.setTag(json["Tag"] || 0); @@ -265,19 +288,19 @@ // -- var frameEvent = json["FrameEvent"]; var callBackType = json["CallBackType"]; - if(callBackType != null) + if (callBackType != null) widget.setCallbackType(callBackType); var callBackName = json["CallBackName"]; - if(callBackName) + if (callBackName) widget.setCallbackName(callBackName); var position = json["Position"]; - if(position != null) + if (position != null) widget.setPosition(position["X"] || 0, position["Y"] || 0); var scale = json["Scale"]; - if(scale != null){ + if (scale != null) { var scaleX = getParam(scale["ScaleX"], 1); var scaleY = getParam(scale["ScaleY"], 1); widget.setScaleX(scaleX); @@ -285,80 +308,79 @@ } var anchorPoint = json["AnchorPoint"]; - if(anchorPoint != null) + if (anchorPoint != null) widget.setAnchorPoint(anchorPoint["ScaleX"] || 0, anchorPoint["ScaleY"] || 0); var color = json["CColor"]; - if(color != null) + if (color != null) widget.setColor(getColor(color)); - if(widget instanceof ccui.Layout){ - var layoutComponent = ccui.LayoutComponent.bindLayoutComponent(widget); - - var positionXPercentEnabled = json["PositionPercentXEnable"] || false; - var positionYPercentEnabled = json["PositionPercentYEnable"] || false; - var positionXPercent = 0, - positionYPercent = 0, - PrePosition = json["PrePosition"]; - if(PrePosition != null){ - positionXPercent = PrePosition["X"] || 0; - positionYPercent = PrePosition["Y"] || 0; - } - var sizeXPercentEnable = json["PercentWidthEnable"] || false; - var sizeYPercentEnable = json["PercentHeightEnable"] || false; - var sizeXPercent = 0, - sizeYPercent = 0, - PreSize = json["PreSize"]; - if(PrePosition != null){ - sizeXPercent = PreSize["X"] || 0; - sizeYPercent = PreSize["Y"] || 0; - } - var stretchHorizontalEnabled = json["StretchWidthEnable"] || false; - var stretchVerticalEnabled = json["StretchHeightEnable"] || false; - var horizontalEdge = json["HorizontalEdge"];// = ccui.LayoutComponent.horizontalEdge.LEFT; - var verticalEdge = json["VerticalEdge"]; // = ccui.LayoutComponent.verticalEdge.TOP; - var leftMargin = json["LeftMargin"] || 0; - var rightMargin = json["RightMargin"] || 0; - var topMargin = json["TopMargin"] || 0; - var bottomMargin = json["BottomMargin"] || 0; - - layoutComponent.setPositionPercentXEnabled(positionXPercentEnabled); - layoutComponent.setPositionPercentYEnabled(positionYPercentEnabled); - layoutComponent.setPositionPercentX(positionXPercent); - layoutComponent.setPositionPercentY(positionYPercent); - layoutComponent.setPercentWidthEnabled(sizeXPercentEnable); - layoutComponent.setPercentHeightEnabled(sizeYPercentEnable); - layoutComponent.setPercentWidth(sizeXPercent); - layoutComponent.setPercentHeight(sizeYPercent); - layoutComponent.setStretchWidthEnabled(stretchHorizontalEnabled); - layoutComponent.setStretchHeightEnabled(stretchVerticalEnabled); - - var horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.NONE; - if (horizontalEdge == "LeftEdge"){ - horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.LEFT; - }else if (horizontalEdge == "RightEdge"){ - horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.RIGHT; - }else if (horizontalEdge == "BothEdge"){ - horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.CENTER; - } - layoutComponent.setHorizontalEdge(horizontalEdgeType); - - var verticalEdgeType = ccui.LayoutComponent.verticalEdge.NONE; - if (verticalEdge == "TopEdge"){ - verticalEdgeType = ccui.LayoutComponent.verticalEdge.TOP; - }else if (verticalEdge == "BottomEdge"){ - verticalEdgeType = ccui.LayoutComponent.verticalEdge.BOTTOM; - }else if (verticalEdge == "BothEdge"){ - verticalEdgeType = ccui.LayoutComponent.verticalEdge.CENTER; - } - layoutComponent.setVerticalEdge(verticalEdgeType); - - layoutComponent.setTopMargin(topMargin); - layoutComponent.setBottomMargin(bottomMargin); - layoutComponent.setLeftMargin(leftMargin); - layoutComponent.setRightMargin(rightMargin); + var layoutComponent = ccui.LayoutComponent.bindLayoutComponent(widget); + if(!layoutComponent) + return; + + var positionXPercentEnabled = json["PositionPercentXEnable"] || false; + var positionYPercentEnabled = json["PositionPercentYEnable"] || false; + var positionXPercent = 0, + positionYPercent = 0, + PrePosition = json["PrePosition"]; + if (PrePosition != null) { + positionXPercent = PrePosition["X"] || 0; + positionYPercent = PrePosition["Y"] || 0; + } + var sizeXPercentEnable = json["PercentWidthEnable"] || false; + var sizeYPercentEnable = json["PercentHeightEnable"] || false; + var sizeXPercent = 0, + sizeYPercent = 0, + PreSize = json["PreSize"]; + if (PrePosition != null) { + sizeXPercent = PreSize["X"] || 0; + sizeYPercent = PreSize["Y"] || 0; } + var stretchHorizontalEnabled = json["StretchWidthEnable"] || false; + var stretchVerticalEnabled = json["StretchHeightEnable"] || false; + var horizontalEdge = json["HorizontalEdge"];// = ccui.LayoutComponent.horizontalEdge.LEFT; + var verticalEdge = json["VerticalEdge"]; // = ccui.LayoutComponent.verticalEdge.TOP; + var leftMargin = json["LeftMargin"] || 0; + var rightMargin = json["RightMargin"] || 0; + var topMargin = json["TopMargin"] || 0; + var bottomMargin = json["BottomMargin"] || 0; + + layoutComponent.setPositionPercentXEnabled(positionXPercentEnabled); + layoutComponent.setPositionPercentYEnabled(positionYPercentEnabled); + layoutComponent.setPositionPercentX(positionXPercent); + layoutComponent.setPositionPercentY(positionYPercent); + layoutComponent.setPercentWidthEnabled(sizeXPercentEnable); + layoutComponent.setPercentHeightEnabled(sizeYPercentEnable); + layoutComponent.setPercentWidth(sizeXPercent); + layoutComponent.setPercentHeight(sizeYPercent); + layoutComponent.setStretchWidthEnabled(stretchHorizontalEnabled); + layoutComponent.setStretchHeightEnabled(stretchVerticalEnabled); + + var horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.NONE; + if (horizontalEdge == "LeftEdge") { + horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.LEFT; + } else if (horizontalEdge == "RightEdge") { + horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.RIGHT; + } else if (horizontalEdge == "BothEdge") { + horizontalEdgeType = ccui.LayoutComponent.horizontalEdge.CENTER; + } + layoutComponent.setHorizontalEdge(horizontalEdgeType); + + var verticalEdgeType = ccui.LayoutComponent.verticalEdge.NONE; + if (verticalEdge == "TopEdge") { + verticalEdgeType = ccui.LayoutComponent.verticalEdge.TOP; + } else if (verticalEdge == "BottomEdge") { + verticalEdgeType = ccui.LayoutComponent.verticalEdge.BOTTOM; + } else if (verticalEdge == "BothEdge") { + verticalEdgeType = ccui.LayoutComponent.verticalEdge.CENTER; + } + layoutComponent.setVerticalEdge(verticalEdgeType); + layoutComponent.setTopMargin(topMargin); + layoutComponent.setBottomMargin(bottomMargin); + layoutComponent.setLeftMargin(leftMargin); + layoutComponent.setRightMargin(rightMargin); }; /** @@ -413,15 +435,12 @@ } - var bgStartColor = json["FirstColor"]; - var bgEndColor = json["EndColor"]; - if(bgStartColor != null && bgEndColor != null){ - var startC = getColor(bgStartColor); - if(bgEndColor["R"] == null && bgEndColor["G"] == null && bgEndColor["B"] == null) - widget.setBackGroundColor( startC ); - else - widget.setBackGroundColor( startC, getColor(bgEndColor) ); - } + var firstColor = json["FirstColor"]; + var endColor = json["EndColor"]; + if(endColor["R"] != null && endColor["G"] != null && endColor["B"] != null) + widget.setBackGroundColor(getColor(firstColor), getColor(endColor)); + else + widget.setBackGroundColor(getColor(json["SingleColor"])); var colorVector = json["ColorVector"]; if(colorVector != null) @@ -579,10 +598,10 @@ widget.setUnifySizeEnabled(false); widget.ignoreContentAdaptWithSize(false); var capInsets = cc.rect( - json["Scale9OriginX"] || 0, - json["Scale9OriginY"] || 0, - json["Scale9Width"] || 0, - json["Scale9Height"] || 0 + json["Scale9OriginX"] || 0, + json["Scale9OriginY"] || 0, + json["Scale9Width"] || 0, + json["Scale9Height"] || 0 ); widget.setCapInsets(capInsets); @@ -639,6 +658,10 @@ this.widgetAttributes(widget, json); + loadTexture(json["FileData"], resourcePath, function(path, type){ + widget.setBackGroundImage(path, type); + }); + var clipEnabled = json["ClipAble"]; widget.setClippingEnabled(clipEnabled); @@ -685,14 +708,10 @@ widget.setBackGroundColorVector(cc.p(colorVectorX, colorVectorY)); } - loadTexture(json["FileData"], resourcePath, function(path, type){ - widget.setBackGroundImage(path, type); - }); - var innerNodeSize = json["InnerNodeSize"]; var innerSize = cc.size( - innerNodeSize["Width"] || 0, - innerNodeSize["Height"] || 0 + innerNodeSize["Width"] || 0, + innerNodeSize["Height"] || 0 ); widget.setInnerContainerSize(innerSize); @@ -823,6 +842,10 @@ this.widgetAttributes(widget, json); + loadTexture(json["FileData"], resourcePath, function(path, type){ + widget.setBackGroundImage(path, type); + }); + var clipEnabled = json["ClipAble"] || false; widget.setClippingEnabled(clipEnabled); @@ -863,10 +886,6 @@ if(bgColorOpacity != null) widget.setBackGroundColorOpacity(bgColorOpacity); - loadTexture(json["FileData"], resourcePath, function(path, type){ - widget.setBackGroundImage(path, type); - }); - setContentSize(widget, json["Size"]); return widget; @@ -885,6 +904,10 @@ this.widgetAttributes(widget, json); + loadTexture(json["FileData"], resourcePath, function(path, type){ + widget.setBackGroundImage(path, type); + }); + var clipEnabled = json["ClipAble"] || false; widget.setClippingEnabled(clipEnabled); @@ -958,11 +981,6 @@ if(bgColorOpacity != null) widget.setBackGroundColorOpacity(bgColorOpacity); - - loadTexture(json["FileData"], resourcePath, function(path, type){ - widget.setBackGroundImage(path, type); - }); - setContentSize(widget, json["Size"]); return widget; @@ -1147,10 +1165,13 @@ if(projectFile != null && projectFile["Path"]){ var file = resourcePath + projectFile["Path"]; if(cc.loader.getRes(file)){ - var obj = ccs.load(file); + var obj = ccs.load(file, resourcePath); parser.generalAttributes(obj.node, json); if(obj.action && obj.node){ obj.action.tag = obj.node.tag; + var InnerActionSpeed = json["InnerActionSpeed"]; + if(InnerActionSpeed !== undefined) + obj.action.setTimeSpeed(InnerActionSpeed); obj.node.runAction(obj.action); obj.action.gotoFrameAndPause(0); } @@ -1249,8 +1270,170 @@ node.setContentSize(cc.size(x, y)); }; + var get3DVector = function(json, name, defValue){ + var x = defValue, y = defValue, z = defValue; + if(json && name && json[name]){ + x = null != json[name]["ValueX"] ? json[name]["ValueX"] : defValue; + y = null != json[name]["ValueY"] ? json[name]["ValueY"] : defValue; + z = null != json[name]["ValueZ"] ? json[name]["ValueZ"] : defValue; + } + var vec3 = cc.math.vec3(x, y, z); + return vec3; + }; + + parser.general3DAttributes = function(node, json){ + var pos = get3DVector(json, "Position3D", 0); + node.setPosition3D(pos); + + var rotation = get3DVector(json, "Rotation3D", 0); + node.setRotation3D(rotation); + + var scale = get3DVector(json, "Scale3D", 1.0); + node.setScaleX(scale.x); + node.setScaleY(scale.y); + node.setScaleZ(scale.z); + + var camMask =json["CameraFlagMode"]; + if(undefined !== camMask && null !== camMask) + node.setCameraMask(camMask); + + this.generalAttributes(node, json); + }; + + /** + * Node3D + * @param json + * @returns {*} + */ + parser.initNode3D = function(json){ + var node = cc.Node.create(); + if(node) + this.general3DAttributes(node, json); + return node; + }; + + /** + * Camera + * @param json + * @returns {*} + */ + parser.initCamera = function(json){ + var s = cc.winSize; + var fov = json["Fov"] ? json["Fov"] : 60; + + var nearClip = 1; + var farClip = 500; + if(json["ClipPlane"]){ + nearClip = json["ClipPlane"]["ValueX"]; + farClip = json["ClipPlane"]["ValueY"]; + if(null === nearClip || isNaN(nearClip)) + nearClip = 1; + if(null === farClip || isNaN(farClip)) + farClip = 500; + } + + var node = cc.Camera.createPerspective(fov, s.width/s.height, nearClip, farClip); + + if(node){ + this.general3DAttributes(node, json); + + var camMode = json["UserCameraFlagMode"]; + switch(camMode){ + case "USER1": + node.setCameraFlag(cc.CameraFlag.USER1); break; + case "USER2": + node.setCameraFlag(cc.CameraFlag.USER2); break; + case "USER3": + node.setCameraFlag(cc.CameraFlag.USER3); break; + case "USER4": + node.setCameraFlag(cc.CameraFlag.USER4); break; + case "USER5": + node.setCameraFlag(cc.CameraFlag.USER5); break; + case "USER6": + node.setCameraFlag(cc.CameraFlag.USER6); break; + case "USER7": + node.setCameraFlag(cc.CameraFlag.USER7); break; + case "USER8": + node.setCameraFlag(cc.CameraFlag.USER8); break; + case "DEFAULT": + node.setCameraFlag(cc.CameraFlag.DEFAULT); break; + default: + node.setCameraFlag(cc.CameraFlag.USER1); + } + } + + return node; + }; + + /** + * Sprite3D + * @param json + * @param resourcePath + * @returns {*} + */ + parser.initSprite3D = function(json, resourcePath){ + var resFile = null; + if(json["FileData"] && json["FileData"]["Path"]) + resFile = resourcePath + json["FileData"]["Path"]; + + var node; + if(resFile) + node = jsb.Sprite3D.create(resFile); + else + node = jsb.Sprite3D.create(); + + if(node) { + this.general3DAttributes(node, json); + + if(json["CColor"]) { + var col = getColor(json["CColor"]); + if(col && col.r !== 255 || col.g !== 255 || col.b !== 255) + node.setColor(col); + } + + var autoAction = getParam(json["RunAction3D"], false); + if(autoAction && resFile){ + var animation = jsb.Animation3D.create(resFile, ""); + if(animation){ + var animate = jsb.Animate3D.create(animation); + var action = cc.RepeatForever.create(animate); + node.runAction(action); + } + } + } + + return node; + }; + + /** + * Particle3D + * @param json + * @param resourcePath + * @returns {*} + */ + parser.initParticle3D = function(json, resourcePath){ + var node = null; + + var resFile = null; + if(json["FileData"] && json["FileData"]["Path"]) + resFile = resourcePath+json["FileData"]["Path"]; + + if(resFile) + node = jsb.PUParticleSystem3D.create(resFile); + else + node = jsb.PUParticleSystem3D.create(); + + if(node){ + this.general3DAttributes(node, json); + node.startParticleSystem(); + } + + return node; + }; + var register = [ {name: "SingleNodeObjectData", handle: parser.initSingleNode}, + {name: "NodeObjectData", handle: parser.initSingleNode}, {name: "LayerObjectData", handle: parser.initSingleNode}, {name: "SpriteObjectData", handle: parser.initSprite}, {name: "ParticleObjectData", handle: parser.initParticle}, @@ -1270,7 +1453,12 @@ {name: "SimpleAudioObjectData", handle: parser.initSimpleAudio}, {name: "GameMapObjectData", handle: parser.initGameMap}, {name: "ProjectNodeObjectData", handle: parser.initProjectNode}, - {name: "ArmatureNodeObjectData", handle: parser.initArmature} + {name: "ArmatureNodeObjectData", handle: parser.initArmature}, + + {name: "Sprite3DObjectData", handle: parser.initSprite3D}, + {name: "Particle3DObjectData", handle: parser.initParticle3D}, + {name: "UserCameraObjectData", handle: parser.initCamera}, + {name: "Node3DObjectData", handle: parser.initNode3D} ]; register.forEach(function(item){ diff --git a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/studio/parsers/uiParser-1.x.js b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/studio/parsers/uiParser-1.x.js index 41500f531f..a6762cac64 100755 --- a/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/studio/parsers/uiParser-1.x.js +++ b/templates/js-template-runtime/runtime/mac/PrebuiltRuntimeJs.app/Contents/Resources/script/studio/parsers/uiParser-1.x.js @@ -458,6 +458,7 @@ /** * Text parser (UIText) */ + var regTTF = /\.ttf$/; parser.TextAttributes = function(widget, options, resourcePath){ var touchScaleChangeAble = options["touchScaleEnable"]; widget.setTouchScaleChangeEnabled(touchScaleChangeAble); @@ -469,7 +470,15 @@ } var fn = options["fontName"]; if (fn != null){ - widget.setFontName(options["fontName"]); + if(cc.sys.isNative){ + if(regTTF.test(fn)){ + widget.setFontName(cc.path.join(cc.loader.resPath, resourcePath, fn)); + }else{ + widget.setFontName(fn); + } + }else{ + widget.setFontName(fn.replace(regTTF, '')); + } } var aw = options["areaWidth"]; var ah = options["areaHeight"]; @@ -599,7 +608,7 @@ /** * TextField parser (UITextField) */ - parser.TextFieldAttributes = function(widget, options, resoutcePath){ + parser.TextFieldAttributes = function(widget, options, resourcePath){ var ph = options["placeHolder"]; if(ph) widget.setPlaceHolder(ph); @@ -608,8 +617,17 @@ if(fs) widget.setFontSize(fs); var fn = options["fontName"]; - if(fn) - widget.setFontName(fn); + if (fn != null){ + if(cc.sys.isNative){ + if(regTTF.test(fn)){ + widget.setFontName(cc.path.join(cc.loader.resPath, resourcePath, fn)); + }else{ + widget.setFontName(fn); + } + }else{ + widget.setFontName(fn.replace(regTTF, '')); + } + } var tsw = options["touchSizeWidth"]; var tsh = options["touchSizeHeight"]; if(tsw!=null && tsh!=null) diff --git a/templates/js-template-runtime/runtime/win32/PrebuiltRuntimeJs.exe b/templates/js-template-runtime/runtime/win32/PrebuiltRuntimeJs.exe index 6194868f27..94c00ac837 100755 Binary files a/templates/js-template-runtime/runtime/win32/PrebuiltRuntimeJs.exe and b/templates/js-template-runtime/runtime/win32/PrebuiltRuntimeJs.exe differ diff --git a/templates/js-template-runtime/runtime/win32/libcocos2d.dll b/templates/js-template-runtime/runtime/win32/libcocos2d.dll index 3b95972bde..03e60e1d74 100755 Binary files a/templates/js-template-runtime/runtime/win32/libcocos2d.dll and b/templates/js-template-runtime/runtime/win32/libcocos2d.dll differ diff --git a/templates/js-template-runtime/runtime/win32/mozjs-33.dll b/templates/js-template-runtime/runtime/win32/mozjs-33.dll new file mode 100755 index 0000000000..ba943abf81 Binary files /dev/null and b/templates/js-template-runtime/runtime/win32/mozjs-33.dll differ