游戏玩家缩放和拖拽

时间:2016-06-02 08:50:57

标签: object view game-maker gml

我目前正在使用游戏制作者来创建平面布局系统。我能够放大房间,拖动和缩小但我怎么能限制我可以放大和缩小多少?房间的大小是1024 x 768 px。我希望能够缩小到你第一次进入房间时的样子。

这是我目前放在脚本中的代码:

 Data1:
 #Year           RA(mas)    DEC(mas)
 1993-06-26     0.36315     0.23913 
 1993-12-16     0.33392     0.28443
 1994-01-28     0.34606     0.30810
 1994-12-23     0.37139     0.32989
 1995-02-12     0.34050     0.29165
 1995-08-17     0.55405     0.42913
 1995-12-18     0.36928     0.2777
 1996-04-07     0.49601     0.31533 
 1996-12-13     0.43557     0.34637
 1997-11-14     0.36811     0.25562
 1998-06-02     0.55603     0.36268
 1998-12-07     0.52873     0.23110
 2000-11-12     0.45839     0.22572
 ieData2: 
#Year           RA(mas)     DEC(mas)
1993-06-26      0.63633     0.44645     
1993-09-18      0.63548     0.35586
1993-12-16      0.63161     0.41704
1994-01-28      0.27266     0.47256
1994-03-14      0.75819     0.65255
1994-04-21      0.69664     0.68481
1994-06-21      0.78735     0.72865
1994-08-29      0.91143     0.78274
1994-10-30      0.55326     0.43258
1994-12-23      0.67065     0.54423
1995-02-12      0.55778     0.51656
1995-08-17      1.01458     0.50502

2 个答案:

答案 0 :(得分:0)

使用clamp function来做到这一点非常简单。代码的修改版本如下所示:

view_wview = clamp(view_wview * 0.15, min_size, 1024)
view_hview = clamp(view_hview * 0.15, min_size, 768)

答案 1 :(得分:0)

只需使用clamp函数来限制view_wview和view_hview

var maxZoomIn = 0.2; //500% zoom in limit
var maxZoomOut = 1; //100% zoom out limit
if mouse_wheel_up(){
    center_of_space_x=view_xview+view_wview/2;
    center_of_space_y=view_yview+view_hview/2;
    view_wview = clamp(view_wview - view_wview * 0.15, maxZoomIn*room_width, maxZoomOut*room_width)
    view_hview = clamp(view_hview - view_hview * 0.15, maxZoomIn*room_height, maxZoomOut*room_height)
    view_xview=center_of_space_x-view_wview/2;
    view_yview=center_of_space_y-view_hview/2;
}

和mouse_wheel_down类似。