Project1

标题: Window_ShopBuy插入背景图,换到其它界面图却消失不了 [打印本页]

作者: alonescud    时间: 2008-5-4 02:54
标题: Window_ShopBuy插入背景图,换到其它界面图却消失不了
RT

我在 Window_ShopBuy 用以下语句加入背景图

class Window_ShopBuy < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #     shop_goods : 商品
  #--------------------------------------------------------------------------
  def initialize(shop_goods)
    super(0, 128, 368, 347)
    @shop_goods = shop_goods
    refresh
    @menu_com = Sprite.new
   @menu_com.bitmap = RPG::Cache.picture("商店界面.png")

    self.index = 0
  end


彩色是我新增的,目的就是加个背景图,退出商店后图会跟着消失。但进入其它界面时(比如在地图上显示图片,进入存档界面什么的),此图又出现了,消失不了。
MS是我没有在脚本里释放他,可是我不知道要怎么做,请指教,谢谢! [LINE]1,#dddddd[/LINE]版务信息:本贴由楼主自主结贴~
作者: 3535    时间: 2008-5-4 02:57
def dispose
super
@menu_com.dispose
end


加入Window_ShopBuy [LINE]1,#dddddd[/LINE]系统信息:本贴由楼主认可为正确答案,66RPG感谢您的热情解答~
作者: alonescud    时间: 2008-5-4 03:15
以下引用3535于2008-5-3 18:57:29的发言:


def dispose
super
@menu_com.dispose
end


加入Window_ShopBuy


[本贴由作者于 2008-5-3 19:00:03 最后编辑]


具体加在哪里...{/gg}


这是完整的window_shopbuy


#==============================================================================
# ■ Window_ShopBuy
#------------------------------------------------------------------------------
#  商店画面、浏览显示可以购买的商品的窗口。
#==============================================================================

class Window_ShopBuy < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #     shop_goods : 商品
  #--------------------------------------------------------------------------
  def initialize(shop_goods)
    super(0, 128, 368, 347) #Scud   352->347
    @shop_goods = shop_goods
    refresh
    @menu_com = Sprite.new
   @menu_com.bitmap = RPG::Cache.picture("商店界面.png")

    self.index = 0
  end
  #--------------------------------------------------------------------------
  # ● 获取物品
  #--------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    for goods_item in @shop_goods
      case goods_item[0]
      when 0
        item = $data_items[goods_item[1]]
      when 1
        item = $data_weapons[goods_item[1]]
      when 2
        item = $data_armors[goods_item[1]]
      end
      if item != nil
        @data.push(item)
      end
    end
    # 如果项目数不是 0 就生成位图、描绘全部项目
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 描绘羡慕
  #     index : 项目编号
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    # 获取物品所持数
    case item
    when RPG::Item
      number = $game_party.item_number(item.id)
    when RPG::Weapon
      number = $game_party.weapon_number(item.id)
    when RPG::Armor
      number = $game_party.armor_number(item.id)
    end
    # 价格在所持金以下、并且所持数不是 99 的情况下为普通文字颜色
    # 除此之外的情况设置为无效文字色
    if item.price <= $game_party.gold and number < 99
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
    x = 4
    y = index * 32
    rect = Rect.new(x, y, self.width - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(item.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
    self.contents.draw_text(x + 240, y, 88, 32, item.price.to_s, 2)
  end
  #--------------------------------------------------------------------------
  # ● 刷新帮助文本
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(self.item == nil ? "" : self.item.description)
  end
end





作者: Infrared    时间: 2008-5-4 03:18
提示: 作者被禁止或删除 内容自动屏蔽
作者: alonescud    时间: 2008-5-4 03:25
问题解决了,多谢! {/se}
放心吧,没认可你的马甲  {/cy}




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