Project1
标题:
如何在主菜单显示地图名称?
[打印本页]
作者:
SINBIOS
时间:
2013-12-6 11:50
标题:
如何在主菜单显示地图名称?
如题,想打开主菜单后 在显示金钱的窗口里面增加显示地图名称和当前的系统时间。可以办到吗?
作者:
hcm
时间:
2013-12-6 13:37
把下面这套脚本放到Main上方即可,
这脚本除了显示当前的地图名外还会显示音乐和地图坐标,
不想要就把脚本中带“音乐”和“位置”的两行前加#注释掉即可。
#==============================================================================
# ■ Game_Player
#------------------------------------------------------------------------------
# 处理玩家人物的类。拥有事件启动的判定、地图的卷动等功能。
# 本类的实例请参考 $game_player 。
#==============================================================================
class Game_Player < Game_Character
def getX
@x
end
def getY
@y
end
end
#==============================================================================
# ■ Scene_Menu
#------------------------------------------------------------------------------
# 菜单画面
#==============================================================================
class Scene_Menu < Scene_MenuBase
#--------------------------------------------------------------------------
# ● 生成窗口
#--------------------------------------------------------------------------
def create_gold_window
@gold_window = Window_Gold.new
@gold_window.x = 0
@gold_window.y = Graphics.height - @gold_window.height
# 生成地图信息窗口
@mapinfos_window = Window_MapInfo.new
@mapinfos_window.x = 0
@mapinfos_window.y = Graphics.height - @mapinfos_window.height - @gold_window.height
end
end
#==============================================================================
# ■ Window_MapInfo
#------------------------------------------------------------------------------
# 显示当前信息的窗口。 By SkyZH
#==============================================================================
class Window_MapInfo < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(0, 0, window_width, fitting_height(3))
self.opacity = 100
refresh
end
#--------------------------------------------------------------------------
# ● 获取窗口的宽度
#--------------------------------------------------------------------------
def window_width
return 160
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = normal_color
@a=$game_map.width
@b=$game_map.height
@BGMNAME=RPG::BGM.last.name
draw_text(0, 0, window_width-24, line_height,$game_map.display_name,2)
draw_text(0, line_height, window_width-24, line_height,"音乐 " + @BGMNAME.to_s,2)
draw_text(0, line_height*2, window_width-24, line_height,"位置 " + $game_player.getX.to_s + "," + $game_player.getY.to_s,2)
end
end
class Spriteset_Map
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize
create_viewports
create_tilemap
create_parallax
create_characters
create_shadow
create_weather
create_pictures
create_timer
@MapInfoWin=Window_MapInfo.new
update
end
def dispose
dispose_tilemap
dispose_parallax
dispose_characters
dispose_shadow
dispose_weather
dispose_pictures
dispose_timer
dispose_viewports
@MapInfoWin.dispose
end
def update
update_tileset
update_tilemap
update_parallax
update_characters
update_shadow
update_weather
update_pictures
update_timer
update_viewports
if $game_switches[40]==false then
@MapInfoWin.visible=false
else
@MapInfoWin.visible=true
end
@MapInfoWin.refresh
end
end
复制代码
名称的话:
在Scene_Menu的def start super后面插入 create_playtime_window
再在Main上方插入
#==============================================================================
# ■ Window_Timer
#------------------------------------------------------------------------------
# 显示系统当前时间的窗口
#==============================================================================
class Window_Timer < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize
super(0, 0, window_width, fitting_height(3))
refresh
end
#--------------------------------------------------------------------------
# ● 获取窗口的宽度
#--------------------------------------------------------------------------
def window_width
return 160
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
self.contents.font.color = system_color
self.contents.draw_text(0, 0, 120, 32, "当前时间") #显示文本位置,我没有细调。。
@total_sec = Graphics.frame_count / Graphics.frame_rate
t = Time.now
$game_variables[204] = t.wday # 星期
$game_variables[208] = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"][$game_variables[204]]
text = sprintf("%02d:%02d:%02d", t.hour, t.min, t.sec)
text2 = sprintf("%02d.%02d.%02d", t.year, t.month, t.day)
text3 = sprintf($game_variables[208])
self.contents.font.color = normal_color
self.contents.draw_text(0, 20, 110, 32, text2, 2)
self.contents.draw_text(-25, 40, 110, 32, text3, 2)
self.contents.draw_text(-3, 60, 110, 32, text, 2)
end
#--------------------------------------------------------------------------
# ● 打开窗口
#--------------------------------------------------------------------------
def open
refresh
super
end
end
#encoding:utf-8
#==============================================================================
# ■ Window_PlayTime
#------------------------------------------------------------------------------
# 显示游戏时间的窗口
#==============================================================================
class Window_PlayTime < Window_Base
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize
super(0, 0, window_width, fitting_height(2))#游戏时间窗口的高度
refresh
end
#--------------------------------------------------------------------------
# ● 获取窗口的宽度
#--------------------------------------------------------------------------
def window_width
return 160 #游戏时间窗口的宽度
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
contents.clear
self.contents.font.color = system_color
self.contents.draw_text(0, 0, 120, 32, "游戏时间")
@total_sec = Graphics.frame_count / Graphics.frame_rate
hour = @total_sec / 60 / 60
min = @total_sec / 60 % 60
sec = @total_sec % 60
text = sprintf("%02d:%02d:%02d", hour, min, sec)
self.contents.font.color = normal_color
self.contents.draw_text(0, 20, 120, 32, text, 2)
end
#--------------------------------------------------------------------------
# ● 打开窗口
#--------------------------------------------------------------------------
def open
refresh
super
end
end
复制代码
最后直接上工程(RGSS300.dll自行添加):
显示游戏时间地图名称.zip
2013-12-6 13:33 上传
点击文件名下载附件
314.64 KB, 下载次数: 78
作者:
SINBIOS
时间:
2013-12-6 14:15
感激不尽 谢谢你
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1