diff --git a/.DS_Store b/.DS_Store index 8066f49..4e94d37 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/assets/.DS_Store b/assets/.DS_Store index 0079dd6..a86f354 100644 Binary files a/assets/.DS_Store and b/assets/.DS_Store differ diff --git a/src/.DS_Store b/src/.DS_Store index c2fba20..284a1f7 100644 Binary files a/src/.DS_Store and b/src/.DS_Store differ diff --git a/src/ecs/SpriteComponent.h b/src/ecs/SpriteComponent.h index bfabd28..3794177 100644 --- a/src/ecs/SpriteComponent.h +++ b/src/ecs/SpriteComponent.h @@ -66,8 +66,8 @@ public: spriteType = sType; if(sType == spriteAnimation) { - std::string fullPath = Game::projPath + json; - std::ifstream fin(fullPath); + //std::string fullPath = Game::projPath + json; + std::ifstream fin(json); if(fin.fail()){ std::cerr<<"ERROR opening json file: " << json << std::endl; @@ -79,13 +79,15 @@ public: std::string aJson = tmp.str(); cJSON * animJson = cJSON_Parse(aJson.c_str()); std::cout << "animJson: " << std::endl; - //std::cout << animJson << std::endl; - //char * printOut = cJSON_Print(animJson); + std::cout << animJson << std::endl; + char * printOut = cJSON_Print(animJson); //std::cout << animJson << std::endl; cJSON * meta = cJSON_GetObjectItem(animJson, "meta"); cJSON * version = cJSON_GetObjectItem(animJson, "version"); cJSON * frameTags = cJSON_GetObjectItem(meta,"frameTags"); + cJSON * frames = cJSON_GetObjectItem(animJson, "frames"); int tagsCount = cJSON_GetArraySize(frameTags); + int framesCount = cJSON_GetArraySize(frames); //std::cout << "tagsCount: " << tagsCount << std::endl; //std::cout << "version: " << version << std::endl; const cJSON * aFrame = NULL; @@ -94,12 +96,19 @@ public: cJSON_ArrayForEach(aFrame, aFrames){ cJSON *filename = cJSON_GetObjectItemCaseSensitive(aFrame, "filename"); if (!cJSON_IsNumber(aFrame)){ - printf("Not a number\n"); + //printf("Not a number\n"); + //printf("Json filename: %s\n",filename); } else { - std::cout << "animation frame number: " << aFrame->valueint<< std::endl; + //std::cout << "animation frame number: " << aFrame->valueint<< std::endl; } } + for (int f = 0; fvaluestring; + std::cout << "Filename for frame is: " << fileName << std::endl; + } + for (int t = 0; t < tagsCount; t++) { cJSON * animItem = cJSON_GetArrayItem(frameTags,t); @@ -109,7 +118,7 @@ public: int toFrame = cJSON_GetObjectItem(animItem, "to")->valueint; Animation anim = Animation(fromFrame,toFrame,100); animations.emplace(name, anim); - std::cout << "Animation Name: " << name << std::endl; + std::cout << "Animation Name: " << name << "from: " << fromFrame << "to: " << toFrame << std::endl; Play(name); } } diff --git a/src/game/Game.cpp b/src/game/Game.cpp index 8c2f6a7..b37bd50 100644 --- a/src/game/Game.cpp +++ b/src/game/Game.cpp @@ -180,7 +180,8 @@ void Game::init(const char *title, int width, int height, bool fullscreen, int g //ecs implementation player.addComponent(150*gScale,100*gScale,32,32,globalScale,2); // 180,120 - player.addComponent("player", SpriteComponent::spriteAnimation, "assets/textures/actors/kaijuturtle.json"); + std::string playerJson = Game::projPath + "assets/textures/actors/kaijuturtle.json"; + player.addComponent("player", SpriteComponent::spriteAnimation, playerJson); // player.addComponent(0.0,0.0,false,false,Vector2D().Zero()); player.addComponent("player",20*globalScale,20*globalScale, true, 0*globalScale,0*globalScale, "");