[Ceramic Tile Engine] Can not center the camera

Hello there! I used to try Ceramic Tile Engine to load and use maps made in Tiled Map Editor. There were some short code samples on different web sites so in final I got this:

local ceramic=require("Ceramic") level = {} level.scale = 2.5 level.map = nil function level\_load(id) level.map=ceramic.buildMap("level\_"..tostring(id)..".json") level.map.xScale = level.scale level.map.yScale = level.scale player = level.map.layer["Dynamic"].object["Hero"] level.map:setReferencePoint(display.CenterReferencePoint) level.map.setCameraFocus(player) return true end

It is not fully centered. It might be caused by setting xScale and yScale of the “level.map”. If set it to 1.0 everything will be fine. What should I multiply by “level.scale” to center the camera?

2eed5eg.png

Ceramic is an experimental form of the Dusk Engine; it doesn’t support scaling.

The algorithm for scaling is rather complicated, but at the moment, if you still want to use Ceramic (Dusk’ll be 99.999% backwards-compatible), you can edit the internal code of the .updateMap() method:

In lines #777 and 778

[lua]

targetX = (display.contentCenterX / map.xScale) + targetX

targetY = (display.contentCenterY / map.yScale) + targetY

[/lua]

That *should* make it work.

  • Caleb

Caleb P, it works! Thank you so much!

Ceramic is an experimental form of the Dusk Engine; it doesn’t support scaling.

The algorithm for scaling is rather complicated, but at the moment, if you still want to use Ceramic (Dusk’ll be 99.999% backwards-compatible), you can edit the internal code of the .updateMap() method:

In lines #777 and 778

[lua]

targetX = (display.contentCenterX / map.xScale) + targetX

targetY = (display.contentCenterY / map.yScale) + targetY

[/lua]

That *should* make it work.

  • Caleb

Caleb P, it works! Thank you so much!