constrainCamera and sprite offset

Hey there

firstly, Dyson, thank you so much for this incredible MTE, every update is just fantastic.

I am having a bit of a problem using constrainCamera() and sprite offset.

the constrainCamera() does not seem to compensate for any offset in the sprite (in my case a y offset of 16), and appears to frame with that offset applied to the constraints rather than to the bounds I want.

I am using letterbox in my config, which may play a part in this, as I know MTE examples use zoomEven.

thanks again :slight_smile:

Thanks for bringing this to my attention, DeadPixel!

I’ll look into the problem today. Letterbox has indeed been a bane of my existence, but MTE gets better and better at supporting it with each update. 

I think I found the source of the problem. Try changing lines 10379 and 10380 of mte.lua from 

local endX = object.levelPosX + object.levelWidth \* scaleFactorX \* 0.5 + object.offsetX \* scaleFactorX local endY = object.levelPosY + object.levelHeight \* scaleFactorY \* 0.5 + object.offsetY \* scaleFactorY  

to

local endX = object.levelPosX + object.levelWidth \* scaleFactorX \* 0.5 local endY = object.levelPosY + object.levelHeight \* scaleFactorY \* 0.5  

And lines 10418 and 10419 from

local finalX = startX - object.levelWidth \* scaleFactorX \* 0.5 - object.offsetX \* scaleFactorX local finalY = startY - object.levelHeight \* scaleFactorY \* 0.5 - object.offsetY \* scaleFactorY  

to

local finalX = startX - object.levelWidth \* scaleFactorX \* 0.5 local finalY = startY - object.levelHeight \* scaleFactorY \* 0.5  

Yes, with a quick test, that appears to have solved the problem.

Thank you for looking into that today, very much appreciated!

Thanks for bringing this to my attention, DeadPixel!

I’ll look into the problem today. Letterbox has indeed been a bane of my existence, but MTE gets better and better at supporting it with each update. 

I think I found the source of the problem. Try changing lines 10379 and 10380 of mte.lua from 

local endX = object.levelPosX + object.levelWidth \* scaleFactorX \* 0.5 + object.offsetX \* scaleFactorX local endY = object.levelPosY + object.levelHeight \* scaleFactorY \* 0.5 + object.offsetY \* scaleFactorY  

to

local endX = object.levelPosX + object.levelWidth \* scaleFactorX \* 0.5 local endY = object.levelPosY + object.levelHeight \* scaleFactorY \* 0.5  

And lines 10418 and 10419 from

local finalX = startX - object.levelWidth \* scaleFactorX \* 0.5 - object.offsetX \* scaleFactorX local finalY = startY - object.levelHeight \* scaleFactorY \* 0.5 - object.offsetY \* scaleFactorY  

to

local finalX = startX - object.levelWidth \* scaleFactorX \* 0.5 local finalY = startY - object.levelHeight \* scaleFactorY \* 0.5  

Yes, with a quick test, that appears to have solved the problem.

Thank you for looking into that today, very much appreciated!