查看: 2705|回复: 3

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

[复制链接]
梦石
0
星屑
2281
在线时间
403 小时
注册时间
2018-11-9
回帖
224
发表于 2019-1-17 19:16:04 | 显示全部楼层 |阅读模式

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

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

×
就是这个脚本:
  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的力量无人能及!
梦石
0
星屑
9862
在线时间
580 小时
注册时间
2017-9-28
回帖
203
发表于 2019-1-17 20:25:24 | 显示全部楼层
[pre lang="ruby"]class Scene_Map < Scene_Base
  FindWindowEx = Win32API.new('user32', 'FindWindowEx', 'llpp', 'i')
  HWnd = FindWindowEx.call(0, 0, 'RGSS Player', 0)
  SetWindowPos = Win32API.new('user32', 'SetWindowPos', 'liiiiip', 'i')
  GetWindowRect = Win32API.new('user32','GetWindowRect',['l','p'],'i')
  #--------------------------------------------------------------------------
  # ● 更新画面
  #--------------------------------------------------------------------------
  alias _update update
  def update
    _update
    if $game_switches[1]
      if @_shake_timer.nil?
        @_shake_timer = 0
        @_window_rect = "\0" * 16
        GetWindowRect.call(HWnd, @_window_rect)
      end
      update_shake
    else
      if @_window_rect
        x, y, wr, wb = @_window_rect.unpack('L4')
        w, h = wr - x, wb - y
        SetWindowPos.call(HWnd, 0, x, y, w, h, 0)
        @_window_rect = nil
      end
      @_shake_timer = nil
    end
  end
  def update_shake
    x, y, wr, wb = @_window_rect.unpack('L4')
    w, h = wr - x, wb - y
    case @_shake_timer = (@_shake_timer + 1) % 34
    when 0  then SetWindowPos.call(HWnd, 0, x - 50, y - 50, w, h, 0)
    when 2  then SetWindowPos.call(HWnd, 0, x, y, w, h, 0)
    when 4  then SetWindowPos.call(HWnd, 0, x , y - 50, w, h, 0)
    when 6  then SetWindowPos.call(HWnd, 0, x, y, w, h, 0)
    when 8  then SetWindowPos.call(HWnd, 0, x + 50, y - 50 , w, h, 0)
    when 10 then SetWindowPos.call(HWnd, 0, x, y, w, h, 0)
    when 12 then SetWindowPos.call(HWnd, 0, x + 50, y, w, h, 0)
    when 14 then SetWindowPos.call(HWnd, 0, x, y, w, h, 0)
    when 16 then SetWindowPos.call(HWnd, 0, x + 50, y + 50, w, h, 0)
    when 20 then SetWindowPos.call(HWnd, 0, x, y, w, h, 0)
    when 22 then SetWindowPos.call(HWnd, 0, x, y + 50, w, h, 0)
    when 24 then SetWindowPos.call(HWnd, 0, x, y, w, h, 0)
    when 26 then SetWindowPos.call(HWnd, 0, x - 50, y + 50, w, h, 0)
    when 28 then SetWindowPos.call(HWnd, 0, x, y, w, h, 0)
    when 30 then SetWindowPos.call(HWnd, 0, x - 50, y, w, h, 0)
    when 32 then SetWindowPos.call(HWnd, 0, x, y, w, h, 0)
    end
  end
end[/pre]

点评

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

评分

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

查看全部评分

喵喵喵
回复

使用道具 举报

梦石
0
星屑
19426
在线时间
3082 小时
注册时间
2013-1-11
回帖
1207
发表于 2019-1-17 20:25:50 | 显示全部楼层
好像每帧要循环34次?打开开关一,等待5秒(300帧),关闭开关一。
地图每帧的刷新里面有34次Graphics.update帧刷新,也就是实际要等待300*34帧,大概170秒才会结束吧。
解决方法就是不要用循环,直接在更新写SetWindowPos,不要写循环。
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部