幻想森林

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 2575|回复: 5

rpgxp的一段原码,关于图片的对话框

[复制链接]

121

主题

3186

帖子

2万

积分

管理员

お嬢様

Rank: 9Rank: 9Rank: 9

积分
22410
发表于 2004-8-31 23:30:52 | 显示全部楼层 |阅读模式
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
回复

使用道具 举报

1

主题

20

帖子

508

积分

⑤进阶

积分
508
发表于 2004-9-10 20:58:47 | 显示全部楼层
效果呢,能贴张图不?
回复 支持 反对

使用道具 举报

carol3 该用户已被删除
发表于 2005-1-6 22:34:15 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

carol3 该用户已被删除
发表于 2005-1-6 22:34:39 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

1

主题

12

帖子

144

积分

③业余

积分
144
发表于 2006-5-22 17:56:28 | 显示全部楼层
先收下了
等下试试... [s:1]
回复 支持 反对

使用道具 举报

7

主题

41

帖子

483

积分

④见习

积分
483
QQ
发表于 2006-5-24 01:24:51 | 显示全部楼层
貌似很那看得懂
RM是条不归路,RM永远的小白..
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|幻想森林

GMT+8, 2025-6-27 17:53 , Processed in 0.011498 second(s), 22 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

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