Comments (4)
A couple of things I notice: mainly this
tmx::MapLayer res = tmx::MapLayer(ml.GetLayers().at(num));
is going to create a copy of a layer and is probably not going to perform brilliantly compared to fetching a reference. Even worse it gets copied again when it's returned from your function. gcc 4.8 should support range-based loops so:
const MapLayer& getLayer(const std::string& name)
{
const auto& layers = ml.getLayers();
for(const auto& l : layers)
{
if(l.name == name) return l;
}
return layers[0];
}
might serve you better. On the other hand (although I admit I can't remember off the top of my head) the map loader does some behind the scenes stuff with culling and setting views to optimise layer drawing. In which case drawing the layer directly won't work and you'll need something like
ml.draw(window, index, false);
to draw a specific layer. In this case your getLayer() function should just return the index of the layer that contains the name you want, or 0 if it does not exist.
ml.draw(window, getLayer("myLayer"), false);
from sfml-tmxloader.
Thank you very much!
Performance problems aside, I can't call ml->Draw() because the first parameter is a RenderTarget.
I think I'm missing something here, I can't pass it my sf::RenderWindow :/
from sfml-tmxloader.
Anyways, I made It to work implementing
MapLoater::Draw(sf::RenderWindow rw, MapLayer ml, bool debug = false);
myself and It is working nice!
Thank you again <3
from sfml-tmxloader.
No problem. From what it looks like in your sample code your window is a pointer, so this should work:
ml.draw(*window, index, false);
as RenderWindow inherits RenderTarget.
from sfml-tmxloader.
Related Issues (20)
- Thanks Matt! HOT 3
- No compatibility with AnimatedSprite class? HOT 2
- MapObject setVisible ? HOT 3
- Terrain Tiled tmx load HOT 3
- Strange culling HOT 4
- Collision issues HOT 7
- Animated Tile with Tiled Editor HOT 4
- layer->tiles doesn't give tiles from layers HOT 3
- Simple test fails: call for help
- Unresolved external symbol HOT 12
- Can't draw map properly if it wasn't the the first one the maploader loaded. HOT 4
- Colission with player sprite HOT 6
- Collisions detected incorrectly due to AABB having incorrect height (2x what it should be) HOT 1
- Isometric causing weird issues HOT 5
- unresolved symbol sf::Sprite::Draw in MapLoaderPublic.obj? HOT 1
- Isometric Layering offset not happening? HOT 22
- Missing vtable HOT 3
- Can not build tmxsfml project as I've set link options correctly HOT 1
- Doesn't build woth MinGW Makefiles HOT 2
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 sfml-tmxloader.