Nothing shows up

I worked with Lime and Tiled before, but i’m having hard time starting with MTE. nothing shows up when I run my project, I see black screen.

main.lua

local mte = require('mte').createMTE()   mte.loadTileSet("bricks\_1", "map.png") mte.loadMap("map.tmx")  

both map.tmx and map.png in main folder of the project

map.tmx

\<?xml version="1.0" encoding="UTF-8"?\> \<map version="1.0" orientation="orthogonal" width="18" height="26" tilewidth="20" tileheight="20"\> &nbsp;\<tileset firstgid="1" name="bricks\_1" tilewidth="40" tileheight="20"\> &nbsp; \<image source="map.png" width="160" height="100"/\> &nbsp;\</tileset\> &nbsp;\<layer name="Tile Layer 1" width="18" height="26"\> &nbsp; \<data encoding="csv"\> 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0, 0,0,0,1,0,1,0,1,0,1,0,16,0,0,0,0,0,0, 0,0,0,16,0,1,0,1,0,1,0,1,0,0,0,0,0,0, 0,0,0,16,0,1,0,1,0,1,0,16,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0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,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 \</data\> &nbsp;\</layer\> &nbsp;\<objectgroup name="Object Layer 1" width="300" height="300"\> &nbsp; \<properties\> &nbsp; &nbsp;\<property name="spriteLayer" value="true"/\> &nbsp; \</properties\> &nbsp;\</objectgroup\> \</map\>&nbsp;

 simulator output

Copyright (C) 2009-2014 &nbsp;C o r o n a &nbsp; L a b s &nbsp; I n c . &nbsp; &nbsp; &nbsp; Version: 3.0.0 &nbsp; &nbsp; &nbsp; &nbsp; Build: 2014.2189 Platform: Droid / x64 / 6.1 / Intel(R) HD Graphics 4000 / 4.0.0 - Build 9.17.10. 2932 World Size X: 18 World Size Y: 26 Levels: 1 Reference Layer: 1 Map Load Time(ms): 4 &nbsp;

I’ve tried adding “mte.goto”, but then I’m receiving an error “main.lua:19: attempt to call field ‘goto’ (a nil value)”

mte.goto({locX = 10, locY = 10, blockScale = 32})&nbsp;

I Changed “goto” to “setCamera” and now I can see the tiles. the documentation is misleading…

mte.setCamera({locX = 8, locY = 1, scale = 1})

but now I’ve another question:

How can I “setCamera” so I can see the map as I see it in map editor?

http://postimg.org/image/ssgxjl28b/

Hello there,

The API changed recently from goto to setCamera. If you could point me to the references I missed I’ll correct them. 

As for your second question, could you post the contents of your config.lua file? What you’re seeing appears to be the result of a bug in MTE. I’ve squashed it on my end, but I’d like to double check the solution before releasing it. Or, if you’d like, you can go to line 67 of mte.lua and modify the code block there to test it yourself. MTE 0v984 reads as follows:

--SCREEN CONSTANTS local viewableContentWidth = display.viewableContentWidth local screenLeft, screenTop, screenRight, screenBottom, screenCenterX, screenCenterY if display.viewableContentWidth \< display.viewableContentHeight then screenLeft = display.screenOriginX screenTop = display.screenOriginY screenBottom = display.screenOriginX + (display.pixelHeight \* display.contentScaleY) screenRight = display.screenOriginY + (display.pixelWidth \* display.contentScaleX) screenCenterY = display.screenOriginX + (display.pixelHeight \* display.contentScaleY) / 2 screenCenterX = display.screenOriginY + (display.pixelWidth \* display.contentScaleX) / 2 else screenLeft = display.screenOriginX screenTop = display.screenOriginY screenRight = display.screenOriginX + (display.pixelHeight \* display.contentScaleY) screenBottom = display.screenOriginY + (display.pixelWidth \* display.contentScaleX) screenCenterX = display.screenOriginX + (display.pixelHeight \* display.contentScaleY) / 2 screenCenterY = display.screenOriginY + (display.pixelWidth \* display.contentScaleX) / 2 end 

Please replace all the above code with the following and see if that helps:

--SCREEN CONSTANTS local viewableContentWidth = display.viewableContentWidth local screenLeft, screenTop, screenRight, screenBottom, screenCenterX, screenCenterY if display.viewableContentWidth \< display.viewableContentHeight then screenCenterX = display.contentWidth / 2 screenCenterY = display.contentHeight / 2 screenLeft = 0 + display.screenOriginX screenTop = 0 + display.screenOriginY screenRight = display.contentWidth - display.screenOriginX screenBottom = display.contentHeight - display.screenOriginY else screenLeft = display.screenOriginX screenTop = display.screenOriginY screenRight = display.screenOriginX + (display.pixelHeight \* display.contentScaleY) screenBottom = display.screenOriginY + (display.pixelWidth \* display.contentScaleX) screenCenterX = display.screenOriginX + (display.pixelHeight \* display.contentScaleY) / 2 screenCenterY = display.screenOriginY + (display.pixelWidth \* display.contentScaleX) / 2 end

If you could point me to the references I missed I’ll correct them

“MTE 0v984 Tilesets, Map Structure, Getting Started.pdf” from the archive that I received 

