Project1

标题: 【XP】请看看这段脚本……有什么问题? [打印本页]

作者: 牛肉面    时间: 2011-12-17 19:49
标题: 【XP】请看看这段脚本……有什么问题?
asasa = $game_actors[1].hp
self.contents.clear
self.contents.draw_text(0, 0, 32, 32, '体力')
self.contents.draw_text(0, 32, 32, 32, '精力')
self.contents.draw_text(32, 0, 128, 32, asasa)

说明是cannot convert Fixnum into Strong
是最后一行出错

此脚本全文:


class Window_Time_Date < Window_Base
  def initialize
super(0, 384,180, 96)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity=150  # 窗口的不透明度   
    self.back_opacity=150 # 窗口背景的不透明度
   refresh
  end




end # end def initialize

def refresh
  

# self.contents.draw_text(32, 0, 96, 32, $game_variables[1].to_s)
asasa = $game_actors[1].hp
self.contents.clear
self.contents.draw_text(0, 0, 32, 32, '体力')
self.contents.draw_text(0, 32, 32, 32, '精力')
self.contents.draw_text(32, 0, 128, 32, asasa)


end # end def refresh

def update
end # end def update

放在了Window_DebugRight 的下面


作者: feizhaodan    时间: 2011-12-17 20:01
在asasa = $game_actors[1].hp
后头加个.to_s
作者: 牛肉面    时间: 2011-12-17 20:09
feizhaodan 发表于 2011-12-17 20:01
在asasa = $game_actors[1].hp
后头加个.to_s

谢谢你,另外,怎样刷新显示的数据呢?我这个只有在切换画面才会变化……
作者: 亿万星辰    时间: 2011-12-17 20:17
牛肉面 发表于 2011-12-17 20:09
谢谢你,另外,怎样刷新显示的数据呢?我这个只有在切换画面才会变化…… ...

刷新就是发现数据发生变化时,就重新写一次数据~
而更新就是不停的判断数据是否发生了变化
作者: 牛肉面    时间: 2011-12-17 20:30
就是这个!如何刷新和更新呢?我在Scene_Map中加入了@Time_Date_window.update,可是怎么刷新呢?
作者: 亿万星辰    时间: 2011-12-17 20:43
牛肉面 发表于 2011-12-17 20:30
就是这个!如何刷新和更新呢?我在Scene_Map中加入了@Time_Date_window.update,可是怎么刷新呢? ...

我说的更新和刷新都要在对应的Window类里~
作者: 牛肉面    时间: 2011-12-17 20:51
亿万星辰 发表于 2011-12-17 20:43
我说的更新和刷新都要在对应的Window类里~

脚本要怎么写呢?
我写@Time_Date.refresh会出现错误……

作者: 牛肉面    时间: 2011-12-17 21:03
AAAA = 10  #开关
BBBB = 10  # 强制刷新


#==============================================================================
# ■ Window_Maplife
#------------------------------------------------------------------------------
#  显示坐标的窗口。
#==============================================================================
class Window_Maplife < Window_Base #注意前面那个window_life是文件名
#--------------------------------------------------------------------------
# ● 初始化窗口
#--------------------------------------------------------------------------
def initialize
#=======================此处可任意调整窗口位置
  super(0, 384,180, 96)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity=150  # 窗口的不透明度   
    self.back_opacity=150 # 窗口背景的不透明度
  #=======================
  refresh
end

#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
  if $game_switches[AAAA]
    @life = $life         # 记录现在变量数组结构
    self.contents.clear # 清除以前的东西
asasa = $game_actors[1].hp.to_s
asasa2 = $game_actors[1].maxhp.to_s
asasa3 =asasa + '/'+ asasa2
asasa4 = $game_actors[1].sp.to_s
asasa5 = $game_actors[1].maxsp.to_s
asasa6 =asasa4 + '/'+ asasa5
self.contents.draw_text(0, 0, 32, 32, '体力')
self.contents.draw_text(0, 32, 32, 32, '精力')
self.contents.draw_text(40, 0, 128, 32, asasa3)
self.contents.draw_text(40, 32, 128, 32, asasa6)
  end
end
#--------------------------------------------------------------------------
# ● 判断文字刷新
#--------------------------------------------------------------------------
def judge
  for life_draw in $life
    if @life_a[life_draw[0]] != $game_variables[life_draw[0]] #如果现在记录的变量和游戏变量不同,刷新
      return true
    end
  end
  if $game_switches[BBBB]  # 强制刷新的时候,刷新
    $game_switches[BBBB] = false
    return true
  end
  return false
  end
end
class Scene_Map
alias life_main main
def main
  @life_window = Window_lifeVar.new
# @var_window.opacity = 0
  life_main
  @life_window.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
alias life_update update
def update
  life_update
  if $game_switches[AAAA]
    @life_window.visible = true      
    @life_window.refresh
    #if @life_window.judge
  else
    @life_window.visible = false
  end
end
end

我照着别人得改这样子了。如果变量过多会不会太卡?




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1