mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 07:42:38 +08:00
Merge pull request #130 from pandamicro/master
让 EventManager 针对 Entity 进行正确的排序
This commit is contained in:
@@ -307,21 +307,21 @@ var Node = cc.Class({
|
||||
// destroy immediate so its _onPreDestroy can be called
|
||||
component._destroyImmediate();
|
||||
}
|
||||
|
||||
// Actions
|
||||
this.stopAllActions();
|
||||
|
||||
// Schedules
|
||||
this.unscheduleAllCallbacks();
|
||||
|
||||
// Remove all listeners
|
||||
cc.eventManager.removeListeners(this);
|
||||
for (i = 0, len = this.__eventTargets.length; i < len; ++i) {
|
||||
var target = this.__eventTargets[i];
|
||||
target && target.targetOff(this);
|
||||
}
|
||||
this.__eventTargets.length = 0;
|
||||
|
||||
if (this._touchListener) {
|
||||
cc.eventManager.removeListener(this._touchListener);
|
||||
}
|
||||
if (this._mouseListener) {
|
||||
cc.eventManager.removeListener(this._mouseListener);
|
||||
}
|
||||
|
||||
// remove from persist
|
||||
if (this._persistNode) {
|
||||
cc.game.removePersistRootNode(this);
|
||||
|
||||
@@ -596,7 +596,7 @@ cc.eventManager = {
|
||||
break;
|
||||
}
|
||||
|
||||
if (locNodeListenersMap[node.__instanceId] != null) {
|
||||
if (locNodeListenersMap[node.__instanceId] !== undefined) {
|
||||
if (!locGlobalZOrderNodeMap[node.getGlobalZOrder()])
|
||||
locGlobalZOrderNodeMap[node.getGlobalZOrder()] = [];
|
||||
locGlobalZOrderNodeMap[node.getGlobalZOrder()].push(node.__instanceId);
|
||||
@@ -608,7 +608,7 @@ cc.eventManager = {
|
||||
this._visitTarget(child, false);
|
||||
}
|
||||
} else {
|
||||
if (locNodeListenersMap[node.__instanceId] != null) {
|
||||
if (locNodeListenersMap[node.__instanceId] !== undefined) {
|
||||
if (!locGlobalZOrderNodeMap[node.getGlobalZOrder()])
|
||||
locGlobalZOrderNodeMap[node.getGlobalZOrder()] = [];
|
||||
locGlobalZOrderNodeMap[node.getGlobalZOrder()].push(node.__instanceId);
|
||||
@@ -796,7 +796,7 @@ cc.eventManager = {
|
||||
*/
|
||||
removeListeners: function (listenerType, recursive) {
|
||||
var i, _t = this;
|
||||
if (listenerType instanceof _ccsg.Node) {
|
||||
if (listenerType.__instanceId !== undefined) {
|
||||
// Ensure the node is removed from these immediately also.
|
||||
// Don't want any dangling pointers or the possibility of dealing with deleted objects..
|
||||
delete _t._nodePriorityMap[listenerType.__instanceId];
|
||||
|
||||
@@ -1,3 +1,15 @@
|
||||
'use strict';
|
||||
|
||||
var _noCacheRex = /\?/;
|
||||
function urlAppendTimestamp (url) {
|
||||
if (cc.game.config['noCache'] && typeof url === 'string') {
|
||||
if(_noCacheRex.test(url))
|
||||
url += '&_t=' + (new Date() - 0);
|
||||
else
|
||||
url += '?_t=' + (new Date() - 0);
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loader for resource loading process. It's a singleton object.
|
||||
@@ -123,14 +135,7 @@ cc.loader = cc.loader || (function () {
|
||||
var d = document, self = this, s = document.createElement('script');
|
||||
s.async = isAsync;
|
||||
_jsCache[jsPath] = true;
|
||||
if(cc.game.config["noCache"] && typeof jsPath === "string"){
|
||||
if(self._noCacheRex.test(jsPath))
|
||||
s.src = jsPath + "&_t=" + (new Date() - 0);
|
||||
else
|
||||
s.src = jsPath + "?_t=" + (new Date() - 0);
|
||||
}else{
|
||||
s.src = jsPath;
|
||||
}
|
||||
s.src = urlAppendTimestamp(jsPath);
|
||||
s.addEventListener('load', function () {
|
||||
s.parentNode.removeChild(s);
|
||||
s.removeEventListener('load', arguments.callee, false);
|
||||
@@ -186,6 +191,9 @@ cc.loader = cc.loader || (function () {
|
||||
loadTxt: function (url, cb) {
|
||||
var xhr = this.getXMLHttpRequest(),
|
||||
errInfo = "load " + url + " failed!";
|
||||
|
||||
url = urlAppendTimestamp(url);
|
||||
|
||||
xhr.open("GET", url, true);
|
||||
if (/msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent)) {
|
||||
// IE-specific logic here
|
||||
@@ -226,6 +234,9 @@ cc.loader = cc.loader || (function () {
|
||||
loadCsb: function(url, cb){
|
||||
var xhr = new XMLHttpRequest(),
|
||||
errInfo = "load " + url + " failed!";
|
||||
|
||||
url = urlAppendTimestamp(url);
|
||||
|
||||
xhr.open("GET", url, true);
|
||||
xhr.responseType = "arraybuffer";
|
||||
|
||||
@@ -290,6 +301,8 @@ cc.loader = cc.loader || (function () {
|
||||
else if (option !== undefined)
|
||||
callback = option;
|
||||
|
||||
url = urlAppendTimestamp(url);
|
||||
|
||||
var img = this.getRes(url);
|
||||
if (img) {
|
||||
callback && callback(null, img);
|
||||
@@ -367,12 +380,6 @@ cc.loader = cc.loader || (function () {
|
||||
realUrl = self.getUrl(basePath, url);
|
||||
}
|
||||
|
||||
if(cc.game.config["noCache"] && typeof realUrl === "string"){
|
||||
if(self._noCacheRex.test(realUrl))
|
||||
realUrl += "&_t=" + (new Date() - 0);
|
||||
else
|
||||
realUrl += "?_t=" + (new Date() - 0);
|
||||
}
|
||||
loader.load(realUrl, url, item, function (err, data) {
|
||||
if (err) {
|
||||
cc.log(err);
|
||||
@@ -385,7 +392,6 @@ cc.loader = cc.loader || (function () {
|
||||
}
|
||||
});
|
||||
},
|
||||
_noCacheRex: /\?/,
|
||||
|
||||
/**
|
||||
* Get url with basePath.
|
||||
|
||||
@@ -686,6 +686,7 @@ var BaseNode = cc.Class(/** @lends cc.Node# */{
|
||||
* @returns {number} The node's global Z order
|
||||
*/
|
||||
getGlobalZOrder: function () {
|
||||
this._globalZOrder = this._sgNode.getGlobalZOrder();
|
||||
return this._globalZOrder;
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user