4
4-KINGS
Guest
Currently I am creating a navigation menu that slides out from the left side of the phone and can be slid back to hide it. Furthermore the navigation panel will have lots of parts so once opened (all the way to the right) it can then be scrolled up and down. The issue is, when its fully open to the right, I can scroll both up and down and also back to the left to close it. However if I slide it diagonally then I want it to only move in 1 direction. E.g. If I slide diagonally to close panel, it will choose to only move horizontally and not vertically. At the moment if I slide diagonally it moves in both directions in a diagonally fashion and immediately after realises to move horizontal. By this point however it has already scrolled slightly up or down and looks a bit unprofessional. Sorry for the code its also a bit messy atm. Global released = 0 (fully closed to left and hidden from sight), Global released = 1 (Moves in x axis), Global.released = 2 (Moves in y axis), Global released = 3 (Fully open to the right and can move in either axis)
Code:
//Set menu release depending on whether menu is open/closed
if mouse_check_button(mb_left) && global.y_movement = 1 && global.val_x = 1
{
global.released = 2
}
if !mouse_check_button(mb_left) && global.val_x = 0
{
global.released = 0
}
if mouse_check_button(mb_left) && global.val_x >= 0 && global.val_x < 1
{
global.released = 1
}
if !mouse_check_button(mb_left) && global.val_x = 1
{
global.released = 3
}
//Drag
if global.released = 1 || global.released = 3
{
x = min(max(mouse_x+xx,minx),maxx)
}
if global.released = 2 || global.released = 3
{
y = min(max(mouse_y+yy,miny),maxy)
}