[脚本]像红警或lol一样用鼠标控制视野
Smalldy 发表于 2017-02-10 11:23:03 710

//------------------------根据鼠标位置移动视野---------------------
// 默认的视野是view0 靠近边界20%区域开始移动视野
// 脚本依附于对象, 需要创建一个不可见的摄像机对象放置在房间中
// 并将本脚本添加到步事件中
var cameraspeed;
cameraspeed = 10;       //摄像机移动速度
viewindex = 0;          //默认视野

if(keyboard_check(vk_left)){
    x-= cameraspeed;
}
if(keyboard_check(vk_right)){
    x+=cameraspeed;
}
if(keyboard_check(vk_up)){
    y-=cameraspeed;
}
if(keyboard_check(vk_down)){
    y+=cameraspeed;
}

if(mouse_x < view_wview[viewindex]*0.2 + view_xview[viewindex]){
     x-= cameraspeed;
}
if(mouse_x > view_wview[viewindex]*0.8 + view_xview[viewindex]){
     x+= cameraspeed;
}
if(mouse_y < view_hview[viewindex]*0.2 + view_yview[viewindex]){
     y-= cameraspeed;
}
if(mouse_y > view_hview[viewindex]*0.8 + view_yview[viewindex]){
     y+= cameraspeed;
}

if(x < view_xview[viewindex]){
    x = view_xview[viewindex];
}
if(y < view_yview[viewindex]){
    y = view_yview[viewindex];
}
if(x >= view_wview[viewindex]+view_xview[viewindex]){
    x = view_wview[viewindex]+view_xview[viewindex] -1;
}
if( y >= view_hview[viewindex]+view_yview[viewindex] ){
    y =  view_hview[viewindex]+view_yview[viewindex]-1;
}
发好多次都没发出去啊

最新回复 (2)
  • BloveStorm 发表于 2017-02-11 03:45:13
    0 2
    不错的脚本。