diff --git a/cocos/editor-support/cocostudio/WidgetReader/Particle3DReader/Particle3DReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/Particle3DReader/Particle3DReader.cpp index 0332bf8e2e..84d814c781 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/Particle3DReader/Particle3DReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/Particle3DReader/Particle3DReader.cpp @@ -147,14 +147,10 @@ namespace cocostudio auto fileData = options->fileData(); std::string path = fileData->path()->c_str(); - ParticleSystem3D* ret = NULL; - if(!FileUtils::getInstance()->isFileExist(path)) + PUParticleSystem3D* ret = PUParticleSystem3D::create(); + if (FileUtils::getInstance()->isFileExist(path)) { - ret = PUParticleSystem3D::create(); - } - else - { - ret = PUParticleSystem3D::create(path); + ret->initWithFilePath(path); } setPropsWithFlatBuffers(ret, particle3DOptions); diff --git a/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js b/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js index b3c3dc6022..129852bf5b 100644 --- a/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js +++ b/cocos/scripting/js-bindings/script/studio/parsers/timelineParser-2.x.js @@ -1519,10 +1519,12 @@ if(json["FileData"] && json["FileData"]["Path"]) resFile = resourcePath + json["FileData"]["Path"]; - var node; - if(resFile) - node = jsb.Sprite3D.create(resFile); - else + var node = null; + if(resFile) { + if(jsb.fileUtils.isFileExist(resFile)) + node = jsb.Sprite3D.create(resFile); + } + if(null === node) node = jsb.Sprite3D.create(); if(node) { @@ -1561,9 +1563,12 @@ if(json["FileData"] && json["FileData"]["Path"]) resFile = resourcePath+json["FileData"]["Path"]; - if(resFile) - node = jsb.PUParticleSystem3D.create(resFile); - else + if(resFile){ + if(jsb.fileUtils.isFileExist(resFile)) + node = jsb.PUParticleSystem3D.create(resFile); + } + + if(null === node) node = jsb.PUParticleSystem3D.create(); if(node){ diff --git a/extensions/Particle3D/PU/CCPUParticleSystem3DTranslator.cpp b/extensions/Particle3D/PU/CCPUParticleSystem3DTranslator.cpp index 31f22e8c8f..4a28f4cd10 100644 --- a/extensions/Particle3D/PU/CCPUParticleSystem3DTranslator.cpp +++ b/extensions/Particle3D/PU/CCPUParticleSystem3DTranslator.cpp @@ -38,6 +38,8 @@ PUParticleSystem3DTranslator::~PUParticleSystem3DTranslator() void PUParticleSystem3DTranslator::translate(PUScriptCompiler* compiler, PUAbstractNode *node) { + if (typeid(*node) != typeid(PUObjectAbstractNode)) + return; PUObjectAbstractNode* obj = reinterpret_cast(node); if(obj->name.empty()) diff --git a/tests/js-tests/src/LoaderTest/LoaderTest.js b/tests/js-tests/src/LoaderTest/LoaderTest.js index 4893f2a823..f9b9d8d6ff 100644 --- a/tests/js-tests/src/LoaderTest/LoaderTest.js +++ b/tests/js-tests/src/LoaderTest/LoaderTest.js @@ -83,6 +83,134 @@ var LoaderTestLayer = BaseTestLayer.extend({ sprite.y = winSize.height/2; }); + }, + + onNextCallback: function(){ + var parent = this.getParent(); + parent.removeChild(this); + parent.addChild(new LoaderCycleLayer()); + } +}); + +var LoaderCycleLayer = BaseTestLayer.extend({ + _title:"Failed to load Test", + _subtitle:"", + + ctor: function(){ + BaseTestLayer.prototype.ctor.call(this); + var index = 0; + + var winSize = cc.director.getWinSize(); + var t = this, + cb = function(num){ + var labelTTF = new cc.LabelTTF(num + " file failed"); + labelTTF.x = index++*100 + winSize.width - 150; + labelTTF.y = winSize.height / 2 - 20; + if(num === 1) + labelTTF.setColor(cc.color.GREEN); + else + labelTTF.setColor(cc.color.RED); + t.addChild(labelTTF); + if(index < 4) + t.test(cb); + }; + this.createInfo(); + this.regLoad(); + this.test(cb); + }, + + regLoad: function(){ + cc.loader.register(["_test1"], { + load: function(realUrl, url, res, cb){ + cc.loader.cache[url] = {}; + setTimeout(function(){ + cb && cb(null, cc.loader.cache[url]); + return cc.loader.cache[url]; + }, Math.random()*1000); + + } + }); + cc.loader.register(["_test2"], { + load: function(realUrl, url, res, cb){ + cb && cb({}); + return null; + } + }); + }, + + list: [ + "1._test2", + "1._test1", + "2._test1", + "3._test1", + "4._test1" + ], + + createInfo: function(){ + var winSize = cc.director.getWinSize(); + var info1 = new cc.LabelTTF("Load 5 files"); + info1.x = winSize.width / 2; + info1.y = winSize.height / 2 + 80; + var info2 = new cc.LabelTTF("1 file does not exist"); + info2.x = winSize.width / 2; + info2.y = winSize.height / 2 + 60; + var info3 = new cc.LabelTTF("The other 4 files should be loaded."); + info3.x = winSize.width / 2; + info3.y = winSize.height / 2 + 40; + + this.addChild(info1); + this.addChild(info2); + this.addChild(info3); + + var info4 = new cc.LabelTTF("test 1"); + info4.x = winSize.width / 2 - 50; + info4.y = winSize.height / 2; + var info5 = new cc.LabelTTF("test 2"); + info5.x = winSize.width / 2 - 150; + info5.y = winSize.height / 2; + var info6 = new cc.LabelTTF("test 3"); + info6.x = winSize.width / 2 + 50; + info6.y = winSize.height / 2; + var info7 = new cc.LabelTTF("test 4"); + info7.x = winSize.width / 2 + 150; + info7.y = winSize.height / 2; + + this.addChild(info4); + this.addChild(info5); + this.addChild(info6); + this.addChild(info7); + }, + + test: function(cb){ + this.clearRes(); + var layer = this; + cc.loader.load(layer.list, function(){ + var num = 0; + layer.list.forEach(function(item){ + if(!cc.loader.getRes(item)){ + num++; + } + }); + cb(num); + }); + }, + + clearRes: function(){ + this.list.forEach(function(item){ + cc.loader.release(item); + }); + }, + + onRestartCallback: function(){ + var parent = this._parent; + parent.removeChild(this); + parent.addChild(new LoaderCycleLayer()); + }, + + onBackCallback: function(){ + var parent = this._parent; + parent.removeChild(this); + parent.addChild(new LoaderTestLayer()); } });