void ObstacleSpawner::Deserialize() { JValue* obstacleData = ResourceManager::GetInstance()->GetJson("ObstacleConfig"); JValue & obstacleArray = (*obstacleData)["obstacles"]; _numOfObtacles = obstacleArray.GetLength(); for (int i = 0; i <_numOfObtacles;i++ ) { std::string name = obstacleArray[i]["name"].ToString(); SDL_Texture * texture = ResourceManager::GetInstance()->GetTexture(name); Drawable * drawable = new Drawable(); drawable->SetTexture(texture); AABB * aabb = new AABB(); aabb->SetRect(drawable->GetRect()); Obstacles * newObstacle = new Obstacles(); newObstacle->SetCollider(aabb); newObstacle->SetDrawable(drawable); newObstacle->weight = obstacleArray[i]["weight"].ToInt(); _obstacleArray.InsertAtLast(newObstacle); } DEBUGLOG("%s","ObstacleSpawner init success"); }