Project1
标题:
问下怎么实现给存档加个的上下的按钮(扩展存档)
[打印本页]
作者:
蓝翎
时间:
2009-3-10 06:34
标题:
问下怎么实现给存档加个的上下的按钮(扩展存档)
问下怎么实现给存档加个的上下的按钮(扩展存档)
我看这个不错 但是总是出错 没办法………………………………只能到这来问了
#==============================================================================
# ■ Scene_File
#------------------------------------------------------------------------------
# 存档画面及读档画面的超级类。
# 支持鼠标滚动条
# 脚本优化: SailCat 水蓝
#==============================================================================
class Scene_File
#--------------------------------------------------------------------------
# ● 常量
#--------------------------------------------------------------------------
MaxPages = 25
DisTance = 400 / MaxPages
INI_X = 610
INI_Y = 50
#--------------------------------------------------------------------------
# ● 初始化对像
# help_text : 帮助窗口显示的字符串
#--------------------------------------------------------------------------
def initialize(help_text)
@help_text = help_text
@slots = MaxPages * 4
end
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
# This is setting up the background picture
@background = Sprite.new
@background.bitmap = RPG::Cache.picture("save")
@background.x = 0
@background.y = 0
@file_index = $game_temp.last_file_index
#设置滚动条
@gdt = Sprite.new
@gdt.bitmap = RPG::Cache.icon("002-Weapon02")
@gdt.x = INI_X
@gdt.y = @file_index / 4 * DisTance + INI_Y
# ヘルプウィンドウを作成
@help_window = Window_Help.new
@help_window.opacity = 0
@help_window.set_text(@help_text)
# セーブファイルウィンドウを作成
# 生成帮助窗口
# @help_window = Window_Help.new
# @help_window.set_text(@help_text)
# 生成存档文件窗口
@savefile_windows = []
# 选择最后操作的文件
for i in @file_index / 4 * 4..@file_index / 4 * 4 + 3
load_window(i)
@savefile_windows[i].visible = true
end
@savefile_windows[@file_index].selected = true
# 执行过渡
Graphics.transition
# 主循环
loop do
# 刷新游戏画面
Graphics.update
# 刷新输入信息
Input.update
# 刷新画面
update
# 如果画面被切换的话就中断循环
if $scene != self
break
end
end
# 准备过渡
Graphics.freeze
# 释放窗口
@help_window.dispose
for i in 0...@slots
@savefile_windows[i].dispose if @savefile_windows[i] != nil
end
@background.dispose
@gdt.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
@help_window.update
for i in @file_index / 4 * 4..@file_index / 4 * 4 + 3
@savefile_windows[i].update if @savefile_windows[i].visible
end
mouse_x, mouse_y = Mouse.get_mouse_pos
Mouse.click_lock
for i in @file_index / 4 * 4..@file_index / 4 * 4 + 3
file = @savefile_windows[i]
top_x = file.x + 16
top_y = file.y + 16
bottom_x = top_x + file.width - 100
bottom_y = top_y + file.height
bottom_x_g = top_x + file.width
if (mouse_x > top_x) and (mouse_y > top_y) and
(mouse_x < bottom_x) and (mouse_y < bottom_y) then
file.selected = true
else
file.selected = false
end
end
Mouse.click_unlock
for i in @file_index / 4 * 4..@file_index / 4 * 4 + 3
file = @savefile_windows[i]
top_x = file.x + 16
top_y = file.y + 16
bottom_x = top_x + file.width - 100
bottom_y = top_y + file.height
bottom_x_g = top_x + file.width
if Input.trigger?(Input::C) then
#后翻一页
if (mouse_x > 580) and (mouse_y > 430) and
(mouse_x < 640) and (mouse_y < 480) then
# p @file_index
$game_system.se_play($data_system.cursor_se)
@savefile_windows[@file_index].selected = false
@file_index = (@file_index + 4) % @slots
for index in @file_index / 4 * 4..@file_index / 4 * 4 + 3
@savefile_windows[(index - 4) % @slots].visible = false
load_window(index)
@savefile_windows[index].visible = true
end
if @file_index>= 0 and @file_index <= 3 then
@gdt.y = INI_Y
else
@gdt.y += DisTance
end
return
end
#前翻一页
if (mouse_x > 580) and (mouse_y > 50) and
(mouse_x < 640) and (mouse_y < 100) then
$game_system.se_play($data_system.cursor_se)
@savefile_windows[@file_index].selected = false
@file_index = (@file_index + @slots - 4) % @slots
for index in @file_index / 4 * 4..@file_index / 4 * 4 + 3
@savefile_windows[(index + 4) % @slots].visible = false
load_window(index)
@savefile_windows[index].visible = true
end
if @file_index>= 96 and @file_index <= 99 then
@gdt.y = 450
else
@gdt.y -= DisTance
end
return
end
if (mouse_x > top_x) and (mouse_y > top_y) and
(mouse_x < bottom_x) and (mouse_y < bottom_y) then
on_decision(make_filename(i))
$game_temp.last_file_index = i
return
end
end
end
@help_window.update
for i in @file_index / 4 * 4..@file_index / 4 * 4 + 3
@savefile_windows[i].update if @savefile_windows[i].visible
end
=begin
# 按下 C 键的情况下
if (mouse_x > top_x) and (mouse_y > top_y) and
(mouse_x < bottom_x) and (mouse_y < bottom_y) and Input.trigger?(Input::C) then
# 调用过程 on_decision (定义继承目标)
on_decision(make_filename(@file_index))
$game_temp.last_file_index = @file_index
return
end
=end
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 调用过程 on_cancel (定义继承目标)
on_cancel
return
end
# 按下方向键下的情况下
if Input.repeat?(Input::DOWN)
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
# 光标向下移动
@savefile_windows[@file_index].selected = false
@file_index = (@file_index + 1) % @slots
# 翻到下一页的情况下
if @file_index % 4 == 0
for index in @file_index / 4 * 4..@file_index / 4 * 4 + 3
@savefile_windows[(index + @slots - 4) % @slots].visible = false
load_window(index)
@savefile_windows[index].visible = true
end
end
@savefile_windows[@file_index].selected = true
return
end
# 按下方向键上的情况下
if Input.repeat?(Input::UP)
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
# 光标向上移动
@savefile_windows[@file_index].selected = false
@file_index = (@file_index + @slots - 1) % @slots
# 翻到上一页的情况下
if @file_index % 4 == 3
for index in @file_index / 4 * 4..@file_index / 4 * 4 + 3
@savefile_windows[(index + 4) % @slots].visible = false
load_window(index)
@savefile_windows[index].visible = true
end
end
@savefile_windows[@file_index].selected = true
return
end
# 按下方向键左或者 L 的情况下
if Input.repeat?(Input::LEFT) or Input.trigger?(Input::L)
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
# 前翻一页
@savefile_windows[@file_index].selected = false
@file_index = (@file_index + @slots - 4) % @slots
for index in @file_index / 4 * 4..@file_index / 4 * 4 + 3
@savefile_windows[(index + 4) % @slots].visible = false
load_window(index)
@savefile_windows[index].visible = true
end
@savefile_windows[@file_index].selected = true
return
end
# 按下方向键右或者 R 的情况下
if Input.repeat?(Input::RIGHT) or Input.trigger?(Input::R)
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
# 前翻一页
@savefile_windows[@file_index].selected = false
@file_index = (@file_index + 4) % @slots
for index in @file_index / 4 * 4..@file_index / 4 * 4 + 3
@savefile_windows[(index - 4) % @slots].visible = false
load_window(index)
@savefile_windows[index].visible = true
end
@savefile_windows[@file_index].selected = true
return
end
end
#--------------------------------------------------------------------------
# ● 生成文件名
# file_index : 文件名的索引 (0~n)
#--------------------------------------------------------------------------
def make_filename(记录_index)
#return "Save#{file_index + 1}.rxdata"
return "Save#{记录_index + 1}.rxdata"
end
#--------------------------------------------------------------------------
# ● 载入当前页存档
# 避免因存档位过多造成的卡壳现象
#--------------------------------------------------------------------------
def load_window(i)
if @savefile_windows[i] != nil
return
else
@savefile_windows[i] = Window_SaveFile.new(i, make_filename(i))
@savefile_windows[i].opacity = 0
end
end
end
复制代码
[LINE]1,#dddddd[/LINE]
此贴于 2009-3-10 7:37:48 被版主darkten提醒,请楼主看到后对本贴做出回应。
[LINE]1,#dddddd[/LINE]
版务信息:版主帮忙结贴~
作者:
kakarot
时间:
2009-3-10 07:54
嗯..稍微看了下..LZ是要跟鼠标脚本一起用还是?
要是不和鼠标一起用的话试试这个吧..
http://rpg.blue/web/htm/news289.htm
p.s.关于LZ的脚本..LZ是不是忘了在Graphics\pictures\下放一个名为“save”的图片呢?
报错的话最好把报错内容也一起发上来吧.. [LINE]1,#dddddd[/LINE]
系统信息:本贴由本区版主认可为正确答案,66RPG感谢您的热情解答~
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1