-
Notifications
You must be signed in to change notification settings - Fork 82
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
Kivy support #59
Comments
Thanks for your interest with pytmx. As far as inverting the y-coordinate, there is a way to do that already (has partial support). Pass 'invert_y=True' to whatever loader or to the TiledMap constructor. That value will be saved in the TiledMap instance. I think the proper solution would be to modify TiledTileLayer.parse_xml to be inverted_axis aware. That would be somewhere around here: https://github.com/bitcraft/PyTMX/blob/master/pytmx/pytmx.py#L916 tmx_data = pytmx.TiledMap(..., invert_y=True) As far as image loading goes, there is another approach to image loading that you may be interested in. You can define a function to load images, without resorting to subclassing...pass an argument to the TiledMap constructor. Please see the link below for more information: What graphics library are you using now? ...just curious. |
thanks, the built-in line 316 - 317 of pytmx.py:
should be:
However, this code never actually runs for me because In otherwords, for me
Also, I am already using the image_loader approach you recommend. See my original comment, with the only difference being that I subclass in order to pass the current tileset. It is necessary to know the current tileset in order to get |
I guess I'm confused here. Does your graphics lib require a flipped tileset image? Could you tell me what graphics lib you are using? That would help me out a lot here. Any code that you've already created would be nice, too. I'd like to see what you are doing, and how I can make pytmx better with your contributions. Thanks. |
Sorry, forgot to mention I am using the Python framework Kivy. It displays content assuming y=0 is at the bottom of the page (hence why I must change content at the top of the page to have y>0) |
Awesome! I'm a big fan of kivy. I've gotten a few requests for ivy support now, I suppose I should do something about it. It would be a great help if you could send your changes in a PR (or diff/paste), so I have somewhere to start. |
Sorry, I'm not too familiar with git hub but here is a working example with Kivy and Tiled tmx:
|
No worries! Thanks so much for sharing that. I will take a look at it later today. |
Any news on this? |
How about simply passing tileset object into image_loader? (see #72). This approach still requires manually converting y axis coordinate inside the loader, but it provides all necessary data required to do the math. |
Iabuzm, I've been busy with other projects at the moment, but I will look into your proposal. Thanks for your suggestions, I will check back when I get time. |
helo i am on a project and i need to use pytmx i need pytmx support for kivy today itself plz |
Hi thanks for your interest. I haven’t worked with kivy compatibility lately. Have you tried the code that is in this thread? |
yes but i am getting some errors in this part of the code def load((x,y,w,h)=None, flags=None): |
can you give me a clean code from that |
i am not giving up on pytmx because i love pytmx with pygame |
and i am a student at 13 years sorry to ask this much questions wasting your time i would like to know how to scale our scrolling tmx file accourding to the window |
looks pretty good so far. one thing i notice is that the images don't seem to align with the tiles. that looks like the margin or spacing of the tileset isn't set or being used properly. if you can share the map and code you are using, i could help you get this fixed. as for scrolling, you would have to rely on Kivy to do that...its been a long time since i've used it so i don't have a good idea for that right now. |
When displaying tiles in OpenGL formatted coordinate systems (y=0 occurs at bottom of page instead of top of page), there is a simple transformation needed to ensure data appearing at the top of the page has coordinates starting from max(y) rather than 0. Would it make sense to incorporate an image loader that handles this simple, yet common transformation?
See below where I had to subclass TiledMap and override the
reload_images
method just to set theimage_loader
to one that sets the y ordinate based on the currenttileset
'stileheight
andheight
. Is there a cleaner, more future-version-compatible-robust way for loading images with correct coordinates for OpenGL displays?Also, this issue comes up again after you've loaded the images from the tileset and now need to play them as widgets in your OpenGL display window. Again, the conversion is needing to know
tileset
specific dimensions. Is there a convenient way to look this up?For instance, I do something kinda ugly like this:
The text was updated successfully, but these errors were encountered: