Scratch for Java

TiledMap()

This class works in a project you run on your own computer, but not in the examples you can start here in the browser. There is no file system, no video encoder and no OpenGL behind a web page, so calling it there tells you as much and does nothing.

The TiledMap class represents a map created using the Tiled map editor. It provides methods to load the map from an XML file, retrieve objects from layers, and stamp layers onto the foreground or background of a stage.

Example usage:

TiledMap map = new TiledMap("assets/map.tmx", stage);
 map.stampLayerToForeground("foreground");
 
 for (MapObject object : map.getObjectsFromLayer("objects")) {
   if (object.type.equals("player")) {
     Player p = new Player(object.x, object.y);
     stage.addSprite(p);
   }
 }

Syntax

Java

new TiledMap(path, stage)
TiledMap()

Create Shareable URL

Select Sections