Comments (4)
Yeah a way to get all tagged/typed int grid tiles would be fantastic.
from ldtkloader.
To get the int grid values, you can use the getIntGridValue
method of a Layer. It will return an IntGridValue that contains the value, name and color.
To get the tiles rendered in an Autolayer, you can use the allTiles
and getTile
methods of a Layer. These methods return Tile instances that are created using the "autoLayerTiles" data from the ldtk file. You can look at the SFML or SDL examples, they both use layer.allTiles()
to iterate on the tiles in an Autolayer to render the tiles.
This made me realize the wiki page for the ldtk::Tile class is missing. I will create it soon.
from ldtkloader.
Thanks. But is there any way to get a list of tiles with their int grid id specifically? For example, if i wanted to mark those tiles as impassible, for creating collision boxes, or if i wanted to mark specific terrain types, etc. Maybe a key value pair of position, intgridvalue?
Something like: map<vec2, intgrid> ?
from ldtkloader.
Okay, so if I understand correctly, you would like a way to get all tiles that have a specific intgrid value ?
An API like this:
auto Layer::getIntGridValuePositions(const string& name) -> vector<InPoint>;
auto Layer::getIntGridValuePositions(int intgrid_value) -> vector<InPoint>;
This could return all the position in grid coordinates of an IntGridValue occurrences.
For example, to get the positions of tiles that have the IntGridValue { 1, "collision", Color::Red} , you would do:
const auto& collision_tiles_pos = layer.getIntGridValuePositions("collision");
for (const auto& pos : collision_tiles_pos) {
const auto& tile = layer.getTile(pos.x, pos.y);
if (tile != ldtk::Tile::None) {
// a tile exists, create a collision
}
}
Is this what you are looking for ?
from ldtkloader.
Related Issues (13)
- Fail to load EntityFields that can be null HOT 1
- No Way to Get List of All Entities HOT 1
- why do the examples use render textures? HOT 4
- Loading external level files does not take world directory into account HOT 1
- Texture coordinates are hardcoded to 16x16 tiles HOT 1
- Compile times, in particular external includes HOT 5
- Compile error: "Cannot use 'throw' with exceptions disabled" HOT 7
- Can't parse LDtk 1.2.0 HOT 1
- Undefined reference to... HOT 7
- SDL Example does not build HOT 2
- Update third party JSON. HOT 5
- Layer::getCoordIdAt calculation flawed 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 ldtkloader.