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

Project1

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

问下怎么实现给存档加个的上下的按钮(扩展存档)

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
155
在线时间
227 小时
注册时间
2008-7-8
帖子
232
跳转到指定楼层
1
发表于 2009-3-10 06:34:21 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
问下怎么实现给存档加个的上下的按钮(扩展存档)
我看这个不错 但是总是出错 没办法………………………………只能到这来问了
  1. #==============================================================================
  2. # ■ Scene_File
  3. #------------------------------------------------------------------------------
  4. #  存档画面及读档画面的超级类。
  5. #   支持鼠标滚动条
  6. #   脚本优化: SailCat 水蓝
  7. #==============================================================================

  8. class Scene_File
  9. #--------------------------------------------------------------------------
  10. # ● 常量
  11. #--------------------------------------------------------------------------
  12.     MaxPages = 25
  13.    
  14.     DisTance = 400 / MaxPages
  15.    
  16.     INI_X = 610
  17.     INI_Y = 50
  18.    
  19. #--------------------------------------------------------------------------
  20. # ● 初始化对像
  21. #     help_text : 帮助窗口显示的字符串
  22. #--------------------------------------------------------------------------
  23. def initialize(help_text)
  24. @help_text = help_text
  25. @slots = MaxPages * 4
  26. end
  27. #--------------------------------------------------------------------------
  28. # ● 主处理
  29. #--------------------------------------------------------------------------
  30. def main
  31. # This is setting up the background picture
  32. @background = Sprite.new
  33. @background.bitmap = RPG::Cache.picture("save")
  34. @background.x = 0
  35. @background.y = 0

  36. @file_index = $game_temp.last_file_index
  37. #设置滚动条
  38. @gdt = Sprite.new
  39. @gdt.bitmap = RPG::Cache.icon("002-Weapon02")
  40. @gdt.x = INI_X
  41. @gdt.y = @file_index / 4 * DisTance + INI_Y


  42. # ヘルプウィンドウを作成
  43. @help_window = Window_Help.new
  44. @help_window.opacity = 0
  45. @help_window.set_text(@help_text)
  46. # セーブファイルウィンドウを作成
  47. # 生成帮助窗口
  48. #   @help_window = Window_Help.new
  49. #   @help_window.set_text(@help_text)

  50. # 生成存档文件窗口
  51. @savefile_windows = []
  52. # 选择最后操作的文件
  53. for i in @file_index / 4 * 4..@file_index / 4 * 4 + 3
  54.    load_window(i)
  55.    @savefile_windows[i].visible = true
  56. end
  57. @savefile_windows[@file_index].selected = true
  58. # 执行过渡
  59. Graphics.transition
  60. # 主循环
  61. loop do
  62.    # 刷新游戏画面
  63.    Graphics.update
  64.    # 刷新输入信息
  65.    Input.update
  66.    # 刷新画面
  67.    update
  68.    # 如果画面被切换的话就中断循环
  69.    if $scene != self
  70.      break
  71.    end
  72. end
  73. # 准备过渡
  74. Graphics.freeze
  75. # 释放窗口
  76. @help_window.dispose
  77. for i in 0...@slots
  78.   @savefile_windows[i].dispose if @savefile_windows[i] != nil
  79. end
  80. @background.dispose
  81. @gdt.dispose
  82. end
  83. #--------------------------------------------------------------------------
  84. # ● 刷新画面
  85. #--------------------------------------------------------------------------
  86. def update
  87.   
  88.     @help_window.update
  89.     for i in @file_index / 4 * 4..@file_index / 4 * 4 + 3
  90.       @savefile_windows[i].update if @savefile_windows[i].visible
  91.     end
  92.    
  93.     mouse_x, mouse_y = Mouse.get_mouse_pos
  94.     Mouse.click_lock
  95.    
  96.     for i in @file_index / 4 * 4..@file_index / 4 * 4 + 3
  97.       
  98.       file = @savefile_windows[i]
  99.       top_x = file.x + 16
  100.       top_y = file.y + 16
  101.       bottom_x = top_x + file.width - 100
  102.       bottom_y = top_y + file.height
  103.       bottom_x_g = top_x + file.width
  104.       
  105.       if (mouse_x > top_x) and (mouse_y > top_y) and
  106.          (mouse_x < bottom_x) and (mouse_y < bottom_y) then
  107.         file.selected = true
  108.       else
  109.        file.selected = false
  110.      end
  111.      
  112.      end
  113.       Mouse.click_unlock
  114.       
  115.       for i in @file_index / 4 * 4..@file_index / 4 * 4 + 3
  116.       
  117.       file = @savefile_windows[i]
  118.       top_x = file.x + 16
  119.       top_y = file.y + 16
  120.       bottom_x = top_x + file.width - 100
  121.       bottom_y = top_y + file.height
  122.       bottom_x_g = top_x + file.width
  123.       
  124.       if Input.trigger?(Input::C) then
  125.       #后翻一页
  126.       if (mouse_x > 580) and (mouse_y > 430) and
  127.          (mouse_x < 640) and (mouse_y < 480) then
  128.         # p @file_index
  129.        $game_system.se_play($data_system.cursor_se)
  130.        @savefile_windows[@file_index].selected = false
  131.        @file_index = (@file_index + 4) % @slots
  132.        for index in @file_index / 4 * 4..@file_index / 4 * 4 + 3
  133.          @savefile_windows[(index - 4) % @slots].visible = false
  134.          load_window(index)
  135.          @savefile_windows[index].visible = true
  136.        end
  137.        if @file_index>= 0 and @file_index <= 3 then
  138.          @gdt.y = INI_Y
  139.        else
  140.        @gdt.y += DisTance
  141.        end
  142.        return
  143.      end
  144.       #前翻一页
  145.       if (mouse_x > 580) and (mouse_y > 50) and
  146.          (mouse_x < 640) and (mouse_y < 100) then
  147.       
  148.        $game_system.se_play($data_system.cursor_se)
  149.        @savefile_windows[@file_index].selected = false
  150.        @file_index = (@file_index + @slots - 4) % @slots
  151.        for index in @file_index / 4 * 4..@file_index / 4 * 4 + 3
  152.          @savefile_windows[(index + 4) % @slots].visible = false
  153.          load_window(index)
  154.          @savefile_windows[index].visible = true
  155.        end
  156.        if @file_index>= 96 and @file_index <= 99 then
  157.          @gdt.y = 450
  158.        else
  159.        @gdt.y -= DisTance
  160.        end
  161.        return
  162.      end
  163.       
  164.        if (mouse_x > top_x) and (mouse_y > top_y) and
  165.     (mouse_x < bottom_x) and (mouse_y < bottom_y)  then
  166.       
  167.        on_decision(make_filename(i))
  168.        $game_temp.last_file_index = i
  169.    
  170.        return
  171.       end
  172.       
  173.     end
  174.     end
  175.      

  176.    @help_window.update
  177.    for i in @file_index / 4 * 4..@file_index / 4 * 4 + 3
  178.       @savefile_windows[i].update if @savefile_windows[i].visible
  179.    end
  180. =begin
  181.    
  182. # 按下 C 键的情况下
  183.    if (mouse_x > top_x) and (mouse_y > top_y) and
  184.     (mouse_x < bottom_x) and (mouse_y < bottom_y) and Input.trigger?(Input::C) then
  185.    # 调用过程 on_decision (定义继承目标)
  186.    on_decision(make_filename(@file_index))
  187.    $game_temp.last_file_index = @file_index
  188.    return
  189. end

  190. =end

  191. # 按下 B 键的情况下
  192. if Input.trigger?(Input::B)
  193.    # 调用过程 on_cancel (定义继承目标)
  194.    on_cancel
  195.    return
  196. end
  197. # 按下方向键下的情况下
  198. if Input.repeat?(Input::DOWN)
  199.    # 演奏光标 SE
  200.    $game_system.se_play($data_system.cursor_se)
  201.    # 光标向下移动
  202.    @savefile_windows[@file_index].selected = false
  203.    @file_index = (@file_index + 1) % @slots
  204.    # 翻到下一页的情况下
  205.    if @file_index % 4 == 0
  206.      for index in @file_index / 4 * 4..@file_index / 4 * 4 + 3
  207.        @savefile_windows[(index + @slots - 4) % @slots].visible = false
  208.        load_window(index)
  209.        @savefile_windows[index].visible = true
  210.      end
  211.    end
  212.    @savefile_windows[@file_index].selected = true
  213.    return
  214. end
  215. # 按下方向键上的情况下
  216. if Input.repeat?(Input::UP)
  217.    # 演奏光标 SE
  218.    $game_system.se_play($data_system.cursor_se)
  219.    # 光标向上移动
  220.    @savefile_windows[@file_index].selected = false
  221.    @file_index = (@file_index + @slots - 1) % @slots
  222.    # 翻到上一页的情况下
  223.    if @file_index % 4 == 3
  224.      for index in @file_index / 4 * 4..@file_index / 4 * 4 + 3
  225.        @savefile_windows[(index + 4) % @slots].visible = false
  226.        load_window(index)
  227.        @savefile_windows[index].visible = true
  228.      end
  229.    end
  230.    @savefile_windows[@file_index].selected = true
  231.    return
  232. end
  233. # 按下方向键左或者 L 的情况下
  234. if Input.repeat?(Input::LEFT) or Input.trigger?(Input::L)
  235.    # 演奏光标 SE
  236.    $game_system.se_play($data_system.cursor_se)
  237.    # 前翻一页
  238.    @savefile_windows[@file_index].selected = false
  239.    @file_index = (@file_index + @slots - 4) % @slots
  240.    for index in @file_index / 4 * 4..@file_index / 4 * 4 + 3
  241.      @savefile_windows[(index + 4) % @slots].visible = false
  242.      load_window(index)
  243.      @savefile_windows[index].visible = true
  244.    end
  245.    @savefile_windows[@file_index].selected = true
  246.    return
  247. end
  248. # 按下方向键右或者 R 的情况下
  249. if Input.repeat?(Input::RIGHT) or Input.trigger?(Input::R)
  250.    # 演奏光标 SE
  251.    $game_system.se_play($data_system.cursor_se)
  252.    # 前翻一页
  253.    @savefile_windows[@file_index].selected = false
  254.    @file_index = (@file_index + 4) % @slots
  255.    for index in @file_index / 4 * 4..@file_index / 4 * 4 + 3
  256.      @savefile_windows[(index - 4) % @slots].visible = false
  257.      load_window(index)
  258.      @savefile_windows[index].visible = true
  259.    end
  260.    @savefile_windows[@file_index].selected = true
  261.    return
  262. end
  263. end
  264. #--------------------------------------------------------------------------
  265. # ● 生成文件名
  266. #     file_index : 文件名的索引 (0~n)
  267. #--------------------------------------------------------------------------
  268. def make_filename(记录_index)
  269.     #return "Save#{file_index + 1}.rxdata"
  270.     return "Save#{记录_index + 1}.rxdata"
  271. end
  272. #--------------------------------------------------------------------------
  273. # ● 载入当前页存档
  274. #     避免因存档位过多造成的卡壳现象
  275. #--------------------------------------------------------------------------
  276. def load_window(i)
  277. if @savefile_windows[i] != nil
  278.    return
  279. else
  280.    @savefile_windows[i] = Window_SaveFile.new(i, make_filename(i))
  281.    @savefile_windows[i].opacity = 0
  282. end
  283. end
  284. end
复制代码

此贴于 2009-3-10 7:37:48 被版主darkten提醒,请楼主看到后对本贴做出回应。
版务信息:版主帮忙结贴~
A man chooses; a slave obeys.

Lv1.梦旅人

夜天の主

梦石
0
星屑
124
在线时间
1552 小时
注册时间
2008-4-13
帖子
2347

开拓者第4届短篇游戏比赛亚军

2
发表于 2009-3-10 07:54:50 | 只看该作者
嗯..稍微看了下..LZ是要跟鼠标脚本一起用还是?
要是不和鼠标一起用的话试试这个吧..
http://rpg.blue/web/htm/news289.htm

p.s.关于LZ的脚本..LZ是不是忘了在Graphics\pictures\下放一个名为“save”的图片呢?
报错的话最好把报错内容也一起发上来吧..
系统信息:本贴由本区版主认可为正确答案,66RPG感谢您的热情解答~
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-25 14:56

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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