Hi guys, i have a quick question. So i have go object with sprite. Sprite is bigger than my viewport (it is mobile game), that’s why i need to pan sprite around. I calculated border positions and just move sprite via go.set_position until it hits border position and it won’t move in that direction. Viewport is kinda trapped inside sprite. It works fine, but when i change viewport size during the game, calculated border positions are no longer valid → viewport can “escape” sprite and i will see things behind sprite. I tried to find correlation in viewport size to adjust border positions but failed. I also tried to create a camera and move it instead of go object, but the result is similar.
Here is the sketch)
Right now it works like this:
-- Move Left if possible
if x < 0 and go.get_position(node).x < self.size.x/2 then
-- Move sprite
end
-- Move Right if possible
if x > 0 and go.get_position(node).x > -(self.size.x/2 - width) then
-- Move sprite
end
-- Move Up if possible
if y > 0 and go.get_position(node).y > -(self.size.y/2 - height) then
-- Move sprite
end
-- Move Down if possible
if y < 0 and go.get_position(node).y < self.size.y/2 then
-- Move sprite
end
self.size is size of sprite and width\height is width\height of screen.
Is there are any ways to overcome this problem, maybe change something in the render or even other approaches to move sprite inside boundaries.