diff --git a/cocos2d/core/CCDirector.js b/cocos2d/core/CCDirector.js index 1598d17e5d..9837408cba 100644 --- a/cocos2d/core/CCDirector.js +++ b/cocos2d/core/CCDirector.js @@ -405,7 +405,7 @@ cc.Director = Class.extend(/** @lends cc.Director# */{ /** * !#en Pause the director's ticker. - * !#zh 暂停正在运行的场景。 + * !#zh 暂停正在运行的场景,该暂停只会停止 Scheduler,但是不会停止渲染和 UI 响应。 * @method pause */ pause: function () { @@ -816,7 +816,7 @@ cc.Director = Class.extend(/** @lends cc.Director# */{ /** * !#en Resume director after pause, if the current scene is not paused, nothing will happen. - * !#zh 恢复暂停场景, 如果当前场景没有暂停将没任何事情发生。 + * !#zh 恢复暂停场景,恢复 Scheduler,如果当前场景没有暂停将没任何事情发生。 * @method resume */ resume: function () { diff --git a/cocos2d/core/CCGame.js b/cocos2d/core/CCGame.js index 2ce30aa4b7..4aefa82ddd 100644 --- a/cocos2d/core/CCGame.js +++ b/cocos2d/core/CCGame.js @@ -240,8 +240,8 @@ var game = /** @lends cc.game# */{ }, /** - * !#en Pause the game. - * !#zh 暂停游戏。 + * !#en Pause the game,pause main loop. + * !#zh 暂停游戏,暂停的是整个主循环。 * @method pause */ pause: function () { @@ -257,7 +257,7 @@ var game = /** @lends cc.game# */{ /** * !#en Resume the game from pause. - * !#zh 继续游戏 + * !#zh 继续游戏,继续的是整个主循环。 * @method resume */ resume: function () { diff --git a/cocos2d/core/collider/CCCollisionManager.js b/cocos2d/core/collider/CCCollisionManager.js index 10b5e8580d..71121113b2 100644 --- a/cocos2d/core/collider/CCCollisionManager.js +++ b/cocos2d/core/collider/CCCollisionManager.js @@ -8,10 +8,10 @@ var CollisionType = Contact.CollisionType; * !#zh * 一个简单的碰撞组件管理类,用于处理节点之间的碰撞组件是否产生了碰撞,并调用相应回调函数。 * - * @class ColliderManager + * @class CollisionManager * @example * - * // Get the collider manager. + * // Get the collision manager. * var manager = cc.director.getCollisionManager(); * * // Enabled the colider manager. @@ -24,7 +24,7 @@ var CollisionType = Contact.CollisionType; * manager.enabledDrawBoundingBox = true; * * - * // Collider callback + * // Collision callback * onCollisionEnter: function (other, self) { * this.node.color = cc.Color.RED; * this.touchingNumber ++; diff --git a/cocos2d/core/collider/CCIntersection.js b/cocos2d/core/collider/CCIntersection.js index 59f33f4da6..ef5fab661b 100644 --- a/cocos2d/core/collider/CCIntersection.js +++ b/cocos2d/core/collider/CCIntersection.js @@ -7,11 +7,13 @@ var Intersection = {}; /** + * !#en Test line and line + * !#zh 测试线段与线段是否相交 * @method lineLine - * @param {Vec2} a1 - * @param {Vec2} a2 - * @param {Vec2} b1 - * @param {Vec2} b2 + * @param {Vec2} a1 - The start point of the first line + * @param {Vec2} a2 - The end point of the first line + * @param {Vec2} b1 - The start point of the second line + * @param {Vec2} b2 - The end point of the second line * @return {boolean} */ function lineLine ( a1, a2, b1, b2 ) { @@ -36,10 +38,12 @@ function lineLine ( a1, a2, b1, b2 ) { Intersection.lineLine = lineLine; /** + * !#en Test line and rect + * !#zh 测试线段与矩形是否相交 * @method lineRect - * @param {Vec2} a1 - * @param {Vec2} a2 - * @param {Vec2} b + * @param {Vec2} a1 - The start point of the line + * @param {Vec2} a2 - The end point of the line + * @param {Rect} b - The rect * @return {boolean} */ function lineRect ( a1, a2, b ) { @@ -66,10 +70,12 @@ function lineRect ( a1, a2, b ) { Intersection.lineRect = lineRect; /** + * !#en Test line and polygon + * !#zh 测试线段与多边形是否相交 * @method linePolygon - * @param {Vec2} a1 - * @param {Vec2} a2 - * @param {[Vec2]} b + * @param {Vec2} a1 - The start point of the line + * @param {Vec2} a2 - The end point of the line + * @param {[Vec2]} b - The polygon, a set of points * @return {boolean} */ function linePolygon ( a1, a2, b ) { @@ -89,9 +95,11 @@ function linePolygon ( a1, a2, b ) { Intersection.linePolygon = linePolygon; /** + * !#en Test rect and rect + * !#zh 测试矩形与矩形是否相交 * @method rectRect - * @param {Rect} a - * @param {Rect} b + * @param {Rect} a - The first rect + * @param {Rect} b - The second rect * @return {boolean} */ function rectRect ( a, b ) { @@ -117,9 +125,11 @@ function rectRect ( a, b ) { Intersection.rectRect = rectRect; /** + * !#en Test rect and polygon + * !#zh 测试矩形与多边形是否相交 * @method rectPolygon - * @param {Rect} a - * @param {[Vec2]} b + * @param {Rect} a - The rect + * @param {[Vec2]} b - The polygon, a set of points * @return {boolean} */ function rectPolygon ( a, b ) { @@ -167,9 +177,11 @@ function rectPolygon ( a, b ) { Intersection.rectPolygon = rectPolygon; /** + * !#en Test polygon and polygon + * !#zh 测试多边形与多边形是否相交 * @method polygonPolygon - * @param {[Vec2]} a - * @param {[Vec2]} b + * @param {[Vec2]} a - The first polygon, a set of points + * @param {[Vec2]} b - The second polygon, a set of points * @return {boolean} */ function polygonPolygon ( a, b ) { @@ -202,36 +214,10 @@ function polygonPolygon ( a, b ) { Intersection.polygonPolygon = polygonPolygon; -/** - * @method pointInPolygon - * @param {Vec2} point - * @param {[Vec2]} polygon - * @return {boolean} - */ -function pointInPolygon (point, polygon) { - var inside = false; - var x = point.x; - var y = point.y; - - // use some raycasting to test hits - // https://github.com/substack/point-in-polygon/blob/master/index.js - var length = polygon.length; - - for ( var i = 0, j = length-1; i < length; j = i++ ) { - var xi = polygon[i].x, yi = polygon[i].y, - xj = polygon[j].x, yj = polygon[j].y, - intersect = ((yi > y) !== (yj > y)) && (x < (xj - xi) * (y - yi) / (yj - yi) + xi); - - if ( intersect ) inside = !inside; - } - - return inside; -} - -Intersection.pointInPolygon = pointInPolygon; - /** + * !#en Test circle and circle + * !#zh 测试圆形与圆形是否相交 * @method circleCircle * @param {Object} a - Object contains position and radius * @param {Object} b - Object contains position and radius @@ -246,8 +232,10 @@ Intersection.circleCircle = circleCircle; /** + * !#en Test polygon and circle + * !#zh 测试矩形与圆形是否相交 * @method polygonCircle - * @param {[Vec2]} polygon + * @param {[Vec2]} polygon - The Polygon, a set of points * @param {Object} circle - Object contains position and radius * @return {boolean} */ @@ -271,13 +259,43 @@ function polygonCircle (polygon, circle) { Intersection.polygonCircle = polygonCircle; +/** + * !#en Test whether the point is in the polygon + * !#zh 测试一个点是否在一个多边形中 + * @method pointInPolygon + * @param {Vec2} point - The point + * @param {[Vec2]} polygon - The polygon, a set of points + * @return {boolean} + */ +function pointInPolygon (point, polygon) { + var inside = false; + var x = point.x; + var y = point.y; + + // use some raycasting to test hits + // https://github.com/substack/point-in-polygon/blob/master/index.js + var length = polygon.length; + + for ( var i = 0, j = length-1; i < length; j = i++ ) { + var xi = polygon[i].x, yi = polygon[i].y, + xj = polygon[j].x, yj = polygon[j].y, + intersect = ((yi > y) !== (yj > y)) && (x < (xj - xi) * (y - yi) / (yj - yi) + xi); + + if ( intersect ) inside = !inside; + } + + return inside; +} + +Intersection.pointInPolygon = pointInPolygon; + /** * !#en Calculate the distance of point to line. * !#zh 计算点到直线的距离。如果这是一条线段并且垂足不在线段内,则会计算点到线段端点的距离。 * @method pointLineDistance - * @param {Vec2} point - * @param {Vec2} start - start point of line - * @param {Vec2} end - end point of line + * @param {Vec2} point - The point + * @param {Vec2} start - The start point of line + * @param {Vec2} end - The end point of line * @param {boolean} isSegment - whether this line is a segment * @return {boolean} */ diff --git a/cocos2d/core/videoplayer/CCSGVideoPlayer.js b/cocos2d/core/videoplayer/CCSGVideoPlayer.js index d4f4c23606..e16e7da74f 100644 --- a/cocos2d/core/videoplayer/CCSGVideoPlayer.js +++ b/cocos2d/core/videoplayer/CCSGVideoPlayer.js @@ -57,9 +57,9 @@ _ccsg.VideoPlayer = _ccsg.Node.extend(/** @lends _ccsg.VideoPlayer# */{ this._renderCmd.pause(); }, - //resume: function () { - // this._renderCmd.resume(); - //}, + _resume: function () { + this._renderCmd.play(); + }, stop: function () { this._renderCmd.stop(); @@ -116,6 +116,10 @@ _ccsg.VideoPlayer = _ccsg.Node.extend(/** @lends _ccsg.VideoPlayer# */{ }, setContentSize: function (width, height) { + if (width.width !== undefined && width.height !== undefined) { + height = width.height; + width = width.width; + } _ccsg.Node.prototype.setContentSize.call(this, width, height); this._renderCmd.updateSize(width, height); }, @@ -139,6 +143,11 @@ _ccsg.VideoPlayer = _ccsg.Node.extend(/** @lends _ccsg.VideoPlayer# */{ var index = list.indexOf(this); if(index !== -1) list.splice(index, 1); + }, + + setVisible: function ( visible ) { + _ccsg.Node.prototype.setVisible.call(this, visible); + this._renderCmd.updateVisibility(); } }); @@ -207,14 +216,19 @@ _ccsg.VideoPlayer.EventType = { video._polyfill.canPlayType.push(".webm"); })(); - if(cc.sys.OS_IOS === cc.sys.os){ - video._polyfill.devicePixelRatio = true; - video._polyfill.event = "progress"; - } if(cc.sys.browserType === cc.sys.BROWSER_TYPE_FIREFOX){ video._polyfill.autoplayAfterOperation = true; } + if ( + cc.sys.OS_ANDROID === cc.sys.os && ( + cc.sys.browserType === cc.sys.BROWSER_TYPE_SOUGOU || + cc.sys.browserType === cc.sys.BROWSER_TYPE_360 + ) + ) { + video._polyfill.zoomInvalid = true; + } + var style = document.createElement("style"); style.innerHTML = ".cocosVideo:-moz-full-screen{transform:matrix(1,0,0,1,0,0) !important;}" + ".cocosVideo:full-screen{transform:matrix(1,0,0,1,0,0) !important;}" + @@ -234,6 +248,7 @@ _ccsg.VideoPlayer.EventType = { // 有一些浏览器第一次播放视频需要特殊处理,这个标记用来标识是否播放过 this._played = false; this._playing = false; + this._ignorePause = false; }; var proto = _ccsg.VideoPlayer.RenderCmd.prototype = Object.create(_ccsg.Node.CanvasRenderCmd.prototype); @@ -251,17 +266,27 @@ _ccsg.VideoPlayer.EventType = { proto.updateMatrix = function () { if (!this._video) return; var node = this._node, scaleX = cc.view._scaleX, scaleY = cc.view._scaleY; + var dpr = cc.view._devicePixelRatio; var t = node.getNodeToWorldTransform(); if (!t) return; - if(polyfill.devicePixelRatio){ - var dpr = window.devicePixelRatio; - scaleX /= dpr; - scaleY /= dpr; + scaleX /= dpr; + scaleY /= dpr; + + var container = cc.container; + var a = t.a * scaleX, b = t.b, c = t.c, d = t.d * scaleY; + + var offsetX = container && container.style.paddingLeft && parseInt(container.style.paddingLeft); + var offsetY = container && container.style.paddingBottom && parseInt(container.style.paddingBottom); + var tx = t.tx * scaleX + offsetX, ty = t.ty * scaleY + offsetY; + + if (polyfill.zoomInvalid) { + this.updateSize(node._contentSize.width * a, node._contentSize.height * d); + a = 1; + d = 1; } - var a = t.a * scaleX, b = t.b, c = t.c, d = t.d * scaleY; - var matrix = "matrix(" + a + "," + -b + "," + -c + "," + d + "," + t.tx + "," + -t.ty + ")"; + var matrix = "matrix(" + a + "," + -b + "," + -c + "," + d + "," + tx + "," + -ty + ")"; this._video.style['transform'] = matrix; this._video.style['-webkit-transform'] = matrix; this._video.style['transform-origin'] = '0px 100% 0px'; @@ -295,10 +320,9 @@ _ccsg.VideoPlayer.EventType = { if(this._loaded == true) return; this._loaded = true; - node.setContentSize(video.clientWidth, video.clientHeight); + node.setContentSize(node._contentSize.width, node._contentSize.height); video.removeEventListener(polyfill.event, cb); video.currentTime = 0; - video.style["visibility"] = "visible"; //IOS does not display video images video.play(); if(!this._played){ @@ -307,7 +331,8 @@ _ccsg.VideoPlayer.EventType = { } video.currentTime = 0; } - this.updateMatrix(this._worldTransform); + this.updateVisibility(); + this.updateMatrix(); }.bind(this); video.addEventListener(polyfill.event, cb); @@ -336,13 +361,16 @@ _ccsg.VideoPlayer.EventType = { var node = this._node, video = this._video, self = this; //binding event video.addEventListener("ended", function(){ + if (self._video !== video) return; this._playing = false; node._dispatchEvent(_ccsg.VideoPlayer.EventType.COMPLETED); }.bind(this)); video.addEventListener("play", function(){ + if (self._video !== video) return; node._dispatchEvent(_ccsg.VideoPlayer.EventType.PLAYING); }); video.addEventListener("pause", function(){ + if (self._ignorePause || self._video !== video) return; node._dispatchEvent(_ccsg.VideoPlayer.EventType.PAUSED); }); video.addEventListener("click", function () { @@ -354,6 +382,18 @@ _ccsg.VideoPlayer.EventType = { }); }; + proto.updateVisibility = function () { + var node = this._node; + if (!this._video) return; + var video = this._video; + if (node.visible) { + video.style.visibility = 'visible'; + } else { + video.style.visibility = 'hidden'; + video.pause(); + } + }; + proto.createDom = function () { var video = document.createElement('video'); video.style.position = "absolute"; @@ -404,19 +444,13 @@ _ccsg.VideoPlayer.EventType = { setTimeout(function(){ video.play(); self._playing = true; - self._stopped = false; }, 20); }else{ video.play(); this._playing = true; - this._stopped = false; } }; - //proto.resume = function () { - // this.play(); - //}; - proto.pause = function () { var video = this._video; if (!video) return; @@ -427,11 +461,13 @@ _ccsg.VideoPlayer.EventType = { proto.stop = function () { var video = this._video; if (!video) return; + this._ignorePause = true; video.pause(); var node = this._node; setTimeout(function(){ node._dispatchEvent(_ccsg.VideoPlayer.EventType.STOPPED); - }, 0); + this._ignorePause = false; + }.bind(this), 0); // 恢复到视频起始位置 video.currentTime = 0; this._playing = false; @@ -441,7 +477,15 @@ _ccsg.VideoPlayer.EventType = { var video = this._video; if (!video) return; - video.currentTime = sec; + if (this._loaded) { + video.currentTime = sec; + } else { + var cb = function () { + video.currentTime = sec; + video.removeEventListener(polyfill.event, cb); + }; + video.addEventListener(polyfill.event, cb); + } if(_ccsg.VideoPlayer._polyfill.autoplayAfterOperation && this.isPlaying()){ setTimeout(function(){ video.play(); diff --git a/extensions/spine/SGSkeleton.js b/extensions/spine/SGSkeleton.js index b126c189fc..09b2ecfaa1 100644 --- a/extensions/spine/SGSkeleton.js +++ b/extensions/spine/SGSkeleton.js @@ -281,7 +281,6 @@ sp._SGSkeleton = _ccsg.Node.extend({ this.setContentSize(skeletonData.width / cc.director.getContentScaleFactor(), skeletonData.height / cc.director.getContentScaleFactor()); this._skeleton = new spine.Skeleton(skeletonData); - this._skeleton.updateWorldTransform(); this._rootBone = this._skeleton.getRootBone(); this._ownsSkeletonData = ownsSkeletonData; diff --git a/extensions/spine/Skeleton.js b/extensions/spine/Skeleton.js index 3ab49eb2b9..339f09aa1f 100644 --- a/extensions/spine/Skeleton.js +++ b/extensions/spine/Skeleton.js @@ -439,6 +439,24 @@ sp.Skeleton = cc.Class({ // RENDERER + /** + * !#en Computes the world SRT from the local SRT for each bone. + * !#zh 重新更新所有骨骼的世界 Transform, + * 当获取 bone 的数值未更新时,即可使用该函数进行更新数值。 + * @method updateWorldTransform + * @example + * var bone = spine.findBone('head'); + * cc.log(bone.worldX); // return 0; + * spine.updateWorldTransform(); + * bone = spine.findBone('head'); + * cc.log(bone.worldX); // return -23.12; + */ + updateWorldTransform: function () { + if (this._sgNode) { + this._sgNode.updateWorldTransform(); + } + }, + /** * !#en Sets the bones and slots to the setup pose. * !#zh 还原到起始动作 diff --git a/gulp/tasks/build.js b/gulp/tasks/build.js index 544de5fb48..cb0545bdaf 100644 --- a/gulp/tasks/build.js +++ b/gulp/tasks/build.js @@ -29,10 +29,13 @@ var Del = require('del'); var gulp = require('gulp'); var mirror = require('gulp-mirror'); +var pipe = require('multipipe'); var uglify = require('gulp-uglify'); var rename = require('gulp-rename'); var sourcemaps = require('gulp-sourcemaps'); var es = require('event-stream'); +var size = require('gulp-size'); +var chalk = require('chalk'); var browserify = require('browserify'); var source = require('vinyl-source-stream'); @@ -86,31 +89,61 @@ function getUglifyOptions (minify, global_defs) { } } +function printSizes (sizeGetter, minSizeGetter, zippedSizeGetter) { + return es.through(null, function () { + console.log('Size of web engine: zipped: ' + chalk.cyan(zippedSizeGetter.size.toLocaleString() + 'B') + + ', minimized: ' + chalk.cyan(minSizeGetter.size.toLocaleString() + 'B') + + ', raw: ' + chalk.cyan(sizeGetter.size.toLocaleString() + 'B') + + ', compression ratio: ' + chalk.magenta((zippedSizeGetter.size / sizeGetter.size * 100).toFixed(2) + '%')); + this.emit('end'); + }); +} + function rebundle_html_dev_min(bundler) { - console.log('compiling...'); + console.log('Compiling ' + paths.outFileDev + ' and ' + paths.outFile + ' ...'); - var dev = uglify(getUglifyOptions(false, { - CC_EDITOR: false, - CC_DEV: true, - CC_TEST: false, - CC_JSB: false - })); + function createSizeGetter (gzip) { + return size({ + gzip: gzip, + pretty: false, + showTotal: false, + showFiles: false, + }); + } - var min = rename({ suffix: '-min' }); - min.pipe(uglify(getUglifyOptions(true, { + var sizeGetter = createSizeGetter(false); + var minSizeGetter = createSizeGetter(false); + var zippedSizeGetter = createSizeGetter(true); + + var devPipes = [ + uglify(getUglifyOptions(false, { + CC_EDITOR: false, + CC_DEV: true, + CC_TEST: false, + CC_JSB: false + })), + sizeGetter + ]; + var minPipes = [ + rename(paths.outFile), + uglify(getUglifyOptions(true, { CC_EDITOR: false, CC_DEV: false, CC_TEST: false, CC_JSB: false - }))); + })), + minSizeGetter, + zippedSizeGetter, + ]; return bundler.bundle() .on('error', handleErrors.handler) .pipe(handleErrors()) - .pipe(source(paths.outFile)) + .pipe(source(paths.outFileDev)) .pipe(buffer()) .pipe(sourcemaps.init({loadMaps: true})) - .pipe(mirror(dev, min)) + .pipe(mirror(pipe(devPipes), pipe(minPipes))) + .pipe(printSizes(sizeGetter, minSizeGetter, zippedSizeGetter)) .pipe(sourcemaps.write('./', {sourceRoot: './', addComment: true})) .pipe(gulp.dest(paths.outDir)); } @@ -128,7 +161,7 @@ function rebundle(bundler, name, options) { .pipe(buffer()); if (macros) { - console.log('compiling...'); + console.log('Compiling ' + name + ' ...'); if (sourceMaps) { bundle = bundle.pipe(sourcemaps.init({loadMaps: true})); } diff --git a/gulpfile.js b/gulpfile.js index 2850909777..c1036f20e1 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -34,7 +34,8 @@ paths = { src: './src', jsEntry: './index.js', outDir: './bin', - outFile: 'cocos2d-js.js', + outFileDev: 'cocos2d-js.js', + outFile: 'cocos2d-js-min.js', jsb: { entries: [ diff --git a/jsb/jsb-tex-sprite-frame.js b/jsb/jsb-tex-sprite-frame.js index 9e075a41ef..8a3d2adfce 100644 --- a/jsb/jsb-tex-sprite-frame.js +++ b/jsb/jsb-tex-sprite-frame.js @@ -62,13 +62,16 @@ cc.Texture2D.prototype.getPixelHeight = cc.Texture2D.prototype.getPixelsHigh; cc.Class._fastDefine('cc.SpriteFrame', cc.SpriteFrame, []); cc.SpriteFrame.$super = cc.Asset; -cc.js.mixin(cc.SpriteFrame.prototype, cc.EventTarget.prototype); -cc.SpriteFrame.prototype.textureLoaded = function () { +var prototype = cc.SpriteFrame.prototype; + +cc.js.mixin(prototype, cc.EventTarget.prototype); +prototype.textureLoaded = function () { return this.getTexture() !== null; }; // cc.SpriteFrame -cc.SpriteFrame.prototype._ctor = function (filename, rect, rotated, offset, originalSize) { +prototype._ctor = function (filename, rect, rotated, offset, originalSize) { + this._name = ''; if (filename !== undefined) { this.initWithTexture(filename, rect, rotated, offset, originalSize); } else { @@ -76,12 +79,12 @@ cc.SpriteFrame.prototype._ctor = function (filename, rect, rotated, offset, orig } }; -cc.SpriteFrame.prototype._initWithTexture = cc.SpriteFrame.prototype.initWithTexture; -cc.SpriteFrame.prototype.initWithTexture = function (texture, rect, rotated, offset, originalSize) { +prototype._initWithTexture = prototype.initWithTexture; +prototype.initWithTexture = function (texture, rect, rotated, offset, originalSize) { this.setTexture(texture, rect, rotated, offset, originalSize); }; -cc.SpriteFrame.prototype.setTexture = function (textureOrTextureFile, rect, rotated, offset, originalSize) { +prototype.setTexture = function (textureOrTextureFile, rect, rotated, offset, originalSize) { if (rect) { this.setRect(rect); @@ -113,7 +116,7 @@ cc.SpriteFrame.prototype.setTexture = function (textureOrTextureFile, rect, rota return true; }; -cc.SpriteFrame.prototype._refreshTexture = function (texture) { +prototype._refreshTexture = function (texture) { if (this.getTexture() !== texture) { @@ -149,7 +152,7 @@ cc.SpriteFrame.prototype._refreshTexture = function (texture) { } }; -cc.SpriteFrame.prototype._deserialize = function (data, handle) { +prototype._deserialize = function (data, handle) { var rect = data.rect; if (rect) { this.setRect(new cc.Rect(rect[0], rect[1], rect[2], rect[3])); @@ -178,7 +181,7 @@ cc.SpriteFrame.prototype._deserialize = function (data, handle) { handle.result.push(this, '_textureFilenameSetter', textureUuid); } }; -cc.SpriteFrame.prototype._checkRect = function (texture) { +prototype._checkRect = function (texture) { var rect = this.getRect(); var maxX = rect.x, maxY = rect.y; if (this.isRotated()) { @@ -196,16 +199,27 @@ cc.SpriteFrame.prototype._checkRect = function (texture) { cc.error(cc._LogInfos.RectHeight, texture.url); } }; -cc.SpriteFrame.prototype._getTexture = cc.SpriteFrame.prototype.getTexture; -cc.SpriteFrame.prototype.getTexture = function () { + +prototype._getTexture = prototype.getTexture; +prototype.getTexture = function () { var tex = this._getTexture(); this._texture = tex; return tex; }; -cc.js.set(cc.SpriteFrame.prototype, '_textureFilenameSetter', function (url) { + +cc.js.set(prototype, '_textureFilenameSetter', function (url) { this._textureFilename = url; if (url) { var texture = cc.textureCache.addImage(url); this._refreshTexture(texture); } }); + +cc.js.getset(prototype, 'name', + function () { + return this._name; + }, + function (value) { + this._name = value; + } +); diff --git a/package.json b/package.json index 338e408aad..8071bae5fc 100644 --- a/package.json +++ b/package.json @@ -26,10 +26,12 @@ "gulp-plumber": "0.6.6", "gulp-rename": "1.2.2", "gulp-shell": "0.4.1", + "gulp-size": "2.1.0", "gulp-sourcemaps": "1.5.2", "gulp-uglify": "1.5.3", "gulp-util": "3.0.6", "jshint-stylish": "2.1.0", + "multipipe": "0.3.0", "require-dir": "0.3.0", "vinyl": "1.1.0", "vinyl-buffer": "1.0.0", diff --git a/test/lib/spawn-runner.js b/test/lib/spawn-runner.js index c5e790cb91..747859be4b 100644 --- a/test/lib/spawn-runner.js +++ b/test/lib/spawn-runner.js @@ -4,7 +4,7 @@ if (cc.sys.platform === cc.sys.EDITOR_CORE) { var Ipc = require('ipc'); var Path = require('path'); var Url = require('url'); - var BrowserWindow = require('browser-window'); + var Electron = require('electron'); var spawnWorker = function (title, scriptUrl, debug) { describe(title, function () { @@ -32,7 +32,7 @@ if (cc.sys.platform === cc.sys.EDITOR_CORE) { done(); }); - win = new BrowserWindow({ + win = new Electron.BrowserWindow({ title: title, width: 400, height: 400,