设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1530|回复: 3
打印 上一主题 下一主题

[已经过期] 为什么自制的窗口类不能再地图上显示?

[复制链接]

Lv1.梦旅人

矿工

梦石
0
星屑
134
在线时间
898 小时
注册时间
2012-10-5
帖子
1535
跳转到指定楼层
1
发表于 2013-9-19 09:01:34 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 876加几 于 2013-9-19 13:09 编辑

脚本:
RUBY 代码复制
  1. #==============================================================================
  2. # ■ Window_SquareBattleActorMessge
  3. #------------------------------------------------------------------------------
  4. #  显示角色信息的类,归到窗口类为了方便。
  5. #==============================================================================
  6.  
  7. class Window_SquareBattleActorMessge < Window_Base
  8.   #--------------------------------------------------------------------------
  9.   # ● 初始化窗口
  10.   #--------------------------------------------------------------------------
  11.   def initialize
  12.     super(0, 480 - 32, 160, 32)
  13.     self.contents = Bitmap.new(width - 32, height - 32)
  14.     self.opacity = 0
  15.     refresh
  16.   end
  17.   #--------------------------------------------------------------------------
  18.   # ● 刷新
  19.   #--------------------------------------------------------------------------
  20.   def refresh
  21.     self.contents.clear
  22.     # 角色の绘制
  23.     if $game_party.actors.size != 0
  24.       @x1 = 16
  25.       @x2 = 176
  26.       @x3 = 332
  27.       @x4 = 496
  28.       @ay = 0
  29.       # 一号角色
  30.       if $game_party.actors.include?($game_actors[1])
  31.         draw_actor_head(1, @x1, @ay)
  32.         @a1hp = 100.000 / $game_actors[1].maxhp * $game_actors[1].hp
  33.         @a1hpzao = Bitmap.new("Graphics/Pictures/HP SP槽")
  34.         @a1hpzao.x = @x1 + 64
  35.         @a1hpzao.y = @ay + 16
  36.         @a1hptiao = Bitmap.new("Graphics/Pictures/HP槽(填充)")
  37.         @a1hptiao.x = @a1xuetiao.x + 1
  38.         @a1hptiao.y = @a1xuetiao.y + 1
  39.         @a1hptiao.zoom_x = @a1hp
  40.         @a1sp = 100.000 / $game_actors[1].maxsp * $game_actors[1].sp
  41.         @a1spzao = Bitmap.new("Graphics/Pictures/HP SP槽")
  42.         @a1spzao.x = @x1 + 64
  43.         @a1spzao.y = @ay + 32
  44.         @a1sptiao = Bitmap.new("Graphics/Pictures/SP槽(填充)")
  45.         @a1sptiao.x = @a1xuetiao.x + 1
  46.         @a1sptiao.y = @a1xuetiao.y + 1
  47.         @a1sptiao.zoom_x = @a1sp
  48.         @a1cp = 100.000 / 100 * $game_actors[1].mor
  49.         @a1cpzao = Bitmap.new("Graphics/Pictures/CP槽")
  50.         @a1cpzao.x = @x1 + 64
  51.         @a1cpzao.y = @ay + 48
  52.         @a1cptiao = Bitmap.new("Graphics/Pictures/CP槽(填充)")
  53.         @a1cptiao.x = @a1xuetiao.x + 1
  54.         @a1cptiao.y = @a1xuetiao.y + 1
  55.         @a1cptiao.zoom_x = @a1cp
  56.       end
  57.       # 二号角色
  58.       if $game_party.actors.include?($game_actors[2])
  59.         if $game_party.actors.include?($game_actors[1])
  60.           draw_actor_head(2, @x2, @ay)
  61.         else
  62.           draw_actor_head(2, @x1, @ay)
  63.         end
  64.         @a2hp = 100.000 / $game_actors[2].maxhp * $game_actors[2].hp
  65.         @a2hpzao = Bitmap.new("Graphics/Pictures/HP SP槽")
  66.         if $game_party.actors.include?($game_actors[1])
  67.           @a2hpzao.x = @x2 + 64
  68.         else
  69.           @a2hptiao.x = @x1 + 64
  70.         end
  71.         @a2hpzao.y = @ay + 16
  72.         @a2hptiao = Bitmap.new("Graphics/Pictures/HP槽(填充)")
  73.         @a2hptiao.x = @a1xuetiao.x + 1
  74.         @a2hptiao.y = @a1xuetiao.y + 1
  75.         @a2hptiao.zoom_x = @a1hp
  76.         @a2sp = 100.000 / $game_actors[2].maxsp * $game_actors[2].sp
  77.         @a2spzao = Bitmap.new("Graphics/Pictures/HP SP槽")
  78.         if $game_party.actors.include?($game_actors[1])
  79.           @a2spzao.x = @x2 + 64
  80.         else
  81.           @a2spzao.x = @x1 + 64
  82.         end
  83.         @a2spzao.y = @ay + 32
  84.         @a2sptiao = Bitmap.new("Graphics/Pictures/SP槽(填充)")
  85.         @a2sptiao.x = @a1xuetiao.x + 1
  86.         @a2sptiao.y = @a1xuetiao.y + 1
  87.         @a2sptiao.zoom_x = @a1sp
  88.         @a2cp = 100.000 / 100 * $game_actors[2].mor
  89.         @a2cpzao = Bitmap.new("Graphics/Pictures/CP槽")
  90.         if $game_party.actors.include?($game_actors[1])
  91.           @a2cpzao.x = @x2 + 64
  92.         else
  93.           @a2cpzao.x = @x1 + 64
  94.         end
  95.         @a2cpzao.y = @ay + 48
  96.         @a2cptiao = Bitmap.new("Graphics/Pictures/CP槽(填充)")
  97.         @a2cptiao.x = @a1xuetiao.x + 1
  98.         @a2cptiao.y = @a1xuetiao.y + 1
  99.         @a2cptiao.zoom_x = @a1cp
  100.       end
  101.       # 三号角色
  102.       if $game_party.actors.include?($game_actors[3])
  103.         if $game_party.actors.include?($game_actors[1])
  104.           if $game_party.actors.include?($game_actors[2])
  105.             draw_actor_head(3, @x3, @ay)
  106.           else
  107.             draw_actor_head(3, @x2, @ay)
  108.           end
  109.         elsif $game_party.actors.include?($game_actors[2])
  110.           draw_actor_head(3, @x2, @ay)
  111.         else
  112.           draw_actor_head(3, @x1, @ay)
  113.         end
  114.         @a3hp = 100.000 / $game_actors[3].maxhp * $game_actors[3].hp
  115.         @a3hpzao = Bitmap.new("Graphics/Pictures/HP SP槽")
  116.         @a3hpzao.y = @ay + 16
  117.         @a3hptiao = Bitmap.new("Graphics/Pictures/HP槽(填充)")
  118.         @a3hptiao.x = @a1xuetiao.x + 1
  119.         @a3hptiao.y = @a1xuetiao.y + 1
  120.         @a3hptiao.zoom_x = @a1hp
  121.         @a3sp = 100.000 / $game_actors[3].maxsp * $game_actors[3].sp
  122.         @a3spzao = Bitmap.new("Graphics/Pictures/HP SP槽")
  123.         @a3spzao.y = @ay + 32
  124.         @a3sptiao = Bitmap.new("Graphics/Pictures/SP槽(填充)")
  125.         @a3sptiao.x = @a1xuetiao.x + 1
  126.         @a3sptiao.y = @a1xuetiao.y + 1
  127.         @a3sptiao.zoom_x = @a1sp
  128.         @a3cp = 100.000 / 100 * $game_actors[3].mor
  129.         @a3cpzao = Bitmap.new("Graphics/Pictures/CP槽")
  130.         @a3cpzao.y = @ay + 48
  131.         @a3cptiao = Bitmap.new("Graphics/Pictures/CP槽(填充)")
  132.         @a3cptiao.x = @a1xuetiao.x + 1
  133.         @a3cptiao.y = @a1xuetiao.y + 1
  134.         @a3cptiao.zoom_x = @a1cp
  135.         if $game_party.actors.include?($game_actors[1])
  136.           if $game_party.actors.include?($game_actors[2])
  137.             @a3hpzao.x = @x3 + 64
  138.             @a3spzao.x = @x3 + 64
  139.             @a3cpzao.x = @x3 + 64
  140.           else
  141.             @a3hpzao.x = @x2 + 64
  142.             @a3spzao.x = @x2 + 64
  143.             @a3cpzao.x = @x2 + 64
  144.           end
  145.         elsif $game_party.actors.include?($game_actors[2])
  146.           @a3hpzao.x = @x2 + 64
  147.           @a3spzao.x = @x2 + 64
  148.           @a3cpzao.x = @x2 + 64
  149.         else
  150.           @a3hpzao.x = @x1 + 64
  151.           @a3spzao.x = @x1 + 64
  152.           @a3cpzao.x = @x1 + 64
  153.         end
  154.       end
  155.       # 四号角色
  156.       if $game_party.actors.include?($game_actors[4])
  157.         if $game_party.actors.include?($game_actors[1])
  158.           if $game_party.actors.include?($game_actors[2])
  159.             if $game_party.actors.include?($game_actors[3])
  160.               draw_actor_head(4, @x4, @ay)
  161.             else
  162.               draw_actor_head(4, @x3, @ay)
  163.             end
  164.           elsif $game_party.actors.include?($game_actors[3])
  165.             draw_actor_head(4, @x3, @ay)
  166.           else
  167.             draw_actor_head(4, @x2, @ay)
  168.           end
  169.         elsif $game_party.actors.include?($game_actors[2])
  170.           if $game_party.actors.include?($game_actors[3])
  171.             draw_actor_head(4, @x3, @ay)
  172.           else
  173.             draw_actor_head(4, @x2, @ay)
  174.           end
  175.         elsif $game_party.actors.include?($game_actors[3])
  176.           draw_actor_head(4, @x2, @ay)
  177.         else
  178.           draw_actor_head(4, @x1, @ay)
  179.         end
  180.         @a4hp = 100.000 / $game_actors[4].maxhp * $game_actors[4].hp
  181.         @a4hpzao = Bitmap.new("Graphics/Pictures/HP SP槽")
  182.         @a4hpzao.y = @ay + 16
  183.         @a4hptiao = Bitmap.new("Graphics/Pictures/HP槽(填充)")
  184.         @a4hptiao.x = @a1xuetiao.x + 1
  185.         @a4hptiao.y = @a1xuetiao.y + 1
  186.         @a4hptiao.zoom_x = @a1hp
  187.         @a4sp = 100.000 / $game_actors[4].maxsp * $game_actors[4].sp
  188.         @a4spzao = Bitmap.new("Graphics/Pictures/HP SP槽")
  189.         @a4spzao.y = @ay + 32
  190.         @a4sptiao = Bitmap.new("Graphics/Pictures/SP槽(填充)")
  191.         @a4sptiao.x = @a1xuetiao.x + 1
  192.         @a4sptiao.y = @a1xuetiao.y + 1
  193.         @a4sptiao.zoom_x = @a1sp
  194.         @a4cp = 100.000 / 100 * $game_actors[4].mor
  195.         @a4cpzao = Bitmap.new("Graphics/Pictures/CP槽")
  196.         @a4cpzao.y = @ay + 48
  197.         @a4cptiao = Bitmap.new("Graphics/Pictures/CP槽(填充)")
  198.         @a4cptiao.x = @a1xuetiao.x + 1
  199.         @a4cptiao.y = @a1xuetiao.y + 1
  200.         @a4cptiao.zoom_x = @a1cp
  201.         if $game_party.actors.include?($game_actors[1])
  202.           if $game_party.actors.include?($game_actors[2])
  203.             if $game_party.actors.include?($game_actors[3])
  204.               @a4hpzao.x = @x4 + 64
  205.               @a4spzao.x = @x4 + 64
  206.               @a4cpzao.x = @x4 + 64
  207.             else
  208.               @a4hpzao.x = @x3 + 64
  209.               @a4spzao.x = @x3 + 64
  210.               @a4cpzao.x = @x3 + 64
  211.             end
  212.           elsif $game_party.actors.include?($game_actors[3])
  213.             @a4hpzao.x = @x3 + 64
  214.             @a4spzao.x = @x3 + 64
  215.             @a4cpzao.x = @x3 + 64
  216.           else
  217.             @a4hpzao.x = @x2 + 64
  218.             @a4spzao.x = @x2 + 64
  219.             @a4cpzao.x = @x2 + 64
  220.           end
  221.         elsif $game_party.actors.include?($game_actors[2])
  222.           if $game_party.actors.include?($game_actors[3])
  223.             @a4hpzao.x = @x3 + 64
  224.             @a4spzao.x = @x3 + 64
  225.             @a4cpzao.x = @x3 + 64
  226.           else
  227.             @a4hpzao.x = @x2 + 64
  228.             @a4spzao.x = @x2 + 64
  229.             @a4cpzao.x = @x2 + 64
  230.           end
  231.         elsif $game_party.actors.include?($game_actors[3])
  232.           @a4hpzao.x = @x2 + 64
  233.           @a4spzao.x = @x2 + 64
  234.           @a4cpzao.x = @x2 + 64
  235.         else
  236.           @a4hpzao.x = @x1 + 64
  237.           @a4spzao.x = @x1 + 64
  238.           @a4cpzao.x = @x1 + 64
  239.         end
  240.       end
  241.     end
  242.   end
  243.   #--------------------------------------------------------------------------
  244.   # ● 刷新画面
  245.   #--------------------------------------------------------------------------
  246.   def update
  247.     super
  248.     if @a1hptiao != 100.000 / $game_actors[1].maxhp * $game_actors[1].hp or @a2hptiao != 100.000 / $game_actors[2].maxhp * $game_actors[2].hp or @a3hptiao != 100.000 / $game_actors[3].maxhp * $game_actors[3].hp or @a4hptiao != 100.000 / $game_actors[4].maxhp * $game_actors[4].hp or @a1sptiao != 100.000 / $game_actors[1].maxsp * $game_actors[1].sp or @a2sptiao != 100.000 / $game_actors[2].maxsp * $game_actors[2].sp or @a3sptiao != 100.000 / $game_actors[3].maxsp * $game_actors[3].sp or @a4sptiao != 100.000 / $game_actors[4].maxsp * $game_actors[4].sp or @a1cptiao != 100.000 / 100 * $game_actors[1].cp or @a2cptiao != 100.000 / 100 * $game_actors[2].cp or @a3cptiao != 100.000 / 100 * $game_actors[3].cp or @a4cptiao != 100.000 / 100 * $game_actors[4].cp
  249.       refresh
  250.     end
  251.   end
  252. end
