Full world not loading and not panning

I’m just getting started with MTE and have created a sample map in Tiled and have loaded it up like below

----------------------------------------------------------------------------------------- -- -- main.lua -- ----------------------------------------------------------------------------------------- display.setStatusBar( display.HiddenStatusBar ) system.activate( "multitouch" ) local mte = require('mte').createMTE() --Load and instantiate MTE. mte.loadTileSet("Grass Block", "map/Grass Block.png") mte.loadTileSet("Water Block", "map/Water Block.png") mte.loadTileSet("Plain Block", "map/Plain Block.png") mte.loadTileSet("Dirt Block", "map/Dirt Block.png") mte.loadMap("map/new.tmx") mte.enableTouchScroll() mte.enablePinchZoom() if mte.getMap().layers then mte.setCamera({locX = 10, locY = 12, blockScaleX = 101, blockScaleY = 171}) end

The map is 50x50 tiles where each tile is 101 x 171.

I can see that this does get detected when the map loads as the console logs:
 

World Size X: 50

World Size Y: 50

Levels: 1

Reference Layer: 1

However when the map loads up i can only see roughly 16x16 tiles rather than 50x50.

I can use pinch to zoom but i cannot pan around, is there something I’m doing wrong?

Hello Tamoor666,

Your config.lua defines the width and height of the content area visible onscreen. If content width = 768 and height = 1024, for example, you will only see on the order of 10 x 10 tiles onscreen at any given moment. Generally the content area should be relatively close to the screen resolution of the devices you’re targeting. Reducing your blockScale will increase the number of tiles that will fit onscreen. Just keep an eye on performance; many budget tablets and phones will have trouble with 50x50 tiles, particularly ones as large as yours.

MTE processes camera movement, sprite movement, and most other things when mte.update() executes. Generally you’ll want to call mte.update() in an enterFrame event:

local gameLoop = function(event) mte.update() end Runtime:addEventListener("enterFrame", gameLoop)

Thanks dyson

I’m actually just playing around with MTE at the moment to see what i can do with it before i create my game

For larger maps is there a way for MTE to only load the tiles that are on-screen and then load the rest as you pan towards them?

MTE automatically spawns tiles as their map locations move onscreen and culls the tiles when they move offscreen. The engine only displays as many tiles as needed to fill the screen, unless overridden by setting a cullingMargin in setCamera(). When it comes to performance, the main determining factor is the number of tiles and sprites, with some impact from the size of the tiles as well. In general iOS devices perform much better than Android devices, particularly when running very large tiles. On a Samsung Galaxy S4 you’re going to want to keep the total number of onscreen tiles down below 1000, and lower if these tiles are enormous (101x171, for example). Dropping the target framerate in config.lua from 60 to 30 will also help to keep things running smoothly when you’re pushing the performance envelope.

Hello Tamoor666,

Your config.lua defines the width and height of the content area visible onscreen. If content width = 768 and height = 1024, for example, you will only see on the order of 10 x 10 tiles onscreen at any given moment. Generally the content area should be relatively close to the screen resolution of the devices you’re targeting. Reducing your blockScale will increase the number of tiles that will fit onscreen. Just keep an eye on performance; many budget tablets and phones will have trouble with 50x50 tiles, particularly ones as large as yours.

MTE processes camera movement, sprite movement, and most other things when mte.update() executes. Generally you’ll want to call mte.update() in an enterFrame event:

local gameLoop = function(event) mte.update() end Runtime:addEventListener("enterFrame", gameLoop)

Thanks dyson

I’m actually just playing around with MTE at the moment to see what i can do with it before i create my game

For larger maps is there a way for MTE to only load the tiles that are on-screen and then load the rest as you pan towards them?

MTE automatically spawns tiles as their map locations move onscreen and culls the tiles when they move offscreen. The engine only displays as many tiles as needed to fill the screen, unless overridden by setting a cullingMargin in setCamera(). When it comes to performance, the main determining factor is the number of tiles and sprites, with some impact from the size of the tiles as well. In general iOS devices perform much better than Android devices, particularly when running very large tiles. On a Samsung Galaxy S4 you’re going to want to keep the total number of onscreen tiles down below 1000, and lower if these tiles are enormous (101x171, for example). Dropping the target framerate in config.lua from 60 to 30 will also help to keep things running smoothly when you’re pushing the performance envelope.