diff --git a/cocos/editor-support/cocostudio/WidgetReader/ArmatureNodeReader/ArmatureNodeReader.cpp b/cocos/editor-support/cocostudio/WidgetReader/ArmatureNodeReader/ArmatureNodeReader.cpp index 89a016417e..f4c0032d07 100644 --- a/cocos/editor-support/cocostudio/WidgetReader/ArmatureNodeReader/ArmatureNodeReader.cpp +++ b/cocos/editor-support/cocostudio/WidgetReader/ArmatureNodeReader/ArmatureNodeReader.cpp @@ -119,16 +119,21 @@ void ArmatureNodeReader::setPropsWithFlatBuffers(cocos2d::Node *node, auto options = (flatbuffers::CSArmatureNodeOption*)nodeOptions; std::string filepath(options->fileData()->path()->c_str()); + std::string fullpath = FileUtils::getInstance()->fullPathForFilename(filepath); - std::string dirpath = filepath.substr(0, filepath.find_last_of("/")); + std::string dirpath = fullpath.substr(0, fullpath.find_last_of("/")); FileUtils::getInstance()->addSearchPath(dirpath); - ArmatureDataManager::getInstance()->addArmatureFileInfo(FileUtils::getInstance()->fullPathForFilename(filepath)); + ArmatureDataManager::getInstance()->addArmatureFileInfo(fullpath); custom->init(getArmatureName(filepath)); + std::string currentname = options->currentAnimationName()->c_str(); if (options->isAutoPlay()) - custom->getAnimation()->play(options->currentAnimationName()->c_str(), -1, options->isLoop()); + custom->getAnimation()->play(currentname, -1, options->isLoop()); else - custom->getAnimation()->setIsPlaying(false); + { + custom->getAnimation()->play(currentname); + custom->getAnimation()->gotoAndPause(0); + } } cocos2d::Node* ArmatureNodeReader::createNodeWithFlatBuffers(const flatbuffers::Table *nodeOptions) @@ -151,9 +156,9 @@ cocos2d::Node* ArmatureNodeReader::createNodeWithFlatBuffers(const flatbuffers: std::string ArmatureNodeReader::getArmatureName(const std::string& exporJsonPath) { //FileUtils.getFileData(exporJsonPath, "r", size) // need read armature name in exportJsonPath - int end = exporJsonPath.find_last_of("."); - int start = exporJsonPath.find_last_of("\\") + 1; - int start1 = exporJsonPath.find_last_of("/") + 1; + size_t end = exporJsonPath.find_last_of("."); + size_t start = exporJsonPath.find_last_of("\\") + 1; + size_t start1 = exporJsonPath.find_last_of("/") + 1; if (start < start1) start = start1;