diff --git a/CCBoot.js b/CCBoot.js index 3e76a55e9b..7bee5c5321 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -58,7 +58,7 @@ _p = null; * @name cc.ENGINE_VERSION */ var engineVersion; -engineVersion = '1.1.1'; +engineVersion = '1.1.2-beta.1'; window['CocosEngine'] = cc.ENGINE_VERSION = engineVersion; /** diff --git a/cocos2d/core/CCNode.js b/cocos2d/core/CCNode.js index 82862e2266..f07ba3159a 100644 --- a/cocos2d/core/CCNode.js +++ b/cocos2d/core/CCNode.js @@ -463,9 +463,6 @@ var Node = cc.Class({ this._name = typeof name !== 'undefined' ? name : 'New Node'; this._activeInHierarchy = false; - // Support for ActionManager and EventManager - this.__instanceId = this._id || cc.ClassManager.getNewInstanceId(); - // cache component this._widget = null; @@ -475,15 +472,6 @@ var Node = cc.Class({ // Mouse event listener this._mouseListener = null; - /** - * Register all related EventTargets, - * all event callbacks will be removed in _onPreDestroy - * @property __eventTargets - * @type {EventTarget[]} - * @private - */ - this.__eventTargets = []; - // Retained actions for JSB if (CC_JSB) { this._retainedActions = []; diff --git a/cocos2d/core/components/CCScrollView.js b/cocos2d/core/components/CCScrollView.js index 424d54a87d..a4615f8f46 100644 --- a/cocos2d/core/components/CCScrollView.js +++ b/cocos2d/core/components/CCScrollView.js @@ -796,6 +796,10 @@ var ScrollView = cc.Class({ //FIXME: touch move delta should be calculated by DPI. if (cc.pLength(deltaMove) > 7) { this._touchMoved = true; + var buttonComponent = event.target.getComponent(cc.Button); + if (buttonComponent) { + buttonComponent._onTouchCancel(); + } } // TODO: detect move distance, if distance greater than a seuil, then stop propagation. event.stopPropagation(); diff --git a/cocos2d/core/event-manager/CCEventManager.js b/cocos2d/core/event-manager/CCEventManager.js index 09cf9e404c..cc604d9c1b 100644 --- a/cocos2d/core/event-manager/CCEventManager.js +++ b/cocos2d/core/event-manager/CCEventManager.js @@ -76,11 +76,11 @@ var __getListenerID = function (event) { return cc._EventListenerAcceleration.LISTENER_ID; if (type === eventType.KEYBOARD) return cc._EventListenerKeyboard.LISTENER_ID; - if (type === eventType.MOUSE) + if (type.startsWith(eventType.MOUSE)) return cc._EventListenerMouse.LISTENER_ID; if (type === eventType.FOCUS) return cc._EventListenerFocus.LISTENER_ID; - if (type === eventType.TOUCH){ + if (type.startsWith(eventType.TOUCH)){ // Touch listener is very special, it contains two kinds of listeners, EventListenerTouchOneByOne and EventListenerTouchAllAtOnce. // return UNKNOWN instead. cc.log(cc._LogInfos._getListenerID); @@ -395,7 +395,7 @@ cc.eventManager = { if(locInDispatch > 1) return; - if (event.getType() === cc.Event.TOUCH) { + if (event.getType().startsWith(cc.Event.TOUCH)) { this._onUpdateListeners(cc._EventListenerTouchOneByOne.LISTENER_ID); this._onUpdateListeners(cc._EventListenerTouchAllAtOnce.LISTENER_ID); } else @@ -593,6 +593,10 @@ cc.eventManager = { }, _visitTarget: function (node, isRootNode) { + // sortAllChildren is performed the next frame, but the event is executed immediately. + if (node._reorderChildDirty) { + node.sortAllChildren(); + } var children = node.getChildren(), i = 0; var childrenCount = children.length, locGlobalZOrderNodeMap = this._globalZOrderNodeMap, locNodeListenersMap = this._nodeListenersMap; @@ -967,7 +971,7 @@ cc.eventManager = { this._inDispatch++; if(!event || !event.getType) throw new Error("event is undefined"); - if (event.getType() === cc.Event.TOUCH) { + if (event.getType().startsWith(cc.Event.TOUCH)) { this._dispatchTouchEvent(event); this._inDispatch--; return; diff --git a/cocos2d/core/load-pipeline/uuid-loader.js b/cocos2d/core/load-pipeline/uuid-loader.js index 4f8a24b80b..36490293c6 100644 --- a/cocos2d/core/load-pipeline/uuid-loader.js +++ b/cocos2d/core/load-pipeline/uuid-loader.js @@ -46,18 +46,15 @@ function loadDepends (pipeline, item, asset, tdInfo, callback) { var ownerList = JS.array.copy(tdInfo.uuidObjList); var propList = JS.array.copy(tdInfo.uuidPropList); - var depends = []; + var depends = new Array(dependsSrcs.length); // load depends assets for (var i = 0; i < dependsSrcs.length; i++) { var dependSrc = dependsSrcs[i]; - if (dependSrc === uuid) { - continue; - } - depends.push({ + depends[i] = { id: dependSrc, type: 'uuid', uuid: dependSrc - }); + }; } // load raw if (tdInfo.rawProp) { diff --git a/cocos2d/core/utils/base-node.js b/cocos2d/core/utils/base-node.js index 65516784b1..4db2211606 100644 --- a/cocos2d/core/utils/base-node.js +++ b/cocos2d/core/utils/base-node.js @@ -30,15 +30,30 @@ var DirtyFlags = Misc.DirtyFlags; var IdGenerater = require('../platform/id-generater'); // called after changing parent -function setMaxZOrder (node) { - var siblings = node.parent.getChildren(); - var z = 0; - if (siblings.length >= 2) { - var prevNode = siblings[siblings.length - 2]; - z = prevNode.getOrderOfArrival() + 1; +function updateZOrder (node) { + var sgNode = node._sgNode; + if (CC_JSB) { + // Reset zorder to update their arrival order in JSB + var zOrder = sgNode.getLocalZOrder(); + sgNode.setLocalZOrder(zOrder + 1); + sgNode.setLocalZOrder(zOrder); + } + else { + var sgSiblings = sgNode.parent.getChildren(); + if (sgSiblings.length >= 2) { + var prevNode = sgSiblings[sgSiblings.length - 2]; + sgNode.arrivalOrder = prevNode.arrivalOrder + 1; + } + else { + sgNode.arrivalOrder = 0; + } + cc.renderer.childrenOrderDirty = true; + var parent = node._parent; + parent._sgNode._reorderChildDirty = true; + parent._reorderChildDirty = true; + parent._delaySort(); + cc.eventManager._setDirtyForNode(node); } - node.setOrderOfArrival(z); - return z; } var POSITION_CHANGED = 'position-changed'; @@ -140,20 +155,20 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{ return; } } - var node = this._sgNode; - if (node.parent) { - node.parent.removeChild(node, false); - } - if (value) { - var parent = value._sgNode; - parent.addChild(node); - setMaxZOrder(node); - value._children.push(this); - value.emit(CHILD_ADDED, this); + var sgNode = this._sgNode; + if (sgNode.parent) { + sgNode.parent.removeChild(sgNode, false); } // var oldParent = this._parent; this._parent = value || null; + if (value) { + var parent = value._sgNode; + parent.addChild(sgNode); + updateZOrder(this); + value._children.push(this); + value.emit(CHILD_ADDED, this); + } if (oldParent) { if (!(oldParent._objFlags & Destroying)) { var removeAt = oldParent._children.indexOf(this); @@ -787,11 +802,30 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{ this._sizeProvider = null; this.__ignoreAnchor = false; + + // Support for ActionManager and EventManager + this.__instanceId = this._id || cc.ClassManager.getNewInstanceId(); + + /** + * Register all related EventTargets, + * all event callbacks will be removed in _onPreDestroy + * @property __eventTargets + * @type {EventTarget[]} + * @private + */ + this.__eventTargets = []; }, - _onPreDestroy: CC_JSB && function () { - this._sgNode.release(); - this._sgNode = null; + _onPreDestroy: function () { + if (CC_JSB) { + this._sgNode.release(); + this._sgNode = null; + } + cc.eventManager.removeListeners(this); + for (var i = 0, len = this.__eventTargets.length; i < len; ++i) { + var target = this.__eventTargets[i]; + target && target.targetOff(this); + } }, _destruct: Misc.destructIgnoreId, @@ -2077,17 +2111,20 @@ Misc.propertyDefine(BaseNode, SameNameGetSets, DiffNameGetSets); /** - * !#en position of node. - * !#zh 节点相对父节点的坐标。 + * !#en The local position in its parent's coordinate system.
+ * PS: The returned value is a copy of current position, so modification of the copy will not take effect for the actual position of the node. + * !#zh 节点相对父节点的坐标。
+ * 注意:返回值会是当前 position 的副本,所以对该副本所做的修改并不会影响节点的实际坐标。 * @property position * @type {Vec2} * @example - * node.position = new cc.Vec2(0, 0); + * node.position = new cc.Vec2(0, 0); // OK! + * node.position.addSelf(new cc.Vec2(1, 0)); // Invalid! */ /** - * !#en Scale of node. - * !#zh 节点缩放 + * !#en The local scale relative to the parent. + * !#zh 节点相对父节点的缩放。 * @property scale * @type {Number} * @example diff --git a/docs/cocos2d/core/animation-clip/event-data.js b/docs/cocos2d/core/animation-clip/event-data.js index d49fabd517..9c921b8c86 100644 --- a/docs/cocos2d/core/animation-clip/event-data.js +++ b/docs/cocos2d/core/animation-clip/event-data.js @@ -1,8 +1,8 @@ [ - frame: 0, func: 'onAnimationEvent1', params:['param-1', 'param-2'] - frame: 2, func: 'onAnimationEvent3', params:['param-1', 'param-2'] - frame: 3, func: 'onAnimationEvent2', params:['param-1'] + { frame: 0, func: 'onAnimationEvent1', params:['param-1', 'param-2'] }, + { frame: 2, func: 'onAnimationEvent3', params:['param-1', 'param-2'] }, + { frame: 3, func: 'onAnimationEvent2', params:['param-1'] }, // The second event at frame 3 - frame: 3, func: 'onAnimationEvent4', params:['param-1'] - frame: 4, func: 'onAnimationEvent4', params:['param-1'] + { frame: 3, func: 'onAnimationEvent4', params:['param-1'] }, + { frame: 4, func: 'onAnimationEvent4', params:['param-1'] } ] \ No newline at end of file