查看: 4560|回复: 4

[已经解决] 为什么这个显示获得物品的脚本不能把物品名字显示全?

[复制链接]
梦石
0
星屑
10345
在线时间
1117 小时
注册时间
2015-2-10
回帖
164
发表于 2019-8-22 19:22:02 | 显示全部楼层 |阅读模式

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

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

×
如题,本人为脚本盲,至多会改改数字和改false和true。我用这个脚本时,会出现显示不全的情况。这是脚本:
[pre lang="ruby"]#===============================================================================
# * Falcao Pearl ABS 脚本集 # 8
#
# 有关掉落物品和金币 v 1.0
# Pearl ABS 系统的一个插件,在没有ABS系统的情况下也可以独立运行。
#
# 网站: http://falcaorgss.wordpress.com/
# Foro: www.makerpalace.com
#===============================================================================
#
# * 安装
# 放在main之上就可以自动运行。
#
# * 使用方式
# 没有特别的使用方法,当玩家获得物品或金币时,就会有图标掉落在地图上。
# 下面是一些可以自定义的内容
#-------------------------------------------------------------------------------

module PearlItemPop
  
  # 物品得失提示的X坐标
  Pos_X = 10
  
  # 物品得失提示的Y坐标
  Pos_Y = 320
  
  # 代表金币的图标的index
  GoldIcon = 245
  
  # 获得物品时播放的音效 (设定为nil则无音效)
  ItemSe = "Item3"
  
  # 获得金币时播放的音效 (设定为nil则无音效)
  GoldSe = "Shop"
  
end

class Game_Party < Game_Unit
  alias falcaopearl_itempop_gain gain_item
  def gain_item(item, amount, include_equip = false)
    if !item_container(item.class).nil? && SceneManager.scene_is?(Scene_Map)
      if amount > 0
        $game_system.item_object = [item, amount]
        RPG::SE.new(PearlItemPop::ItemSe, 80).play rescue nil
      end
    end
    falcaopearl_itempop_gain(item, amount, include_equip = false)
  end
  
  alias falcaopearl_itempop_gold gain_gold
  def gain_gold(amount)
    if SceneManager.scene_is?(Scene_Map)
      $game_system.item_object = [nil, amount]
      RPG::SE.new(PearlItemPop::GoldSe, 80).play rescue nil
    end
    falcaopearl_itempop_gold(amount)
  end
end

class Game_System
  attr_accessor :item_object
end

class Spriteset_Map
  
  alias falcaopearl_itempop_create create_pictures
  def create_pictures
    create_itempop_sprites
    falcaopearl_itempop_create
  end
  
  def create_itempop_sprites
    @item_object = $game_system.item_object
    @item_sprite = Sprite_PopItem.new(@viewport2, @item_object) if
    not @item_object.nil?
  end
  
  alias falcaopearl_itempop_update update
  def update
    if !@item_sprite.nil?
      unless @item_sprite.disposed?
        @item_sprite.update
      else
        @item_sprite.dispose
        @item_object = nil
        $game_system.item_object = nil
        @item_sprite = nil
      end
    end
    if @item_object != $game_system.item_object
      @item_sprite.dispose if !@item_sprite.nil?
      @item_sprite = nil
      @item_sprite = Sprite_PopItem.new(@viewport2, $game_system.item_object)
      @item_object = $game_system.item_object
    end
    falcaopearl_itempop_update
  end
  
  alias falcaopearl_itempop_dispose dispose
  def dispose
    @item_sprite.dispose unless @item_sprite.nil?
    falcaopearl_itempop_dispose
  end
end

  
class Sprite_PopItem < Sprite
  def initialize(viewport, item)
    super(viewport)
    @item = item[0]
    @num = item[1]
    set_bitmap
    self.x = PearlItemPop::Pos_X
    self.y = PearlItemPop::Pos_Y
    @erasetimer = 120
    update
  end
  
  def update
    super
    if @erasetimer > 0
      @erasetimer -= 1
      self.opacity -= 10 if @erasetimer <= 25
      dispose if @erasetimer == 0
    end
  end
  
  def dispose
    self.bitmap.dispose
    super
  end
  
  def set_bitmap
    @item.nil? ? operand = Vocab::currency_unit : operand = @item.name
    string = operand + ' X' + @num.to_s
    self.bitmap = Bitmap.new(26 + string.length * 9, 28)
    self.bitmap.fill_rect(0, 0, self.bitmap.width, 28, Color.new(0, 0, 0, 100))
    self.bitmap.font.size = 20
    bitmap = Cache.system("Iconset")
    icon = @item.nil? ? PearlItemPop::GoldIcon : @item.icon_index
    rect = Rect.new(icon % 16 * 24, icon / 16 * 24, 24, 24)
    self.bitmap.blt(4, 0, bitmap, rect)
    self.bitmap.draw_text(28, 0, 250, 32, string)
  end
end
[/pre]
bandicam 2019-08-22 19-19-14-008.jpg

老鹰

梦石
40
星屑
37812
在线时间
7091 小时
注册时间
2012-5-26
回帖
3297

极短24评委极短23参与极短22参与极短21评委老司机慢点开短篇十吟唱者组别冠军开拓者剧作品鉴家

发表于 2019-8-22 20:03:58 | 显示全部楼层
136行 self.bitmap = Bitmap.new(26 + string.length * 9, 28)
其中 26 + string.length * 9 是这个显示的总宽度,28 是高度
而 string.length 是文字的数目,由于图标占了宽度24,所以前面加了 24+2
比如 恢复剂 X1 就是6个字符数目(含空格)
你把单个字符的宽度改大点,也就是把 9 改成比如 20 试试看,就懂了

评分

参与人数 2星屑 +100 赞 +1 收起 理由
VIPArcher + 100 认可答案
fbeds + 1 认可答案

查看全部评分

回复

使用道具 举报

梦石
0
星屑
10345
在线时间
1117 小时
注册时间
2015-2-10
回帖
164
 楼主| 发表于 2019-8-22 20:32:31 | 显示全部楼层
百里_飞柳 发表于 2019-8-22 20:03
136行 self.bitmap = Bitmap.new(26 + string.length * 9, 28)
其中 26 + string.length * 9 是这个显示的 ...

谢谢,已经解决。
回复

使用道具 举报

梦石
0
星屑
1737
在线时间
123 小时
注册时间
2023-12-26
回帖
184
发表于 2024-4-29 12:57:27 | 显示全部楼层
这个脚本,在宝箱里放好几个物品,显示才一个,,而且速度好快。。。有没办法一个一个显示。。

点评

你可以获得一个道具, 等待N帧, 再获得一个道具,再等待N帧...  发表于 2024-4-29 15:30
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部