I have been working on a project that required the user to drag the screen using the mouse or touch and it was rather difficult but I have since (with help from forum members) been able to do this and I thought I would create a tutorial for others. This is really for if you have a level bigger than the screen size.
Dragging the Screen - Mouse
First thing, make sure you have selected Mouse as an input object.
You then need 5 Global Variables for this to work. They are all numbers and can start with an initial value of 0, I have called them: Dragging, DragScrollX, DragScrollY, DragMouseX, DragMouseY.
Now, there are two parts to getting this to work and the first one involves setting the global values when the mouse is either being pressed or not.
Create an event for the mouse:
Choose On Click and select Left and Clicked.
Then, Add two actions:
Choose System then select Set Value for Global Values. Choose DragMouseX from the drop-down list and write the value as Mouse.AbsoluteX.
Repeat this a second time but this time set DragMouseY to the value Mouse.AbsoluteY.
You should have:
Next create a second event for the mouse:
Choose Mouse Button is Down and select Left but this time, right click the event and Invert it.
You also need two actions for this event:
Set The Global Variables DragScrollX and DragScrollY to the values scrollX and scrollY so you now have:
Basically, when the mouse is not being pressed, it stores the currently X and Y value of the position of the screen and once the mouse is pressed is stores the position on the mouse pointer on the screen at that exact moment.
This second part can be the confusing part but bare with me, I promise you it will work!!