How to import Tiled in Android ( no engine)?

(Beautiful Life) #1

i want import tiled map in my android project ( don’t use engine same Andengine,libgdx). How can i do it?

(Beautiful Life) #2

help me. please

(Thorbjørn Lindeijer) #3

You can find some Java source code for reading and rendering Tiled maps here:

Note though, that these libraries are out of date. They may work for you, but it is also likely that you will run into minor issues and missing functionality. You’d then have to either write your own map reader and renderer or adjust the code as necessary. See also the documentation of the TMX map format.

(Ben Wheeler) #4

I used a modified version of The code is not quite right for modern versions of Android, so needed some tweaking. Also there is no hex renderer so I’m writing my own.

I’ve been pondering whether to clean up my changes and do a PR back to the @bjorn repo, though it would have to include making the resources generic, as the Android and Swing ones don’t play well with each other.

(Thorbjørn Lindeijer) #5

Any help in making the libtiled-java shipping with Tiled more useful would be very appreciated. How would it work to make the resources more generic?

(Beautiful Life) #6

thanks verymuch

(Ben Wheeler) #7

It would mean wrapping the Android Bitmap and AWT Image/BufferedImage references with a generic image interface.

Then probably creating an abstract factory to load these from streams and/or paths. Maybe with some generics thrown in to make it nicer to work with.

Then to implement bindings to another platform, you would (hopefully) just need to implement a new factory. Though this is just the basic idea…

(Thorbjørn Lindeijer) #8

Hmm, maybe it would be better to extract the image loading and rendering parts out of the library, and leave those to be implemented on the game engine side? We could show some example code to get people started instead.

(Ben Wheeler) #9

I had a go at reworking it, and have the basics. Its not great.

There is a lot of coupling between the library and AWT. The MapObject code specifically uses AWT ellipse and some other stuff. The tile cutter does a bunch of AWT calls to implement transparency.

I’ve made all the references to Image generic, but its not a great way to do it. It would probably be better to separate out all the images and just hold an id reference to them in each Tile. The image management code in TileSet would be better somewhere else too.

Also any AWT specific code doesn’t compile in Android Studio :frowning:. Its probably the same for Android classes in other IDEs.

(Thorbjørn Lindeijer) #10

Right, sounds like taking the graphics stuff out rather than making it generic will be the easier and better way to go. There is no need for using some Ellipse class, the object just needs a ‘shape’ enumeration. The tile cutter could just be removed.

Of course, we do have the tmxviewer-java and other applications may find a use for the rendering parts, but they could be moved to a libtiled-swing library that depends on plain libtiled-java. Then, a libtiled-android (or maybe named after the Android base library it would use) could similarly be added.

Thanks for having a go at this, btw!

(Beautiful Life) #11

Hello. How to import AndroidTMX in android Studio?

(Thorbjørn Lindeijer) #12

Are you talking about Android-TMX-Loader? If so, please read their documentation and if you’re having trouble, try contacting its author. This library has not been updated in 4 years so it’s unlikely you’ll find help here.

Or maybe you need to ask people who know Android Studio.

(Charles Charbonneau) #13

The new Game Engine mode in Mintoris Basic Pro supports Tiled maps. Simple and rapid app development for Android.

Mintoris Basic Pro