查看: 1676|回复: 7

【XP】请看看这段脚本……有什么问题?

[复制链接]

脚本白痴

梦石
0
星屑
422
在线时间
903 小时
注册时间
2007-7-9
回帖
1259
发表于 2011-12-17 19:49:04 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
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 的下面

Mr.Gandum

梦石
0
星屑
226
在线时间
2070 小时
注册时间
2007-1-31
回帖
2982

贵宾

发表于 2011-12-17 20:01:31 | 显示全部楼层
在asasa = $game_actors[1].hp
后头加个.to_s
回复

使用道具 举报

脚本白痴

梦石
0
星屑
422
在线时间
903 小时
注册时间
2007-7-9
回帖
1259
 楼主| 发表于 2011-12-17 20:09:36 | 显示全部楼层
feizhaodan 发表于 2011-12-17 20:01
在asasa = $game_actors[1].hp
后头加个.to_s

谢谢你,另外,怎样刷新显示的数据呢?我这个只有在切换画面才会变化……

正统向RPG-大雄的高井山奇谈
https://rpg.blue/thread-369758-1-1.html
哆啦A梦RTP风格素材
https://rpg.blue/forum.php?mod=viewthread&tid=394608
回复

使用道具 举报

梦石
0
星屑
275
在线时间
1373 小时
注册时间
2005-10-16
回帖
5038

贵宾

发表于 2011-12-17 20:17:45 | 显示全部楼层
牛肉面 发表于 2011-12-17 20:09
谢谢你,另外,怎样刷新显示的数据呢?我这个只有在切换画面才会变化…… ...

刷新就是发现数据发生变化时,就重新写一次数据~
而更新就是不停的判断数据是否发生了变化
我只个搬答案的
叔叔我已经当爹了~
婚后闪人了……
回复

使用道具 举报

脚本白痴

梦石
0
星屑
422
在线时间
903 小时
注册时间
2007-7-9
回帖
1259
 楼主| 发表于 2011-12-17 20:30:50 | 显示全部楼层
就是这个!如何刷新和更新呢?我在Scene_Map中加入了@Time_Date_window.update,可是怎么刷新呢?

正统向RPG-大雄的高井山奇谈
https://rpg.blue/thread-369758-1-1.html
哆啦A梦RTP风格素材
https://rpg.blue/forum.php?mod=viewthread&tid=394608
回复

使用道具 举报

梦石
0
星屑
275
在线时间
1373 小时
注册时间
2005-10-16
回帖
5038

贵宾

发表于 2011-12-17 20:43:54 | 显示全部楼层
牛肉面 发表于 2011-12-17 20:30
就是这个!如何刷新和更新呢?我在Scene_Map中加入了@Time_Date_window.update,可是怎么刷新呢? ...

我说的更新和刷新都要在对应的Window类里~
我只个搬答案的
叔叔我已经当爹了~
婚后闪人了……
回复

使用道具 举报

脚本白痴

梦石
0
星屑
422
在线时间
903 小时
注册时间
2007-7-9
回帖
1259
 楼主| 发表于 2011-12-17 20:51:42 | 显示全部楼层
亿万星辰 发表于 2011-12-17 20:43
我说的更新和刷新都要在对应的Window类里~

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

点评

@Time_Date_Window.refresh  发表于 2011-12-17 20:58

正统向RPG-大雄的高井山奇谈
https://rpg.blue/thread-369758-1-1.html
哆啦A梦RTP风格素材
https://rpg.blue/forum.php?mod=viewthread&tid=394608
回复

使用道具 举报

脚本白痴

梦石
0
星屑
422
在线时间
903 小时
注册时间
2007-7-9
回帖
1259
 楼主| 发表于 2011-12-17 21:03:49 | 显示全部楼层
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

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

正统向RPG-大雄的高井山奇谈
https://rpg.blue/thread-369758-1-1.html
哆啦A梦RTP风格素材
https://rpg.blue/forum.php?mod=viewthread&tid=394608
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部