diff --git a/cocos2d/core/components/CCComponent.js b/cocos2d/core/components/CCComponent.js index 0c0d70444c..f278c7ca24 100644 --- a/cocos2d/core/components/CCComponent.js +++ b/cocos2d/core/components/CCComponent.js @@ -236,9 +236,10 @@ var Component = cc.Class({ name: 'cc.Component', extends: cc.Object, - ctor: (CC_EDITOR && window._Scene && _Scene.AssetsWatcher) ? function () { - _Scene.AssetsWatcher.initComponent(this); - + ctor: CC_EDITOR ? function () { + if (window._Scene && _Scene.AssetsWatcher) { + _Scene.AssetsWatcher.initComponent(this); + } // Support for Scheduler this.__instanceId = cc.ClassManager.getNewInstanceId(); } : function () { diff --git a/cocos2d/core/components/CCScrollView.js b/cocos2d/core/components/CCScrollView.js index 33b34d1fc6..972f1a223a 100644 --- a/cocos2d/core/components/CCScrollView.js +++ b/cocos2d/core/components/CCScrollView.js @@ -103,7 +103,13 @@ var EventType = cc.Enum({ * !#zh 滚动视图滚动滚动结束的时候发出的事件 * @property {Number} AUTOSCROLL_ENDED */ - AUTOSCROLL_ENDED : 9 + AUTOSCROLL_ENDED : 9, + /** + * !#en The event emmitted when user release the touch + * !#zh 当用户松手的时候会发出一个事件 + * @property {Number} TOUCH_UP + */ + TOUCH_UP : 10 }); /** @@ -698,6 +704,8 @@ var ScrollView = cc.Class({ }, _onMouseWheel: function(event) { + if (!this.enabledInHierarchy) return; + var deltaMove = cc.p(0, 0); var wheelPrecision = 1.0 / 40; if(CC_JSB) { @@ -847,6 +855,8 @@ var ScrollView = cc.Class({ // touch event handler _onTouchBegan: function(event) { + if (!this.enabledInHierarchy) return; + var touch = event.touch; if (this.content) { this._handlePressLogic(touch); @@ -855,6 +865,8 @@ var ScrollView = cc.Class({ }, _onTouchMoved: function(event) { + if (!this.enabledInHierarchy) return; + var touch = event.touch; if (this.content) { this._handleMoveLogic(touch); @@ -881,15 +893,20 @@ var ScrollView = cc.Class({ }, _onTouchEnded: function(event) { + if (!this.enabledInHierarchy) return; + var touch = event.touch; if (this.content) { this._handleReleaseLogic(touch); } + this._dispatchEvent(EventType.TOUCH_UP); if (this._touchMoved) { event.stopPropagation(); } }, _onTouchCancelled: function(event) { + if (!this.enabledInHierarchy) return; + // Filte touch cancel event send from self if (!event.simulate) { var touch = event.touch; diff --git a/cocos2d/core/components/CCSprite.js b/cocos2d/core/components/CCSprite.js index 055b2fffbe..0dd40826b0 100644 --- a/cocos2d/core/components/CCSprite.js +++ b/cocos2d/core/components/CCSprite.js @@ -163,10 +163,17 @@ var Sprite = cc.Class({ return this._spriteFrame; }, set: function (value, force) { - if (this._spriteFrame === value) { - return; - } var lastSprite = this._spriteFrame; + if (CC_EDITOR) { + if (!force && ((lastSprite && lastSprite._uuid) === (value && value._uuid))) { + return; + } + } + else { + if (lastSprite === value) { + return; + } + } this._spriteFrame = value; this._applySpriteFrame(lastSprite); if (CC_EDITOR) { diff --git a/cocos2d/core/editbox/CCSGEditBox.js b/cocos2d/core/editbox/CCSGEditBox.js index 82647dd0c0..3d779c8a65 100644 --- a/cocos2d/core/editbox/CCSGEditBox.js +++ b/cocos2d/core/editbox/CCSGEditBox.js @@ -581,10 +581,18 @@ _ccsg.EditBox.KeyboardReturnType = KeyboardReturnType; tmpEdTxt.addEventListener('input', function () { var editBox = thisPointer._editBox; + + + if (this.value.length > this.maxLength) { + this.value = this.value.slice(0, this.maxLength); + } + if (editBox._delegate && editBox._delegate.editBoxTextChanged) { - editBox._text = this.value; - thisPointer._updateEditBoxContentStyle(); - editBox._delegate.editBoxTextChanged(editBox, editBox._text); + if (editBox._text.toLowerCase() !== this.value.toLowerCase()) { + editBox._text = this.value; + thisPointer._updateEditBoxContentStyle(); + editBox._delegate.editBoxTextChanged(editBox, editBox._text); + } } }); tmpEdTxt.addEventListener('keypress', function (e) { @@ -597,6 +605,7 @@ _ccsg.EditBox.KeyboardReturnType = KeyboardReturnType; this.style.fontSize = editBox._placeholderFontSize + 'px'; this.style.color = cc.colorToHex(editBox._placeholderColor); } + editBox._text = this.value; thisPointer._updateEditBoxContentStyle(); thisPointer.hidden(); @@ -670,11 +679,17 @@ _ccsg.EditBox.KeyboardReturnType = KeyboardReturnType; tmpEdTxt.style.className = "cocosEditBox"; tmpEdTxt.addEventListener('input', function () { + if (this.value.length > this.maxLength) { + this.value = this.value.slice(0, this.maxLength); + } + var editBox = thisPointer._editBox; if (editBox._delegate && editBox._delegate.editBoxTextChanged) { - editBox._text = this.value; - thisPointer._updateEditBoxContentStyle(); - editBox._delegate.editBoxTextChanged(editBox, editBox._text); + if(editBox._text.toLowerCase() !== this.value.toLowerCase()) { + editBox._text = this.value; + thisPointer._updateEditBoxContentStyle(); + editBox._delegate.editBoxTextChanged(editBox, editBox._text); + } } }); diff --git a/cocos2d/core/platform/CCView.js b/cocos2d/core/platform/CCView.js index 86df5e28b0..646b8a3d49 100644 --- a/cocos2d/core/platform/CCView.js +++ b/cocos2d/core/platform/CCView.js @@ -151,7 +151,7 @@ var View = cc._Class.extend({ __resizeWithBrowserSize: false, _isAdjustViewPort: true, _targetDensityDPI: null, - _antiAliasEnabled: false, + _antiAliasEnabled: true, /** * Constructor of View @@ -184,7 +184,6 @@ var View = cc._Class.extend({ _t._rpFixedWidth = new cc.ResolutionPolicy(_strategyer.EQUAL_TO_FRAME, _strategy.FIXED_WIDTH); _t._targetDensityDPI = cc.macro.DENSITYDPI_HIGH; - _t.enableAntiAlias(true); }, // Resize helper functions @@ -469,7 +468,7 @@ var View = cc._Class.extend({ * !#en Returns whether the current enable on anti-alias * !#zh 返回当前是否抗锯齿 * @method isAntiAliasEnabled - * @param {Boolean} enabled - Pass false to make pixel art sharp. + * @return {Boolean} */ isAntiAliasEnabled: function () { return this._antiAliasEnabled; diff --git a/cocos2d/core/textures/CCTextureCache.js b/cocos2d/core/textures/CCTextureCache.js index 54bd675522..ac6650163b 100644 --- a/cocos2d/core/textures/CCTextureCache.js +++ b/cocos2d/core/textures/CCTextureCache.js @@ -125,6 +125,21 @@ var textureCache = /** @lends cc.textureCache# */{ return this._textureColorsCache[key]; }, + /** + * #en get all textures + * #zh 获取所有贴图 + * @method getAllTextures + * @return {Texture2D[]} + */ + getAllTextures: function () { + var texs = []; + for (var key in this._textures) { + var item = this._textures[key]; + texs.push(item); + } + return texs; + }, + /** *

Purges the dictionary of loaded textures.
* Call this method if you receive the "Memory Warning"