里面素材齐全,但是每次在Scene_Map上写update就会出错,这是怎么回事?
update没问题了,窗口也不显示了……
(我用的是102版本的)
我写了draw_actor_head和mor方法,但是总是出错。

点评

怎么出错也不说一下。。。  发表于 2013-9-19 09:04
呃,发糖贴好冷清呀!

Lv3.寻梦者

梦石
0
星屑
3846
在线时间
1966 小时
注册时间
2013-1-3
帖子
9536
2
发表于 2013-9-19 09:31:49 | 只看该作者
是没法调用这个窗口类吗?

点评

想调用但会出错  发表于 2013-9-19 09:41
《宿愿·寻剑篇》正式版已经发布!快去看看!点击进入论坛发布贴
回复 支持 反对

使用道具 举报

Lv2.观梦者 (暗夜天使)

万兽

梦石
0
星屑
597
在线时间
2271 小时
注册时间
2006-11-4
帖子
4868

贵宾

3
发表于 2013-9-19 13:00:47 | 只看该作者
首先你有没有在scene_map里生成Window_SquareBattleActorMessge窗口?
其次你确定你有写draw_actor_head这个方法?
最后脚本中各种错误,完全不能使用,比如@a2sp = 100.000 / $game_actors[2].maxsp * $game_actors[2].sp 这个实例变量在整个脚本中没有任何意思,LZ需要的巩固脚本基础学会编写代码的一个基本思路。

点评

scene_map写了就出错,我在window_base里面写了draw_actor_head方法。这个怎样才能显示在scene_map里不出错?  发表于 2013-9-19 13:08
回复 支持 反对

使用道具 举报

Lv1.梦旅人

薄凉看客

梦石
0
星屑
50
在线时间
1269 小时
注册时间
2010-6-20
帖子
1316
4
发表于 2013-9-19 14:43:34 | 只看该作者
楼上正解没有在Scene_Map中生成窗口
  1. class Scene_Map
  2.   alias old_main_main_old main
  3.   def main
  4.     window = Window_SquareBattleActorMessge.new
  5.     old_main_main_old
  6.     window.dispose
  7.   end
  8. end  
复制代码

点评

太麻烦  发表于 2013-9-19 18:52
你来测试肯定有问题,因为你没有draw_actor_head类方法或者素材。  发表于 2013-9-19 15:30
你脚本有问题,你还是好好学下吧  发表于 2013-9-19 14:47
回复 支持 反对

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-9-23 07:34

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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