Bug Report: Touch scroll with constrainCamera

Bug Report: Touch scroll with constrainCamera
 
Version: mte 0v980-6
 
Summary: Map becomes unresponsive at edges when touch scoll is enabled and constrainCamera is applied.
 
Background:
My game uses a top-down orthographic map like “CastleDemo” and “RotateConstrainStoryboard”. The world does not wrap and the hero is able to move to the very corners and edges of the world. I have set a single camera constraint that covers the entire map so that the camera never leaves the map when the hero is at the edges. The player is also able to touch scroll around the map (I also plan to implement zoom in / out now that the tile culling issue has been addressed for zoomed out views) so that the player can see the whole map independently of the hero sprite and decide where to move to next.
 
Problem:
The touch scroll works perfectly for the whole map until the player scrolls to the edges and the constraint comes in to force. At this point the touch becomes sticky and it’s often difficult to scroll away from the edge. If the player scrolls to the map corners then it’s almost impossible to scroll away and the map essentially freezes.
 
Reproduce:
In the “CastleDemo” project main.lua “UNCOMMENT TO TEST PINCH ZOOM / TOUCH SCROLL” (line 300 onwards) and add to line 56…
 

mte.constrainCamera({ loc = {1, 1, 100, 100} })

… then run the project and touch scroll to the edges/corners of the map.
 
Final thoughts

  • If world wrap is not enabled would it be possible/preferable for the default behaviour to be a camera constraint to the full dimensions of the map, such as this? I can’t think of a time when visibly dead tile space would be useful (see the CastleDemo touch scroll without constrainCamera and toggleWorldWrapX and toggleWorldWrapY (lines 8 and 9)…)
     
  • Would it be possible to add the touch scroll / pinch code to MTE itself so that it could be enabled and disabled easily as needed? It’s quite a big block of reused code to copy/paste/maintain across multiple projects when it could be housed internally. A couple of listeners could be set/called at key touch phases if customisation is required (such as enable/disable player’s hero’s movement). It could then be implemented with mte.enableMapTouch(), mte.disableMapTouch() and in the game loop the “isDragging” block could be dealt with during mte.update().

Thanks as always! :slight_smile:

I’ve just realised that the “stickiness” at the edges is directly related to the number of touches used while at the edges. So, if I’m at the very far left edge and drag to go left 3 times I obviously won’t move the camera as I’m actually as far as I can go… but I still need to swipe right the same number of times (or so) to be able to start moving away from the edge again, rather than just the once as you’d expect. If you see what I mean…

I’m sure I didn’t witness this issue with the previous version of MTE but I could be wrong.

It really would be a big help if this code was internal to MTE. :slight_smile:

I’m working on this now AppDeveloperGuy. Thanks for pointing out the bit about the swipes in the second post. That really narrows it down for me! Shouldn’t be too hard to fix.

EDIT: Well, that proved more involved than I thought it would, but I’m thinking I’ll have a fix out tomorrow. 

I’m not planning on adding anything new to MTE until the code is debugged, optimized, and out as 1.0. Including the touch scroll pinch zoom code is a good idea though! I’ll add it to the todo list for after the MTE release. 

That’s brilliant, many thanks dyson! MTE really is a fantastic product - as is your support! I look forward to seeing 1.0 in action!

Just to confirm that the updated v980-9 has fixed the problem. Thanks!
 

I’ve just realised that the “stickiness” at the edges is directly related to the number of touches used while at the edges. So, if I’m at the very far left edge and drag to go left 3 times I obviously won’t move the camera as I’m actually as far as I can go… but I still need to swipe right the same number of times (or so) to be able to start moving away from the edge again, rather than just the once as you’d expect. If you see what I mean…

I’m sure I didn’t witness this issue with the previous version of MTE but I could be wrong.

It really would be a big help if this code was internal to MTE. :slight_smile:

I’m working on this now AppDeveloperGuy. Thanks for pointing out the bit about the swipes in the second post. That really narrows it down for me! Shouldn’t be too hard to fix.

EDIT: Well, that proved more involved than I thought it would, but I’m thinking I’ll have a fix out tomorrow. 

I’m not planning on adding anything new to MTE until the code is debugged, optimized, and out as 1.0. Including the touch scroll pinch zoom code is a good idea though! I’ll add it to the todo list for after the MTE release. 

That’s brilliant, many thanks dyson! MTE really is a fantastic product - as is your support! I look forward to seeing 1.0 in action!

Just to confirm that the updated v980-9 has fixed the problem. Thanks!