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

Project1

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

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

[复制链接]

Lv4.逐梦者

梦石
0
星屑
7013
在线时间
877 小时
注册时间
2015-2-10
帖子
248
跳转到指定楼层
1
发表于 2019-8-22 19:22:02 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
如题,本人为脚本盲,至多会改改数字和改false和true。我用这个脚本时,会出现显示不全的情况。这是脚本:
RUBY 代码复制
  1. #===============================================================================
  2. # * Falcao Pearl ABS 脚本集 # 8
  3. #
  4. # 有关掉落物品和金币 v 1.0
  5. # Pearl ABS 系统的一个插件,在没有ABS系统的情况下也可以独立运行。
  6. #
  7. # 网站: [url]http://falcaorgss.wordpress.com/[/url]
  8. # Foro: [url]www.makerpalace.com[/url]
  9. #===============================================================================
  10. #
  11. # * 安装
  12. # 放在main之上就可以自动运行。
  13. #
  14. # * 使用方式
  15. # 没有特别的使用方法,当玩家获得物品或金币时,就会有图标掉落在地图上。
  16. # 下面是一些可以自定义的内容
  17. #-------------------------------------------------------------------------------
  18.  
  19. module PearlItemPop
  20.  
  21.   # 物品得失提示的X坐标
  22.   Pos_X = 10
  23.  
  24.   # 物品得失提示的Y坐标
  25.   Pos_Y = 320
  26.  
  27.   # 代表金币的图标的index
  28.   GoldIcon = 245
  29.  
  30.   # 获得物品时播放的音效 (设定为nil则无音效)
  31.   ItemSe = "Item3"
  32.  
  33.   # 获得金币时播放的音效 (设定为nil则无音效)
  34.   GoldSe = "Shop"
  35.  
  36. end
  37.  
  38. class Game_Party < Game_Unit
  39.   alias falcaopearl_itempop_gain gain_item
  40.   def gain_item(item, amount, include_equip = false)
  41.     if !item_container(item.class).nil? && SceneManager.scene_is?(Scene_Map)
  42.       if amount > 0
  43.         $game_system.item_object = [item, amount]
  44.         RPG::SE.new(PearlItemPop::ItemSe, 80).play rescue nil
  45.       end
  46.     end
  47.     falcaopearl_itempop_gain(item, amount, include_equip = false)
  48.   end
  49.  
  50.   alias falcaopearl_itempop_gold gain_gold
  51.   def gain_gold(amount)
  52.     if SceneManager.scene_is?(Scene_Map)
  53.       $game_system.item_object = [nil, amount]
  54.       RPG::SE.new(PearlItemPop::GoldSe, 80).play rescue nil
  55.     end
  56.     falcaopearl_itempop_gold(amount)
  57.   end
  58. end
  59.  
  60. class Game_System
  61.   attr_accessor :item_object
  62. end
  63.  
  64. class Spriteset_Map
  65.  
  66.   alias falcaopearl_itempop_create create_pictures
  67.   def create_pictures
  68.     create_itempop_sprites
  69.     falcaopearl_itempop_create
  70.   end
  71.  
  72.   def create_itempop_sprites
  73.     @item_object = $game_system.item_object
  74.     @item_sprite = Sprite_PopItem.new(@viewport2, @item_object) if
  75.     not @item_object.nil?
  76.   end
  77.  
  78.   alias falcaopearl_itempop_update update
  79.   def update
  80.     if !@item_sprite.nil?
  81.       unless @item_sprite.disposed?
  82.         @item_sprite.update
  83.       else
  84.         @item_sprite.dispose
  85.         @item_object = nil
  86.         $game_system.item_object = nil
  87.         @item_sprite = nil
  88.       end
  89.     end
  90.     if @item_object != $game_system.item_object
  91.       @item_sprite.dispose if !@item_sprite.nil?
  92.       @item_sprite = nil
  93.       @item_sprite = Sprite_PopItem.new(@viewport2, $game_system.item_object)
  94.       @item_object = $game_system.item_object
  95.     end
  96.     falcaopearl_itempop_update
  97.   end
  98.  
  99.   alias falcaopearl_itempop_dispose dispose
  100.   def dispose
  101.     @item_sprite.dispose unless @item_sprite.nil?
  102.     falcaopearl_itempop_dispose
  103.   end
  104. end
  105.  
  106.  
  107. class Sprite_PopItem < Sprite
  108.   def initialize(viewport, item)
  109.     super(viewport)
  110.     @item = item[0]
  111.     @num = item[1]
  112.     set_bitmap
  113.     self.x = PearlItemPop::Pos_X
  114.     self.y = PearlItemPop::Pos_Y
  115.     @erasetimer = 120
  116.     update
  117.   end
  118.  
  119.   def update
  120.     super
  121.     if @erasetimer > 0
  122.       @erasetimer -= 1
  123.       self.opacity -= 10 if @erasetimer <= 25
  124.       dispose if @erasetimer == 0
  125.     end
  126.   end
  127.  
  128.   def dispose
  129.     self.bitmap.dispose
  130.     super
  131.   end
  132.  
  133.   def set_bitmap
  134.     @item.nil? ? operand = Vocab::currency_unit : operand = @item.name
  135.     string = operand + ' X' + @num.to_s
  136.     self.bitmap = Bitmap.new(26 + string.length * 9, 28)
  137.     self.bitmap.fill_rect(0, 0, self.bitmap.width, 28, Color.new(0, 0, 0, 100))
  138.     self.bitmap.font.size = 20
  139.     bitmap = Cache.system("Iconset")
  140.     icon = @item.nil? ? PearlItemPop::GoldIcon : @item.icon_index
  141.     rect = Rect.new(icon % 16 * 24, icon / 16 * 24, 24, 24)
  142.     self.bitmap.blt(4, 0, bitmap, rect)
  143.     self.bitmap.draw_text(28, 0, 250, 32, string)
  144.   end
  145. end

bandicam 2019-08-22 19-19-14-008.jpg (95.4 KB, 下载次数: 20)

bandicam 2019-08-22 19-19-14-008.jpg

Lv6.析梦学徒

老鹰

梦石
40
星屑
33402
在线时间
6552 小时
注册时间
2012-5-26
帖子
3178

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

2
发表于 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 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
0
星屑
7013
在线时间
877 小时
注册时间
2015-2-10
帖子
248
3
 楼主| 发表于 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 是这个显示的 ...

谢谢,已经解决。
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-25 13:44

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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