diff --git a/CCBoot.js b/CCBoot.js index e5af2c5291..462bfea9f2 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -58,7 +58,7 @@ _p = null; * @name cc.ENGINE_VERSION */ var engineVersion; -engineVersion = '1.2.1-beta.4'; +engineVersion = '1.2.1-rc.1'; window['CocosEngine'] = cc.ENGINE_VERSION = engineVersion; /** diff --git a/cocos2d/core/CCNode.js b/cocos2d/core/CCNode.js index 3eb80ebbe3..828c33bdfe 100644 --- a/cocos2d/core/CCNode.js +++ b/cocos2d/core/CCNode.js @@ -969,6 +969,12 @@ var Node = cc.Class({ // activate cc.director.getActionManager().resumeTarget(this); cc.eventManager.resumeTarget(this); + if (this._touchListener) { + this._touchListener.mask = _searchMaskParent(this); + } + if (this._mouseListener) { + this._mouseListener.mask = _searchMaskParent(this); + } } else { // deactivate diff --git a/cocos2d/core/components/CCScrollView.js b/cocos2d/core/components/CCScrollView.js index 762fc7f1db..33b34d1fc6 100644 --- a/cocos2d/core/components/CCScrollView.js +++ b/cocos2d/core/components/CCScrollView.js @@ -813,6 +813,7 @@ var ScrollView = cc.Class({ } this._moveContent(moveDelta); + this._adjustContentOutOfBoundary(); }, _calculateBoundary: function() { @@ -1331,6 +1332,7 @@ var ScrollView = cc.Class({ var newPosition = cc.pAdd(this.getContentPosition(), outOfBoundary); if(this.content) { this.content.setPosition(newPosition); + this._updateScrollBar(0); } } }, @@ -1339,7 +1341,9 @@ var ScrollView = cc.Class({ this._calculateBoundary(); //Because widget component will adjust content position and scrollview position is correct after visit //So this event could make sure the content is on the correct position after loading. - cc.director.once(cc.Director.EVENT_AFTER_VISIT, this._adjustContentOutOfBoundary, this); + if(this.content) { + cc.director.once(cc.Director.EVENT_AFTER_VISIT, this._adjustContentOutOfBoundary, this); + } }, onDestroy: function() { diff --git a/cocos2d/core/editbox/CCSGEditBox.js b/cocos2d/core/editbox/CCSGEditBox.js index 4e6f82e24d..82647dd0c0 100644 --- a/cocos2d/core/editbox/CCSGEditBox.js +++ b/cocos2d/core/editbox/CCSGEditBox.js @@ -280,9 +280,9 @@ _ccsg.EditBox = _ccsg.Node.extend({ }, cleanup: function () { + this._super(); + this._renderCmd._removeDomInputControl(); - this.stopAllActions(); - this.unscheduleAllCallbacks(); }, _onTouchBegan: function (touch) { diff --git a/cocos2d/core/label/CCSGLabel.js b/cocos2d/core/label/CCSGLabel.js index 34c6ca0545..8705cc99b0 100644 --- a/cocos2d/core/label/CCSGLabel.js +++ b/cocos2d/core/label/CCSGLabel.js @@ -359,6 +359,7 @@ _ccsg.Label = _ccsg.Node.extend({ this._fontHandle = fontHandle; this._labelType = _ccsg.Label.Type.SystemFont; this._blendFunc = cc.BlendFunc._alphaPremultiplied(); + this._renderCmd._needDraw = true; this._notifyLabelSkinDirty(); this.emit('load'); return; @@ -367,16 +368,35 @@ _ccsg.Label = _ccsg.Node.extend({ if (extName === ".ttf") { this._labelType = _ccsg.Label.Type.TTF; this._blendFunc = cc.BlendFunc._alphaPremultiplied(); + this._renderCmd._needDraw = true; this._fontHandle = this._loadTTFFont(fontHandle); } else if (extName === ".fnt") { //todo add bmfont here this._labelType = _ccsg.Label.Type.BMFont; this._blendFunc = cc.BlendFunc._alphaNonPremultiplied(); + this._renderCmd._needDraw = false; this._initBMFontWithString(this._string, fontHandle, textureUrl); } this._notifyLabelSkinDirty(); }, + cleanup: function () { + this._super(); + + //remove the created DIV and style due to loading @font-face + if(this._fontFaceStyle) { + if(document.body.contains(this._fontFaceStyle)) { + document.body.removeChild(this._fontFaceStyle); + } + } + + if(this._preloadDiv) { + if(document.body.contains(this._preloadDiv)) { + document.body.removeChild(this._preloadDiv); + } + } + }, + _loadTTFFont: function(fontHandle) { var ttfIndex = fontHandle.lastIndexOf(".ttf"); if (ttfIndex === -1) return fontHandle; @@ -398,6 +418,7 @@ _ccsg.Label = _ccsg.Node.extend({ fontStyle = document.createElement("style"); fontStyle.type = "text/css"; doc.body.appendChild(fontStyle); + this._fontFaceStyle = fontStyle; var fontStr = ""; if (isNaN(fontFamilyName - 0)) @@ -418,6 +439,7 @@ _ccsg.Label = _ccsg.Node.extend({ _divStyle.left = "-100px"; _divStyle.top = "-100px"; doc.body.appendChild(preloadDiv); + this._preloadDiv = preloadDiv; self.scheduleOnce(function () { self._notifyLabelSkinDirty(); self.emit("load"); diff --git a/cocos2d/core/label/CCSGLabelWebGLRenderCmd.js b/cocos2d/core/label/CCSGLabelWebGLRenderCmd.js index 541e2f3c11..5247004163 100644 --- a/cocos2d/core/label/CCSGLabelWebGLRenderCmd.js +++ b/cocos2d/core/label/CCSGLabelWebGLRenderCmd.js @@ -69,7 +69,8 @@ proto._updateDisplayOpacity = function (parentOpacity) { proto.transform = function (parentCmd, recursive) { this.originTransform(parentCmd, recursive); - var lx = 0, rx = this._labelCanvas.width, + var node = this._node, + lx = 0, rx = this._labelCanvas.width, by = 0, ty = this._labelCanvas.height, wt = this._worldTransform; @@ -83,6 +84,12 @@ proto.transform = function (parentCmd, recursive) { vert[3].x = rx * wt.a + by * wt.c + wt.tx; // br vert[3].y = rx * wt.b + by * wt.d + wt.ty; + if (!node._string || (node._labelType !== _ccsg.Label.Type.TTF && + node._labelType !== _ccsg.Label.Type.SystemFont)) { + // No culling for bmfont + return; + } + var rect = cc.visibleRect, vl = rect.left.x, vr = rect.right.x, vt = rect.top.y, vb = rect.bottom.y; if (((vert[0].x-vl) & (vert[1].x-vl) & (vert[2].x-vl) & (vert[3].x-vl)) >> 31 || // All outside left diff --git a/cocos2d/core/platform/CCClass.js b/cocos2d/core/platform/CCClass.js index 997dd8bb52..4eda3efe1f 100644 --- a/cocos2d/core/platform/CCClass.js +++ b/cocos2d/core/platform/CCClass.js @@ -1003,10 +1003,10 @@ function parseAttributes (attrs, className, propName) { } function parseSimpleAttr (attrName, expectType, attrCreater) { - var val = attrs[attrName]; - if (val) { + if (attrName in attrs) { + var val = attrs[attrName]; if (typeof val === expectType) { - if (typeof attrCreater === 'undefined') { + if ( !attrCreater ) { var attr = {}; attr[attrName] = val; result.push(attr); @@ -1016,7 +1016,7 @@ function parseAttributes (attrs, className, propName) { } } else if (CC_DEV) { - cc.error('The %s of %s.%s must be type %s', attrName, className, propName, expectType); + cc.error(ERR_Type, attrName, className, propName, expectType); } } } @@ -1070,13 +1070,16 @@ function parseAttributes (attrs, className, propName) { result.push({ min: range[0], max: range[1], step: range[2] }); } else if (CC_DEV) { - cc.error('The length of range array must be 2'); + cc.error('The length of range array must be equal or greater than 2'); } } else if (CC_DEV) { - cc.error(ERR_Type, '"range"', className + '.' + propName, 'array'); + cc.error(ERR_Type, 'range', className, propName, 'array'); } } + parseSimpleAttr('min', 'number'); + parseSimpleAttr('max', 'number'); + parseSimpleAttr('step', 'number'); return result; } diff --git a/cocos2d/core/platform/CCView.js b/cocos2d/core/platform/CCView.js index c5703f7016..d65dc9b54c 100644 --- a/cocos2d/core/platform/CCView.js +++ b/cocos2d/core/platform/CCView.js @@ -154,7 +154,7 @@ var View = cc._Class.extend({ * Constructor of View */ ctor: function () { - var _t = this, d = document, _strategyer = cc.ContainerStrategy, _strategy = cc.ContentStrategy; + var _t = this, _strategyer = cc.ContainerStrategy, _strategy = cc.ContentStrategy; __BrowserGetter.init(this); @@ -703,6 +703,9 @@ var View = cc._Class.extend({ // reset director's member variables to fit visible rect director.setGLDefaultValues(); } + else if (cc._renderType === cc.game.RENDER_TYPE_CANVAS) { + cc.renderer._allNeedDraw = true; + } this._originalScaleX = this._scaleX; this._originalScaleY = this._scaleY; @@ -1055,7 +1058,15 @@ cc.ContentStrategy = cc._Class.extend(/** @lends cc.ContentStrategy# */{ */ var EqualToFrame = cc.ContainerStrategy.extend({ apply: function (view) { + var frameH = view._frameSize.height, containerStyle = cc.container.style; this._setupContainer(view, view._frameSize.width, view._frameSize.height); + // Setup container's margin and padding + if (view._isRotated) { + containerStyle.marginLeft = frameH + 'px'; + } + else { + containerStyle.margin = '0px'; + } } }); diff --git a/cocos2d/core/textures/CCTexture2D.js b/cocos2d/core/textures/CCTexture2D.js index 3f6a17b485..abafe8d952 100644 --- a/cocos2d/core/textures/CCTexture2D.js +++ b/cocos2d/core/textures/CCTexture2D.js @@ -96,7 +96,6 @@ var Texture2D = cc.Class(/** @lends cc.Texture2D# */{ this._isGray = false; } else if (cc._renderType === game.RENDER_TYPE_WEBGL) { - this._hasPremultipliedAlpha = false; this._pixelFormat = Texture2D.defaultPixelFormat; this._hasPremultipliedAlpha = false; this._hasMipmaps = false; diff --git a/cocos2d/core/videoplayer/CCSGVideoPlayer.js b/cocos2d/core/videoplayer/CCSGVideoPlayer.js index 64dad7323e..831672ea52 100644 --- a/cocos2d/core/videoplayer/CCSGVideoPlayer.js +++ b/cocos2d/core/videoplayer/CCSGVideoPlayer.js @@ -139,9 +139,9 @@ _ccsg.VideoPlayer = _ccsg.Node.extend(/** @lends _ccsg.VideoPlayer# */{ }, cleanup: function () { + this._super(); + this._renderCmd.removeDom(); - this.stopAllActions(); - this.unscheduleAllCallbacks(); }, onEnter: function () { diff --git a/cocos2d/core/webview/CCSGWebView.js b/cocos2d/core/webview/CCSGWebView.js index 7973a86a1f..db7f3295f3 100644 --- a/cocos2d/core/webview/CCSGWebView.js +++ b/cocos2d/core/webview/CCSGWebView.js @@ -185,9 +185,9 @@ _ccsg.WebView = _ccsg.Node.extend(/** @lends _ccsg.WebView# */{ * remove node */ cleanup: function(){ + this._super(); + this._renderCmd.removeDom(); - this.stopAllActions(); - this.unscheduleAllCallbacks(); }, setVisible: function ( visible ) {