赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 19835 |
最后登录 | 2017-9-29 |
在线时间 | 33 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 33 小时
- 注册时间
- 2011-9-17
- 帖子
- 24
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
这个脚本是呼出两个简单的窗口,左边是命令窗口,如果命令窗口的项目个数很多,超过了窗体高度,怎么让这些项目文字压缩在窗口之内?
class Window_mp_Command < Window_Selectable def initialize(width, commands) super(0, 0, width, 480) @item_max = 15 @commands = commands self.contents = Bitmap.new(width - 32, @item_max * 32) refresh self.index = 0 end def refresh self.contents.clear for i in 0...@item_max draw_item(i, normal_color) end end def draw_item(index, color) self.contents.font.color = color rect = Rect.new(4, 32 * index, self.contents.width - 8, 32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) self.contents.draw_text(rect, @commands[index].to_s) end def disable_item(index) draw_item(index, disabled_color) end def able_item(index) draw_item(index, normal_color) end end class Window_st < Window_Base def initialize(actor) super(0, 0, 460, 480) self.contents = Bitmap.new(width - 32, height - 32) @actor = actor end end class Scene_st def initialize(actor_index = 0 , menu_index = 0) @actor_index = actor_index @menu_index = menu_index end #-------------------------------------------------------------------------- # ● 主处理 #-------------------------------------------------------------------------- def main s1 = "项目1" s2 = "项目2" s3 = "项目3" s4 = "项目4" s5 = "项目5" s6 = "项目6" s7 = "项目7" s8 = "项目8" s9 = "项目9" s10 = "项目10" s11 = "项目11" s12 = "项目12" s13 = "项目13" s14 = "项目14" s15 = "项目15" @command_window = Window_mp_Command.new(180, [s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15]) @command_window.index = @menu_index @command_window.x = 0 @st_window = Window_st.new(@actor) @st_window.x = 180 @st_window.y = 0 Graphics.transition # 主循环 loop do# 刷新游戏画面 Graphics.update Input.update # 刷新输入信息 update# 刷新画面 if $scene != self # 如果切换画面就中断循环 break end end # 准备过渡 Graphics.freeze# 释放窗口 @command_window.dispose @st_window.dispose # 释放背景 end #-------------------------------------------------------------------------- # ● 刷新画面 #-------------------------------------------------------------------------- def update # 刷新窗口 @command_window.update if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) @command_window.index = 14 return end end end
class Window_mp_Command < Window_Selectable
def initialize(width, commands)
super(0, 0, width, 480)
@item_max = 15
@commands = commands
self.contents = Bitmap.new(width - 32, @item_max * 32)
refresh
self.index = 0
end
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i, normal_color)
end
end
def draw_item(index, color)
self.contents.font.color = color
rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect, @commands[index].to_s)
end
def disable_item(index)
draw_item(index, disabled_color)
end
def able_item(index)
draw_item(index, normal_color)
end
end
class Window_st < Window_Base
def initialize(actor)
super(0, 0, 460, 480)
self.contents = Bitmap.new(width - 32, height - 32)
@actor = actor
end
end
class Scene_st
def initialize(actor_index = 0 , menu_index = 0)
@actor_index = actor_index
@menu_index = menu_index
end
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
s1 = "项目1"
s2 = "项目2"
s3 = "项目3"
s4 = "项目4"
s5 = "项目5"
s6 = "项目6"
s7 = "项目7"
s8 = "项目8"
s9 = "项目9"
s10 = "项目10"
s11 = "项目11"
s12 = "项目12"
s13 = "项目13"
s14 = "项目14"
s15 = "项目15"
@command_window = Window_mp_Command.new(180, [s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15])
@command_window.index = @menu_index
@command_window.x = 0
@st_window = Window_st.new(@actor)
@st_window.x = 180
@st_window.y = 0
Graphics.transition
# 主循环
loop do# 刷新游戏画面
Graphics.update
Input.update # 刷新输入信息
update# 刷新画面
if $scene != self # 如果切换画面就中断循环
break
end
end
# 准备过渡
Graphics.freeze# 释放窗口
@command_window.dispose
@st_window.dispose
# 释放背景
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@command_window.update
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@command_window.index = 14
return
end
end
end
|
评分
-
查看全部评分
|