设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2183|回复: 3
打印 上一主题 下一主题

[已经解决] 如何让这个脚本停下来?

[复制链接]

Lv3.寻梦者

梦石
0
星屑
2281
在线时间
403 小时
注册时间
2018-11-9
帖子
249
跳转到指定楼层
1
发表于 2019-1-17 19:16:04 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
就是这个脚本:
  1. class Scene_Map < Scene_Base
  2.   FindWindowEx = Win32API.new('user32', 'FindWindowEx', 'llpp', 'i')
  3.   HWnd = FindWindowEx.call(0, 0, 'RGSS Player', 0)
  4.   SetWindowPos = Win32API.new('user32', 'SetWindowPos', 'liiiiip', 'i')
  5.   GetWindowRect = Win32API.new('user32','GetWindowRect',['l','p'],'i')
  6.   #--------------------------------------------------------------------------
  7.   # ● 更新画面
  8.   #--------------------------------------------------------------------------
  9.   alias _update update
  10.   def update
  11.     _update
  12.     if $game_switches[1]
  13.       update_shake
  14.     end
  15.   end
  16.   def update_shake
  17.     window_rect = "\0" * 16
  18.     GetWindowRect.call(HWnd, window_rect)
  19.     x,y,wr,wb = window_rect.unpack('llll')
  20.     w = wr - x
  21.     h = wb - y
  22.     time = 0
  23.     while time < 34
  24.       Graphics.update
  25.       time += 1
  26.       case time
  27.       when 0 then SetWindowPos.call(HWnd, 0, x - 50, y - 50, w, h, 0)
  28.       when 2 then SetWindowPos.call(HWnd, 0, x, y, w, h, 0)
  29.       when 4 then SetWindowPos.call(HWnd, 0, x , y - 50, w, h, 0)
  30.       when 6 then SetWindowPos.call(HWnd, 0, x, y, w, h, 0)
  31.       when 8 then SetWindowPos.call(HWnd, 0, x + 50, y - 50 , w, h, 0)
  32.       when 10 then SetWindowPos.call(HWnd, 0, x, y, w, h, 0)
  33.       when 12 then SetWindowPos.call(HWnd, 0, x + 50, y, w, h, 0)
  34.       when 14 then SetWindowPos.call(HWnd, 0, x, y, w, h, 0)
  35.       when 16 then SetWindowPos.call(HWnd, 0, x + 50, y + 50, w, h, 0)
  36.       when 20 then SetWindowPos.call(HWnd, 0, x, y, w, h, 0)
  37.       when 22 then SetWindowPos.call(HWnd, 0, x, y + 50, w, h, 0)
  38.       when 24 then SetWindowPos.call(HWnd, 0, x, y, w, h, 0)
  39.       when 26 then SetWindowPos.call(HWnd, 0, x - 50, y + 50, w, h, 0)
  40.       when 28 then SetWindowPos.call(HWnd, 0, x, y, w, h, 0)
  41.       when 30 then SetWindowPos.call(HWnd, 0, x - 50, y, w, h, 0)
  42.       when 32 then SetWindowPos.call(HWnd, 0, x, y, w, h, 0)
  43.       end
  44.     end
  45.   end
  46. end
复制代码

目的:当开关1打开时,让整个游戏窗口“摇滚”起来。
现在,我设置了这样一个事件:打开开关1,然后等待5秒,再关闭开关1(也就是关闭“摇滚模式”)。
但不知为什么,打开开关1后,整个屏幕停不下来,所以过来求教各位大佬0.0
莫把湖面倒影,当作夜空繁星。所以大角鼠yesyes,kaka的力量无人能及!

Lv4.逐梦者

梦石
0
星屑
9617
在线时间
566 小时
注册时间
2017-9-28
帖子
208
2
发表于 2019-1-17 20:25:24 | 只看该作者
RUBY 代码复制
  1. class Scene_Map < Scene_Base
  2.   FindWindowEx = Win32API.new('user32', 'FindWindowEx', 'llpp', 'i')
  3.   HWnd = FindWindowEx.call(0, 0, 'RGSS Player', 0)
  4.   SetWindowPos = Win32API.new('user32', 'SetWindowPos', 'liiiiip', 'i')
  5.   GetWindowRect = Win32API.new('user32','GetWindowRect',['l','p'],'i')
  6.   #--------------------------------------------------------------------------
  7.   # ● 更新画面
  8.   #--------------------------------------------------------------------------
  9.   alias _update update
  10.   def update
  11.     _update
  12.     if $game_switches[1]
  13.       if @_shake_timer.nil?
  14.         @_shake_timer = 0
  15.         @_window_rect = "\0" * 16
  16.         GetWindowRect.call(HWnd, @_window_rect)
  17.       end
  18.       update_shake
  19.     else
  20.       if @_window_rect
  21.         x, y, wr, wb = @_window_rect.unpack('L4')
  22.         w, h = wr - x, wb - y
  23.         SetWindowPos.call(HWnd, 0, x, y, w, h, 0)
  24.         @_window_rect = nil
  25.       end
  26.       @_shake_timer = nil
  27.     end
  28.   end
  29.   def update_shake
  30.     x, y, wr, wb = @_window_rect.unpack('L4')
  31.     w, h = wr - x, wb - y
  32.     case @_shake_timer = (@_shake_timer + 1) % 34
  33.     when 0  then SetWindowPos.call(HWnd, 0, x - 50, y - 50, w, h, 0)
  34.     when 2  then SetWindowPos.call(HWnd, 0, x, y, w, h, 0)
  35.     when 4  then SetWindowPos.call(HWnd, 0, x , y - 50, w, h, 0)
  36.     when 6  then SetWindowPos.call(HWnd, 0, x, y, w, h, 0)
  37.     when 8  then SetWindowPos.call(HWnd, 0, x + 50, y - 50 , w, h, 0)
  38.     when 10 then SetWindowPos.call(HWnd, 0, x, y, w, h, 0)
  39.     when 12 then SetWindowPos.call(HWnd, 0, x + 50, y, w, h, 0)
  40.     when 14 then SetWindowPos.call(HWnd, 0, x, y, w, h, 0)
  41.     when 16 then SetWindowPos.call(HWnd, 0, x + 50, y + 50, w, h, 0)
  42.     when 20 then SetWindowPos.call(HWnd, 0, x, y, w, h, 0)
  43.     when 22 then SetWindowPos.call(HWnd, 0, x, y + 50, w, h, 0)
  44.     when 24 then SetWindowPos.call(HWnd, 0, x, y, w, h, 0)
  45.     when 26 then SetWindowPos.call(HWnd, 0, x - 50, y + 50, w, h, 0)
  46.     when 28 then SetWindowPos.call(HWnd, 0, x, y, w, h, 0)
  47.     when 30 then SetWindowPos.call(HWnd, 0, x - 50, y, w, h, 0)
  48.     when 32 then SetWindowPos.call(HWnd, 0, x, y, w, h, 0)
  49.     end
  50.   end
  51. end

点评

谢谢0.0  发表于 2019-1-17 21:30

评分

参与人数 1星屑 +30 收起 理由
VIPArcher + 30 认可答案

查看全部评分

喵喵喵
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
19279
在线时间
3074 小时
注册时间
2013-1-11
帖子
1288
3
发表于 2019-1-17 20:25:50 | 只看该作者
好像每帧要循环34次?打开开关一,等待5秒(300帧),关闭开关一。
地图每帧的刷新里面有34次Graphics.update帧刷新,也就是实际要等待300*34帧,大概170秒才会结束吧。
解决方法就是不要用循环,直接在更新写SetWindowPos,不要写循环。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-19 14:35

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表