Project1

标题: 为什么这段脚本放在def update不执行呢 [打印本页]

作者: 幻耶    时间: 2009-7-7 17:21
标题: 为什么这段脚本放在def update不执行呢
以下脚本添加在Scene_Map的def update下,用来判断当事件的坐标变量重合并且按S键就执行相应的公共事件,但是在游戏中并没有执行相应的公共事件。
但是把if Input.trigger?(Input::Y)这个条件判断去除就可以执行i号公共事件了,为什么 if Input.trigger?(Input::Y) 这个判断不能添加?

for i in 1..20
  if $game_variables[9] == $game_variables[i*2+199] and $game_variables[10] == $game_variables[i*2+200]
    if Input.trigger?(Input::Y)
      $game_variables[5] = i
      $game_temp.common_event_id = i
      break
    end
  end
end
作者: 猫哥哥    时间: 2009-7-7 17:36
本帖最后由 猫哥哥 于 2009-7-7 17:38 编辑

if Input.trigger?(Input::Y)
for i in 1..20
  if $game_variables[9] == $game_variables[i*2+199] and $game_variables[10] == $game_variables[i*2+200]
     $game_variables[5] = i
     $game_temp.common_event_id = i
     break
  end
end
end
----------------------------------------------------------
这样呢?

另外看看在这个update之前,有没有Input.update
作者: 幻耶    时间: 2009-7-7 17:43
if Input.trigger?(Input::Y)
for i in 1..20
  if $game_variables[9] == $game_variables and $game_variables[10] == $game_variables
     $game_variables[5] = i
     $game_temp.common_event_id = i
     b ...
猫哥哥 发表于 2009-7-7 17:36



也没执行啊。。奇怪了,去掉if Input.trigger?(Input::Y)就可以。之前没有Input.update
作者: 猫哥哥    时间: 2009-7-7 18:25
去掉那个就能执行,说明Input.trigger?(Input::Y)的返回值一直是false,并不奇怪。

你改成Input.press?试试看,你是用的默认脚本?
作者: 幻耶    时间: 2009-7-7 19:11
是默认脚本啊,Input.press?可以了!为什么Input.trigger?不行哦??我用了个全键盘按键调用脚本,这个有关系?
作者: 猫哥哥    时间: 2009-7-7 19:17
可以理解为trigger是检测按键的单击,press是检测按键是否处于被按下的状态。




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1