From 0862d313b28c24dc5c822bd7418cc271aa326628 Mon Sep 17 00:00:00 2001 From: zhangcheng Date: Wed, 8 Jul 2015 16:13:38 +0800 Subject: [PATCH] Fix cocos reader bug. Fixes child nodes can't be rendered when particle and TiledMap as parent and their resource have been removed from disk. --- .../GameMapReader/GameMapReader.cpp | 15 ++++++--------- .../ParticleReader/ParticleReader.cpp | 19 ++++++++----------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/cocos/editor-support/cocostudio/WidgetReader/GameMapReader/GameMapReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/GameMapReader/GameMapReader.cpp index 903bba1811..476fa9b59e 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/GameMapReader/GameMapReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/GameMapReader/GameMapReader.cpp @@ -238,15 +238,12 @@ namespace cocostudio setPropsWithFlatBuffers(tmx, (Table*)gameMapOptions); } } - //else - //{ - // Node* node = Node::create(); - // setPropsWithFlatBuffers(node, (Table*)gameMapOptions); - // auto label = Label::create(); - // label->setString(__String::createWithFormat("%s missed", errorFilePath.c_str())->getCString()); - // node->addChild(label); - // return node; - //} + else + { + Node* node = Node::create(); + setPropsWithFlatBuffers(node, (Table*)gameMapOptions); + return node; + } return tmx; } diff --git a/cocos/editor-support/cocostudio/WidgetReader/ParticleReader/ParticleReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/ParticleReader/ParticleReader.cpp index 51f4f79e25..9e27769f0d 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/ParticleReader/ParticleReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/ParticleReader/ParticleReader.cpp @@ -153,11 +153,11 @@ namespace cocostudio void ParticleReader::setPropsWithFlatBuffers(cocos2d::Node *node, const flatbuffers::Table *particleOptions) { - auto particle = static_cast(node); + auto particle = dynamic_cast(node); auto options = (ParticleSystemOptions*)particleOptions; auto f_blendFunc = options->blendFunc(); - if (f_blendFunc) + if (particle && f_blendFunc) { cocos2d::BlendFunc blendFunc = cocos2d::BlendFunc::ALPHA_PREMULTIPLIED; blendFunc.src = f_blendFunc->src(); @@ -208,15 +208,12 @@ namespace cocostudio particle->setPositionType(ParticleSystem::PositionType::GROUPED); } } - //else - //{ - // Node* node = Node::create(); - // setPropsWithFlatBuffers(node, (Table*)particleOptions); - // auto label = Label::create(); - // label->setString(__String::createWithFormat("%s missed", errorFilePath.c_str())->getCString()); - // node->addChild(label); - // return node; - //} + else + { + Node* node = Node::create(); + setPropsWithFlatBuffers(node, (Table*)particleOptions); + return node; + } return particle; }