Meester Dennis
Member
Dear people,
I'm looking for an tutorial, extension or some help with panning in an mobile game. I'm trying to create an way to swipe with my finger true the room. So te player can swipe and see everything.
I already tried something.
My resolution script is: (I'm in the team off Pelistar now AppSurd)
My panning script is:
I can pann horizontal with this script, but part of my screen is always black. I draw an background with the draw functions, but the game doesn't show half of it. The black border.
Screenshot:
Roomsize = 3840 bij 1810
Could someone help me? How to pann on my mobile without black borders.
I'm looking for an tutorial, extension or some help with panning in an mobile game. I'm trying to create an way to swipe with my finger true the room. So te player can swipe and see everything.
I already tried something.
My resolution script is: (I'm in the team off Pelistar now AppSurd)
/// @description scr_set_resolution(game_width, game_height, [room1, room2,...])
/// @param game_width
/// @param game_height
/// @param [room1
/// @param room2
/// @param ...]
//
// Script: Set the game resolution for all displays
// Date: 2018-01-08
// Copyright: PeliStar
//
// Arguments:
// argument[0]: actual width of the game
// argument[1]: actual height of the game
// argument[2..15]: rooms to change
// Init variables
var w = display_get_width();
var h = display_get_height();
var r = h/w;
var game_width = argument[0];
var game_height = argument[1];
// Testing on Windows
if (os_type == os_windows)
{
w = 1280 ; //1280 1280 1920
h = 720 ; //591 720 1080
r = h/w;
window_set_size(w, h);
}
// Set Resolution
if (game_width < game_height)
{
// Portrait
if (r > 1.7777)
{
// iPhone X
show_debug_message("Portrait: iPhone X Resolution");
var phone_height = game_width*r;
var diff = (phone_height - game_height) / 2;
display_set_gui_size(game_width, phone_height);
// Rooms
var cam = camera_create_view(0, -diff, game_width, phone_height);
for(var i = 2; i < argument_count; i++)
{
room_set_camera(argument, 0, cam);
room_set_viewport(argument, 0, 1, 0, 0, game_width, game_height)
}
}
else
{
// Others
show_debug_message("Portrait: Other Resolution");
var phone_width = game_height/r;
var diff = (phone_width - game_width) / 2;
display_set_gui_size(phone_width, game_height);
// Rooms
var cam = camera_create_view(-diff, 0, phone_width, game_height);
for(var i = 2; i < argument_count; i++)
{
room_set_camera(argument, 0, cam);
room_set_viewport(argument, 0, 1, 0, 0, game_width, game_height)
}
}
}
else
{
// Landscape
if (r < 0.5625)
{
// iPhone X
show_debug_message("Landscape: iPhone X Resolution");
var phone_width = game_height/r;
var diff = (phone_width - game_width) / 2;
display_set_gui_size(phone_width, game_height);
// Rooms
var cam = camera_create_view(-diff, 0, phone_width, game_height);
for(var i = 2; i < argument_count; i++)
{
room_set_camera(argument, 0, cam);
room_set_viewport(argument, 0, 1, 0, 0, game_width, game_height)
}
}
else
{
// Others
show_debug_message("Landscape: Other Resolution");
var phone_height = game_width*r;
var diff = (phone_height - game_height) / 2;
display_set_gui_size(game_width, phone_height);
// Rooms
var cam = camera_create_view(0, -diff, game_width, phone_height);
for(var i = 2; i < argument_count; i++)
{
room_set_camera(argument, 0, cam);
room_set_viewport(argument, 0, 1, 0, 0, game_width, game_height)
}
}
}
// Debug
show_debug_message("game_width="+string(game_width));
show_debug_message("game_height="+string(game_height));
/// @param game_width
/// @param game_height
/// @param [room1
/// @param room2
/// @param ...]
//
// Script: Set the game resolution for all displays
// Date: 2018-01-08
// Copyright: PeliStar
//
// Arguments:
// argument[0]: actual width of the game
// argument[1]: actual height of the game
// argument[2..15]: rooms to change
// Init variables
var w = display_get_width();
var h = display_get_height();
var r = h/w;
var game_width = argument[0];
var game_height = argument[1];
// Testing on Windows
if (os_type == os_windows)
{
w = 1280 ; //1280 1280 1920
h = 720 ; //591 720 1080
r = h/w;
window_set_size(w, h);
}
// Set Resolution
if (game_width < game_height)
{
// Portrait
if (r > 1.7777)
{
// iPhone X
show_debug_message("Portrait: iPhone X Resolution");
var phone_height = game_width*r;
var diff = (phone_height - game_height) / 2;
display_set_gui_size(game_width, phone_height);
// Rooms
var cam = camera_create_view(0, -diff, game_width, phone_height);
for(var i = 2; i < argument_count; i++)
{
room_set_camera(argument, 0, cam);
room_set_viewport(argument, 0, 1, 0, 0, game_width, game_height)
}
}
else
{
// Others
show_debug_message("Portrait: Other Resolution");
var phone_width = game_height/r;
var diff = (phone_width - game_width) / 2;
display_set_gui_size(phone_width, game_height);
// Rooms
var cam = camera_create_view(-diff, 0, phone_width, game_height);
for(var i = 2; i < argument_count; i++)
{
room_set_camera(argument, 0, cam);
room_set_viewport(argument, 0, 1, 0, 0, game_width, game_height)
}
}
}
else
{
// Landscape
if (r < 0.5625)
{
// iPhone X
show_debug_message("Landscape: iPhone X Resolution");
var phone_width = game_height/r;
var diff = (phone_width - game_width) / 2;
display_set_gui_size(phone_width, game_height);
// Rooms
var cam = camera_create_view(-diff, 0, phone_width, game_height);
for(var i = 2; i < argument_count; i++)
{
room_set_camera(argument, 0, cam);
room_set_viewport(argument, 0, 1, 0, 0, game_width, game_height)
}
}
else
{
// Others
show_debug_message("Landscape: Other Resolution");
var phone_height = game_width*r;
var diff = (phone_height - game_height) / 2;
display_set_gui_size(game_width, phone_height);
// Rooms
var cam = camera_create_view(0, -diff, game_width, phone_height);
for(var i = 2; i < argument_count; i++)
{
room_set_camera(argument, 0, cam);
room_set_viewport(argument, 0, 1, 0, 0, game_width, game_height)
}
}
}
// Debug
show_debug_message("game_width="+string(game_width));
show_debug_message("game_height="+string(game_height));
My panning script is:
diff = point_distance(drag_start_x, drag_start_y, mouse_x, mouse_y);
if mouse_check_button_pressed(mb_left)
{
//Start position for dragging
drag_x = mouse_x;
drag_speed = 0;
drag_start_x = mouse_x;
drag_start_y = mouse_y;
}
if mouse_check_button(mb_left)
{
//Drag
if can_scroll = 1
{
drag_speed = (drag_x - mouse_x) / 50;
var aa;
aa = view_xport[0]-drag_speed
//show_debug_message("Aa:"+string(aa));
if aa <=0 && aa >= -1920
{
view_set_xport(0,aa);
}
}
}
if abs(drag_speed) > 0
{
//Drag slow down effect
view_xview += drag_speed;
if view_xview <= 0 || view_xview >= (room_width-view_wport[0]) then drag_speed = 0;
drag_speed += (-drag_speed/24);
}
if mouse_check_button_pressed(mb_left)
{
//Start position for dragging
drag_x = mouse_x;
drag_speed = 0;
drag_start_x = mouse_x;
drag_start_y = mouse_y;
}
if mouse_check_button(mb_left)
{
//Drag
if can_scroll = 1
{
drag_speed = (drag_x - mouse_x) / 50;
var aa;
aa = view_xport[0]-drag_speed
//show_debug_message("Aa:"+string(aa));
if aa <=0 && aa >= -1920
{
view_set_xport(0,aa);
}
}
}
if abs(drag_speed) > 0
{
//Drag slow down effect
view_xview += drag_speed;
if view_xview <= 0 || view_xview >= (room_width-view_wport[0]) then drag_speed = 0;
drag_speed += (-drag_speed/24);
}
I can pann horizontal with this script, but part of my screen is always black. I draw an background with the draw functions, but the game doesn't show half of it. The black border.
Screenshot:
Roomsize = 3840 bij 1810
Could someone help me? How to pann on my mobile without black borders.