Project1
标题:
如何实现 变量值 显示到 画面的图片上
[打印本页]
作者:
z2z4
时间:
2013-2-9 10:34
标题:
如何实现 变量值 显示到 画面的图片上
本来可以用对话框 显示变量的 这个不实际 有没有其他办法
作者:
945127391
时间:
2013-2-10 15:25
用一个精灵吧……
在main上插入:
#------------------------------------------------------------------------------
# ** 设定
#------------------------------------------------------------------------------
Variable_XY = [0, 0] # 变量显示的xy坐标
#------------------------------------------------------------------------------
# ** 精灵
#------------------------------------------------------------------------------
class Sprite_Variable < Sprite
#----------------------------------------------------------------------------
# * 初始化
#----------------------------------------------------------------------------
def initialize(variable)
super(nil)
self.x = Variable_XY[0]
self.y = Variable_XY[1]
self.bitmap = Bitmap.new(Graphics.width - Variable_XY[0], 24)
@variable = variable
refresh
end
#----------------------------------------------------------------------------
# * 更新内容
#----------------------------------------------------------------------------
def refresh
self.bitmap.clear
self.bitmap.draw_text(self.bitmap.rect, @variable)
end
#----------------------------------------------------------------------------
# * 修改变量
#----------------------------------------------------------------------------
def variable=(nv)
@variable = nv
refresh
end
end
#------------------------------------------------------------------------------
# ** 地图
#------------------------------------------------------------------------------
class Game_Map
#----------------------------------------------------------------------------
# * 定义实例变量
#----------------------------------------------------------------------------
attr_accessor :map_variable
#----------------------------------------------------------------------------
# * 重命名方法
#----------------------------------------------------------------------------
alias oi initialize
#----------------------------------------------------------------------------
# * 初始化
#----------------------------------------------------------------------------
def initialize
oi
@map_variable = 0
end
end
class Scene_Map < Scene_Base
#----------------------------------------------------------------------------
# * 重命名方法
#----------------------------------------------------------------------------
alias os start
alias ou update
#----------------------------------------------------------------------------
# * 开始处理
#----------------------------------------------------------------------------
def start
os
@map_variable = $game_map.map_variable
@map_variable_sprite = Sprite_Variable.new($game_map.map_variable)
end
#----------------------------------------------------------------------------
# * 释放
#----------------------------------------------------------------------------
def dispose
super
@map_variable_sprite.dispose
end
#----------------------------------------------------------------------------
# * 刷新画面
#----------------------------------------------------------------------------
def update
ou
@map_variable_sprite.update
if @map_variable != $game_map.map_variable
@map_variable_sprite.variable = $game_map.map_variable
@map_variable = $game_map.map_variable
end
end
end
复制代码
在事件=>脚本中输入:
$game_map.map_variable = x
来修改显示的值.
(以上未经测试)
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1