void ImageManager::AbstractLoadFromFile(sf::Image &image, std::string name, bool transparency, sf::Color color) { if (!image.LoadFromFile(name)) std::cerr << "Impossible d'ouvrir le fichier " << name << " !" << std::endl; if(transparency) { image.SetSmooth(false); image.CreateMaskFromColor(color); } }
TileSet::TileSet(Json::Value metadata, sf::Image& myImage) { myImage.SetSmooth(false); for (auto iter = metadata.begin(); iter != metadata.end() ; iter++) { Json::Value tileData = *iter; sf::IntRect rect(tileData["x"].asInt(), tileData["y"].asInt(), tileData["x"].asInt() + 64, tileData["y"].asInt()+64); sf::Sprite sprite; sprite.SetImage(myImage); sprite.SetSubRect(rect); vectorOfSprites.emplace_back(std::move(sprite)); } }