From a278c783f3134520724a3c3ec0681710d69c5654 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 28 Dec 2015 21:13:43 +0800 Subject: [PATCH 1/2] Remove scheduleUpdate for Component --- cocos2d/core/components/CCComponent.js | 24 ------------------------ cocos2d/core/platform/CCLoader.js | 2 -- 2 files changed, 26 deletions(-) diff --git a/cocos2d/core/components/CCComponent.js b/cocos2d/core/components/CCComponent.js index f47605f250..bd5a820f22 100644 --- a/cocos2d/core/components/CCComponent.js +++ b/cocos2d/core/components/CCComponent.js @@ -599,21 +599,6 @@ var Component = cc.Class({ cc.director.getScheduler().schedule(callback, this, interval, repeat, delay, !this.enabledInHierarchy, key); }, - /** - *

- * schedules the "update" callback function with a custom priority. - * This callback function will be called every frame.
- * Scheduled callback functions with a lower priority will be called before the ones that have a higher value.
- * Only one "update" callback function could be scheduled per node (You can't have 2 'update' callback functions).
- *

- * @method scheduleUpdate - * @param {Number} [priority=0] The priority of the update callback - */ - scheduleUpdate: function (priority) { - priority = priority || 0; - cc.director.getScheduler().scheduleUpdate(this, priority, !this.enabledInHierarchy); - }, - /** * Schedules a callback function that runs only once, with a delay of 0 or larger * @method scheduleOnce @@ -638,15 +623,6 @@ var Component = cc.Class({ cc.director.getScheduler().unschedule(callback_fn, this); }, - /** - * Unschedules the "update" method. - * @method unscheduleUpdate - * @see cc.Node#scheduleUpdate - */ - unscheduleUpdate: function () { - cc.director.getScheduler().unscheduleUpdate(this); - }, - /** *

unschedule all scheduled callback functions: custom callback functions, and the 'update' callback function.
* Actions are not affected by this method.

diff --git a/cocos2d/core/platform/CCLoader.js b/cocos2d/core/platform/CCLoader.js index a53e5a054e..4f9d15a1a4 100644 --- a/cocos2d/core/platform/CCLoader.js +++ b/cocos2d/core/platform/CCLoader.js @@ -1,5 +1,3 @@ -'use strict'; - var _noCacheRex = /\?/; function urlAppendTimestamp (url) { if (cc.game.config['noCache'] && typeof url === 'string') { From d4e5e02b9ec01f08bacf9095603577cd46365333 Mon Sep 17 00:00:00 2001 From: pandamicro Date: Mon, 28 Dec 2015 21:13:57 +0800 Subject: [PATCH 2/2] Add touch cancel event to entity --- cocos2d/core/CCNode.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/CCNode.js b/cocos2d/core/CCNode.js index 28a4020b7e..0f43861a57 100644 --- a/cocos2d/core/CCNode.js +++ b/cocos2d/core/CCNode.js @@ -61,6 +61,13 @@ var EventType = cc.Enum({ * @readonly */ TOUCH_END: 'touchend', + /** + * The event type for touch end event, you can use its value directly: 'touchcancel' + * @property TOUCH_CANCEL + * @type {String} + * @readonly + */ + TOUCH_CANCEL: 'touchcancel', /** * The event type for mouse down events, you can use its value directly: 'mousedown' @@ -103,6 +110,7 @@ var _touchEvents = [ EventType.TOUCH_START, EventType.TOUCH_MOVE, EventType.TOUCH_END, + EventType.TOUCH_CANCEL, ]; var _mouseEvents = [ EventType.MOUSE_DOWN, @@ -133,8 +141,15 @@ var _touchMoveHandler = function (touch, event) { node.dispatchEvent(event); }; var _touchEndHandler = function (touch, event) { + var pos = touch.getLocation(); var node = this.owner; - event.type = EventType.TOUCH_END; + + if (node._hitTest(pos)) { + event.type = EventType.TOUCH_END; + } + else { + event.type = EventType.TOUCH_CANCEL; + } event.touch = touch; event.bubbles = true; node.dispatchEvent(event);