- 注册时间
- 2004-3-2
- 最后登录
- 2023-5-15
管理员
お嬢様
  
- 积分
- 22410
|
rpgxp的一段原码,包括台图片的对话框 健如下的类
#==============================================================================
# ■ Game_User
#------------------------------------------------------------------------------
# 自定义函数集
#==============================================================================
class Game_User
#图片窗口
def ShowBmpWnd(sfilename)
#if $Window_Bmp == nil then
bitmap = RPG::Cache.picture(sfilename)
cw = bitmap.width
ch = bitmap.height
src_rect = Rect.new(0, 0, cw, ch)
@Window_Bmp = Window_Bmp.new(cw,ch)
@Window_Bmp.back_opacity = 160
#end
@Window_Bmp.contents.blt(0,0, bitmap, src_rect)
#按C键关闭
Graphics.transition
ret = 1
loop do
Graphics.update
Input.update
ret = @Window_Bmp.Update
if ret == -1 then
@Window_Bmp.dispose
break
end
end
Graphics.freeze
$game_player.straighten
end
#对话窗口
def showmessage120(sname,smessage)
bitmap = RPG::Cache.picture(sname)
cw = 90
ch = 100
src_rect = Rect.new(0, 0, cw, ch)
#处理字符串,如果长度太长则分段显示
s1 = smessage[0,31]
s2 = smessage[31,31]
s3 = smessage[62,30]
s4 = smessage[92,31]
@Window_Chat = Window_Chat.new([s1,s2,s3,s4])
@Window_Chat.back_opacity = 160
@Window_Chat.contents.blt(10,10, bitmap, src_rect)
#按C键关闭
Graphics.transition
ret = 1
loop do
Graphics.update
Input.update
ret = @Window_Chat.Update
if ret == -1 then
@Window_Chat.dispose
break
end
end
Graphics.freeze
$game_player.straighten
end
end
#==============================================================================
# ■ Window_chat
#------------------------------------------------------------------------------
# 自定义对话窗口
#==============================================================================
class Window_Chat < Window_Base
def initialize(smessage)
super(30, 300, 580, 150)
self.contents = Bitmap.new(470, 140) #图片大小
self.contents.clear
rect = Rect.new(120 , 0 ,600, 32 )#30 + 80 , 500 + 20, 580 - 20, 100 - 20 )
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.cursor_rect.set(5,5 , 100 , 110)
self.contents.draw_text( rect, smessage[0])
unless smessage[1] == nil then
rect = Rect.new(120 , 30 ,600, 32 )
self.contents.draw_text( rect, smessage[1])
end
unless smessage[2] == nil then
rect = Rect.new(120 , 60 ,600, 32 )
self.contents.draw_text( rect, smessage[2])
end
unless smessage[3] == nil then
rect = Rect.new(120 , 90 ,600, 32 )
self.contents.draw_text( rect, smessage[3])
end
end
def Update
if Input.trigger?(Input::C)
$scene = Scene_Map.new
return -1
end
return 1
end
end
--------------------------------
#==============================================================================
# ■ Window_Bmp
#------------------------------------------------------------------------------
# 自定义窗口背景
#==============================================================================
class Window_Bmp < Window_Base
def initialize(x,y)
super(0, 0, x + 32,y + 32 ) #窗口大小
self.contents = Bitmap.new(x, y) #图片大小
self.x = (640 - x - 32) / 2 #居中
self.y = (480 - y - 32 ) / 2 #居中
self.contents.clear
#self.contents.font.color = color
rect = Rect.new(x - 20, y - 32 , self.contents.width , 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
self.cursor_rect.set(x - 20, y - 32 , 16, 32)
self.contents.draw_text(rect, ">")
end
def Update
if Input.trigger?(Input::C)
$scene = Scene_Map.new
return -1
end
return 1
end
end ======================================用法如下===================== 用法如下:
1 在Scene_Title 下 加入 :
def command_new_game
# 決定 SE を演奏
$game_system.se_play($data_system.decision_se)
# BGM を停止
Audio.bgm_stop
# プレイ時間計測用のフレームカウントをリセット
Graphics.frame_count = 0
# 各種ゲームオブジェクトを作成
$game_temp = Game_Temp.new
$game_system = Game_System.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_screen = Game_Screen.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new # 新加入的
$game_user = Game_User.new # 新加入的
2 建立新的地图
3 建立新的事件
4 事件新加脚本
如下 game_user.ShowBmpWnd(" ictures路径下的图片文件名")
$game_user.showmessage120(" ictures路径下的头像图片文件名","对话信息")
5 还有bug,就是事件加入脚本后,必须在加入一行普通的文本行,否则死循环 -_-b,
例如:文章:asd
放心 asd 不会显示 转帖EZ模拟开发区原帖子地址http://bbs.emu-zone.org/showthread.php?t=205434作者: gao0022 |
|