Comments (3)
Hey, @VictorJL !
This is probably related to features described in issue #9.
Due to issues with my arms I've been unable to code for the last two months, but I'm recovering
I'll make this my top priority when I'm back. If you want to look into this yourself meanwhile, I suggest you look for differences related to what's described in #9 and look for the missing link in the related class.
Good luck
from tileson.
@VictorJL: I see the feature you are asking about is something I have completely missed, and due to Tileson wrongfully parsing IDs as int and not uint32_t (or unsigned int), you'll have to convert an eventual ID to unsigned int first, then determine it using the example in the Tiled doc: https://doc.mapeditor.org/en/stable/reference/tmx-map-format/#tmx-tile-flipping
This will be implemented with actual flags so you'll not need to do this process yourself once this feature is done.
I am working on it as we speak, but I am sadly still in a recovery process on my arms, so I have a limited time I am able to code, but this my top priority right now. Will update this issue when it's done
from tileson.
@VictorJL : This feature should now be complete! It would be awesome if you could get the very latest version of Tileson and report if everything works as intended tson::Object
linked to tiles, tson::Tile
and tson::TileObject
(which is Tileson-only handling to easily resolve tile positions/drawing data).
Here is a copy/paste from one of the newest integration tests checking flipped tiles (to give you an idea how it works):
TEST_CASE( "Parse map - expect correct flip flags", "[parse][file][flip]" )
{
tson::Tileson t;
#ifndef DISABLE_CPP17_FILESYSTEM
fs::path pathLocal {"../../content/test-maps/ultimate_test.json"};
fs::path pathTravis {"../content/test-maps/ultimate_test.json"};
fs::path pathToUse = (fs::exists(pathLocal)) ? pathLocal : pathTravis;
#else
std::string pathToUse = "../../content/test-maps/ultimate_test.json";
#endif
std::unique_ptr<tson::Map> map = t.parse({pathToUse});
if(map->getStatus() == tson::ParseStatus::OK)
{
tson::Object *obj_ver_flip = map->getLayer("Object Layer")->firstObj("mario_ver_flip");
tson::Object *obj_hor_flip = map->getLayer("Object Layer")->firstObj("mario_hor_flip");
tson::Object *obj_all_flip = map->getLayer("Object Layer")->firstObj("mario_all_flipped");
tson::Object *obj_no_flip = map->getLayer("Object Layer")->firstObj("mario_no_flip");
tson::Tile *tile_ver_flip = map->getLayer("Main Layer")->getTileData(28, 15);
tson::Tile *tile_hor_flip = map->getLayer("Main Layer")->getTileData(28, 14);
tson::Tile *tile_diagvert_flip = map->getLayer("Main Layer")->getTileData(29, 15);
tson::Tile *tile_diaghori_flip = map->getLayer("Main Layer")->getTileData(29, 14);
tson::Tile *tile_no_flip = map->getLayer("Main Layer")->getTileData(25, 14);
tson::TileObject *tileobj_hor_flip = map->getLayer("Main Layer")->getTileObject(28, 14);
tson::TileObject *tileobj_diagvert_flip = map->getLayer("Main Layer")->getTileObject(29, 15);
//Objects
REQUIRE(obj_ver_flip != nullptr);
REQUIRE(obj_ver_flip->hasFlipFlags(tson::TileFlipFlags::Vertically));
REQUIRE(obj_hor_flip != nullptr);
REQUIRE(obj_hor_flip->hasFlipFlags(tson::TileFlipFlags::Horizontally));
REQUIRE(obj_all_flip != nullptr);
REQUIRE(obj_all_flip->hasFlipFlags(tson::TileFlipFlags::Vertically | tson::TileFlipFlags::Horizontally));
REQUIRE(obj_no_flip != nullptr);
REQUIRE(obj_no_flip->hasFlipFlags(tson::TileFlipFlags::None));
//Tiles
REQUIRE(tile_ver_flip != nullptr);
REQUIRE(tile_ver_flip->get<std::string>("name") == "cloudyboy");
REQUIRE(tile_ver_flip->hasFlipFlags(tson::TileFlipFlags::Vertically));
REQUIRE(tile_ver_flip->getId() == 3221225484); //Id including the flags
REQUIRE(tile_ver_flip->getGid() == 12); //Id of the tile
REQUIRE(tile_hor_flip != nullptr);
REQUIRE(tile_hor_flip->get<std::string>("name") == "cloudyboy");
REQUIRE(tile_hor_flip->hasFlipFlags(tson::TileFlipFlags::Horizontally));
REQUIRE(tile_diagvert_flip != nullptr);
REQUIRE(tile_diagvert_flip->get<std::string>("name") == "cloudyboy");
REQUIRE(tile_diagvert_flip->hasFlipFlags(tson::TileFlipFlags::Vertically | tson::TileFlipFlags::Diagonally));
REQUIRE(tile_diaghori_flip != nullptr);
REQUIRE(tile_diaghori_flip->get<std::string>("name") == "cloudyboy");
REQUIRE(tile_diaghori_flip->hasFlipFlags(tson::TileFlipFlags::Horizontally | tson::TileFlipFlags::Diagonally));
REQUIRE(tile_no_flip != nullptr);
REQUIRE(tile_no_flip->get<std::string>("name") == "cloudyboy");
REQUIRE(tile_no_flip->hasFlipFlags(tson::TileFlipFlags::None));
//TileObjects
auto rect = tileobj_hor_flip->getDrawingRect();
REQUIRE(tileobj_hor_flip != nullptr);
REQUIRE(tileobj_hor_flip->getTile() != nullptr);
REQUIRE(tileobj_hor_flip->getPositionInTileUnits() == tson::Vector2i(28, 14));
REQUIRE(tileobj_hor_flip->getPosition() == tson::Vector2f(448, 224));
REQUIRE(tileobj_hor_flip->getTile()->get<std::string>("name") == "cloudyboy");
REQUIRE(tileobj_hor_flip->getTile()->hasFlipFlags(tson::TileFlipFlags::Horizontally));
REQUIRE(tileobj_diagvert_flip != nullptr);
REQUIRE(tileobj_diagvert_flip->getTile() != nullptr);
REQUIRE(tileobj_diagvert_flip->getPositionInTileUnits() == tson::Vector2i(29, 15));
REQUIRE(tileobj_diagvert_flip->getPosition() == tson::Vector2f(464, 240));
REQUIRE(tileobj_diagvert_flip->getTile()->get<std::string>("name") == "cloudyboy");
REQUIRE(tileobj_diagvert_flip->getTile()->hasFlipFlags(tson::TileFlipFlags::Vertically | tson::TileFlipFlags::Diagonally));
}
else
{
std::cout << "Ignored - " << map->getStatusMessage() << std::endl;
REQUIRE(true);
}
}
from tileson.
Related Issues (20)
- CMake Issue when building tests on Windows with MinGW/G++
- Tile layer data compression HOT 2
- Tileset::GetImage() returns a space before extension
- Multiple definition of `std::type_info::operator==(std::type_info const&) const` HOT 6
- Add support for Tiled 1.9
- [SUGGESTION] Add a conan package for library HOT 2
- Update README and documentation for v1.4.0
- Access violation when getting the drawing rect of a tile by id HOT 4
- 'tson::World': no appropriate default constructor available HOT 6
- Text object is missing several important fields. HOT 3
- Add an option to be able to read Tiled Projects and its maps through memory.
- Add an option to be able to read Tiled Worlds and its maps through memory.
- Make sure tson::Class objects with modified values are updated.
- tests depend on amalgamated header, but amalgamate tool requires Linux or Windows; no source provided HOT 2
- tests failing using apple clang 13.0.0 HOT 4
- compiler warnings with Apple Clang 13.0.0
- Fix broken CI for Linux (GCC and Clang)
- Add stricter compile flags when building tests HOT 3
- Make sure TiledEnum values can be properly read from Objects and Tiles
- Fix compression errors occuring on Clang 11 and newer HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tileson.