Comments (7)
If you're using SetPosition, it calls Move which edits the polypoints and causes collision issues, there is a bug for it here: #21
from sfml-tmxloader.
is there a way around this? been trying to get my player to collide with the walls but gave up as it wasn't recognizing it
from sfml-tmxloader.
You can comment out the lines where the polypoints are changed in MapObject::Move but even after I did this I was getting some different issues and I didn't want to waste lots of time debugging it.
I went the route of converting each MapObject into an sfml convex shape and wrapping it in my own class. You'll have to copy the MapObject::intersects and MapObject::contains methods to do collision with the convex shapes.
from sfml-tmxloader.
This is basically down to a badly designed MapObject class on my part. I'm aware of this and plan to rewrite it using the sf::Transformable class. As this will be likely an API breaking change it will be part of version 2 of the map loader (although I can't offer any estimation on when it's done, I only work on this as time allows). Version 2 can always be previewed via the 'next' branch of the repository (and already has many improvements) if you want to track its progress. For a work around in its current state, although it's a little more effort, the box2D utilities do correctly parse map objects, so the box2D collision detection system can be used. Box2D doesn't force you to use the physics part if you only wish to detect collisions - they can be handled by your own callbacks if you'd prefer (check out the box2D docs for this).
from sfml-tmxloader.
So I wouldn't need box2d in order to do this method?
from sfml-tmxloader.
You still need to link to box2D. Using the functions found in tmx2box2d.cpp you can then convert the map objects to box2D objects. Afterwards you can either let box2D use its physics, or you can supply callbacks to box2D to handle your own collisions.
from sfml-tmxloader.
I've pushed a potential fix for this to the 'next' branch, if anyone would like to try it and offer feedback / pull requests. I'll close this particular issue and point to #21 for further discussion
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
- Animated Tile with Tiled Editor HOT 4
- layer->tiles doesn't give tiles from layers HOT 3
- GetLayers() doesn't work as spected HOT 4
- 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.