config.lua

application = { content = { width = 320, height = 480, scale = "letterBox", fps = 30, --[[imageSuffix = { ["@2x"] = 2, } --]] }, --[[-- Push notifications notification = { iphone = { types = { "badge", "sound", "alert", "newsstand" } } } --]] }

after the changes in code: http://s28.postimg.org/5q6m0x5dp/555.png

Could the map be fixed 100% width and height if i’m not setting setCamera?

Alright, I’ve removed that goto for the next update, and the code changes you made have corrected the bug on your end as well- the image you posted is showing correct engine behavior. You can call mte.constrainCamera({}) to prevent any black space around the map. Setting the scale to 1 will show the map at 100% of it’s width and height, but this will not necessarily conform to the size of the screen. 

just spent a bit of time trying to work out how to remove black space and set params, then realized you could just call the method with no arguments - cool

perhaps just add a comment to the api example of “mte.constrainCamera()” to something like:

- mte.constrainCamera()    –  to prevent any black space around the map

(i.e. just so it’s more obvious this is possible)

That’s a great idea, Greg. I’ll clarify that in the docs.

I Changed “goto” to “setCamera” and now I can see the tiles. the documentation is misleading…

mte.setCamera({locX = 8, locY = 1, scale = 1})

but now I’ve another question:

How can I “setCamera” so I can see the map as I see it in map editor?

http://postimg.org/image/ssgxjl28b/

Hello there,

The API changed recently from goto to setCamera. If you could point me to the references I missed I’ll correct them. 

As for your second question, could you post the contents of your config.lua file? What you’re seeing appears to be the result of a bug in MTE. I’ve squashed it on my end, but I’d like to double check the solution before releasing it. Or, if you’d like, you can go to line 67 of mte.lua and modify the code block there to test it yourself. MTE 0v984 reads as follows:

--SCREEN CONSTANTS local viewableContentWidth = display.viewableContentWidth local screenLeft, screenTop, screenRight, screenBottom, screenCenterX, screenCenterY if display.viewableContentWidth \< display.viewableContentHeight then screenLeft = display.screenOriginX screenTop = display.screenOriginY screenBottom = display.screenOriginX + (display.pixelHeight \* display.contentScaleY) screenRight = display.screenOriginY + (display.pixelWidth \* display.contentScaleX) screenCenterY = display.screenOriginX + (display.pixelHeight \* display.contentScaleY) / 2 screenCenterX = display.screenOriginY + (display.pixelWidth \* display.contentScaleX) / 2 else screenLeft = display.screenOriginX screenTop = display.screenOriginY screenRight = display.screenOriginX + (display.pixelHeight \* display.contentScaleY) screenBottom = display.screenOriginY + (display.pixelWidth \* display.contentScaleX) screenCenterX = display.screenOriginX + (display.pixelHeight \* display.contentScaleY) / 2 screenCenterY = display.screenOriginY + (display.pixelWidth \* display.contentScaleX) / 2 end 

Please replace all the above code with the following and see if that helps:

--SCREEN CONSTANTS local viewableContentWidth = display.viewableContentWidth local screenLeft, screenTop, screenRight, screenBottom, screenCenterX, screenCenterY if display.viewableContentWidth \< display.viewableContentHeight then screenCenterX = display.contentWidth / 2 screenCenterY = display.contentHeight / 2 screenLeft = 0 + display.screenOriginX screenTop = 0 + display.screenOriginY screenRight = display.contentWidth - display.screenOriginX screenBottom = display.contentHeight - display.screenOriginY else screenLeft = display.screenOriginX screenTop = display.screenOriginY screenRight = display.screenOriginX + (display.pixelHeight \* display.contentScaleY) screenBottom = display.screenOriginY + (display.pixelWidth \* display.contentScaleX) screenCenterX = display.screenOriginX + (display.pixelHeight \* display.contentScaleY) / 2 screenCenterY = display.screenOriginY + (display.pixelWidth \* display.contentScaleX) / 2 end

If you could point me to the references I missed I’ll correct them

“MTE 0v984 Tilesets, Map Structure, Getting Started.pdf” from the archive that I received 

config.lua

application = { content = { width = 320, height = 480, scale = "letterBox", fps = 30, --[[imageSuffix = { ["@2x"] = 2, } --]] }, --[[-- Push notifications notification = { iphone = { types = { "badge", "sound", "alert", "newsstand" } } } --]] }

after the changes in code: http://s28.postimg.org/5q6m0x5dp/555.png

Could the map be fixed 100% width and height if i’m not setting setCamera?

Alright, I’ve removed that goto for the next update, and the code changes you made have corrected the bug on your end as well- the image you posted is showing correct engine behavior. You can call mte.constrainCamera({}) to prevent any black space around the map. Setting the scale to 1 will show the map at 100% of it’s width and height, but this will not necessarily conform to the size of the screen. 

just spent a bit of time trying to work out how to remove black space and set params, then realized you could just call the method with no arguments - cool

perhaps just add a comment to the api example of “mte.constrainCamera()” to something like:

- mte.constrainCamera()    –  to prevent any black space around the map

(i.e. just so it’s more obvious this is possible)

That’s a great idea, Greg. I’ll clarify that in the docs.