-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Colission with player sprite #70
Comments
Hi, as you 've closed this I'll assume you found a solution - there are a couple of links you can check out though: Alternatively my SFML frame work xygine has built in tmx/collision support (check the 2D tilemap demo in the included example) |
Yeah, I solved it and thanks for the links 👍 But if you solve one problem, another one pops up, hehe... So, right now it's detecting colission with the player sprite and the platforms, so I can jump on them and everything works fine that way. But, as it seems, the colission is constantly checking all of the objects in the layer, something which could be fixed by using a quadtree, which you mentioned in your blog and on the homepage of this repository. So I simply did:
and then I check for colission with the objects in the layer. But it seems like it's not working as expected as the debug text prints out a mix of 'true' (if colission occur) and 'false' (colission didn't occur), when it should printout only 'true' (if I'm intersecting with a platform) as I should only be checking with each platform at a time.
Do you have any ideas? @fallahn |
No, that sound right. If a layer or quad tree query returns 3 platforms and you only intersect one, then the output would be
or similar, as you're only colliding with one of the 3 platforms. Try also outputting the layer object count, and see if it matches up with the number of true/false statements in the console |
Hmm, oh that sounds quite right, yeah. But still, I'm having an issue how to make the player unable to continue walking when he's actually in midair, which is actually why I wanted it to only print 'true' when I was intersecting with one platform. Because if it would, I could have a boolean in there which would turn true if I was intersecting and then false if I wouldn't intersect. Then I could use this boolean to restrict the player movement and simply let the player fall free if not on the platform. But as it is now, this boolean would switch from true to false even if I was on one single platform, making this approach useless. What would be the recommended approach? :) @fallahn |
This might help :) |
Yep, I have to look into the art of game design a bit more. Thanks for the help anyways and the effort you put into the library. |
Hey!
I have created a tilemap with simple rectangular platforms and I have added an object layer and marked the platforms in order to perform colission. I have checked your example folder for the b2d map and used the same code for the debug shapes so I could see the outlines (red) of the object layer objects.
Now I want the player sprite in the project to perform colission with the platforms, which shouldn't be too complicated as the sprite is a rectangular shape and the platforms are rectangular shapes aswell. Though, I can't get it to work, what would be an easy way to do it?
The text was updated successfully, but these errors were encountered: