Skip to content

jmecn/TMXLoader

Repository files navigation

Introduction

TMXLoader is used for loading .tmx assets created by Tiled Map Editor. It's a plugin for jMonkeyEngine3.

You can download it here: https://github.com/jmecn/TMXLoader/releases. Or use the source.

Java CI with Gradle

How to use

maven

<dependencies>
    <dependency>
        <groupId>io.github.jmecn</groupId>
        <artifactId>tmx-loader</artifactId>
        <version>0.6.0</version>
    </dependency>
    <dependency>
        <groupId>io.github.jmecn</groupId>
        <artifactId>tmx-renderer</artifactId>
        <version>0.6.0</version>
    </dependency>
</dependencies>

gradle

repositories {
    mavenCentral()
}

dependencies {
    implementation 'io.github.jmecn:tmx-loader:0.6.0'
    implementation 'io.github.jmecn:tmx-renderer:0.6.0'
}

Example

package io.github.jmecn.tiled.app;

import com.jme3.app.SimpleApplication;
import com.jme3.system.AppSettings;
import io.github.jmecn.tiled.TiledMapAppState;
import io.github.jmecn.tiled.TmxLoader;
import io.github.jmecn.tiled.core.TiledMap;

/**
 * Test loading tmx assets with TmxLoader.
 * @author yanmaoyuan
 *
 */
public class TmxLoaderExample extends SimpleApplication {

    @Override
    public void simpleInitApp() {
        // register it
        TmxLoader.registerLoader(assetManager);

        // load tmx with it
        TiledMap map = (TiledMap) assetManager.loadAsset("Desert/desert.tmx");

        // render it with TiledMapAppState
        stateManager.attach(new TiledMapAppState());

        TiledMapAppState tiledMap = stateManager.getState(TiledMapAppState.class);
        tiledMap.setMap(map);
        tiledMap.setViewColumn(20);
    }

    public static void main(String[] args) {
        AppSettings settings = new AppSettings(true);
        settings.setWidth(1280);
        settings.setHeight(720);
        settings.setSamples(4);
        settings.setGammaCorrection(false);

        TmxLoaderExample app = new TmxLoaderExample();
        app.setSettings(settings);
        app.start();
    }
}

Screenshots

  • Orthogonal Map

orthogonal03

  • Iso map

isometric01

  • Hex map

hexagonal01

  • Staggered map

staggered05

animated tile

  • Parallax scroll

https://youtu.be/0OIIdxaAZjA