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

Project1

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

[推荐问答] 如何在地图左下角显示某个物品和数量?

[复制链接]

Lv3.寻梦者

梦石
0
星屑
3065
在线时间
1429 小时
注册时间
2009-7-27
帖子
1448
跳转到指定楼层
1
发表于 2012-7-30 05:49:23 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
请问如何在游戏左下角用窗口显示某个物品的图标及数量?当几号开关打开后。

点评

你把那些变量去掉就可以了。这本身就是一个window  发表于 2012-7-30 16:53
这个显示图片  发表于 2012-7-30 16:29
bitmap = RPG::Cache.icon("101-01")#黄钥匙) 77. self.contents.blt(10, 280, bitmap, Rect.new(0, 0, 32, 32))  发表于 2012-7-30 16:29

博客:我的博客

Lv3.寻梦者

双子人

梦石
0
星屑
3165
在线时间
3616 小时
注册时间
2009-4-4
帖子
4154

开拓者

2
发表于 2012-7-30 14:13:45 | 只看该作者
晕倒了……
直接用这个改就可以了。

  1. Playerdate_SWITCH = 1 # 当1号开关打开,本脚本才开始工作。
  2. Playerdate_magicdef =19
  3. Yellowkey_itemid=1
  4. Bluekey_itemid=2
  5. Redkey_itemid=3
  6. Greenkey_itemid=41

  7. #==============================================================================
  8. # ■ Window_PlayerDate
  9. #------------------------------------------------------------------------------
  10. #  显示玩家状态的窗口。
  11. #==============================================================================

  12. class Window_PlayerDate < Window_Base
  13.   #--------------------------------------------------------------------------
  14.   # ● 初始化窗口
  15.   #--------------------------------------------------------------------------
  16.   def initialize
  17.     super(0, 0, 160, 640)#395)#192,416
  18.     self.contents = Bitmap.new(width - 32, height - 32)
  19.     self.z =210
  20.     self.opacity=0
  21.     self.back_opacity =255
  22. #    self.contents_opacity = 255
  23.     self.visible = false
  24. #    self.contents.clear
  25.     refresh
  26. #    if $game_switches[XY_SWITCH]
  27. #      self.contents_opacity = 0
  28. #    else
  29. #      self.contents_opacity = 5
  30. #    end
  31.    
  32.   end
  33.   
  34.   
  35.   def refresh
  36.     if $game_switches[50]#进入屏幕右侧状态栏换到左侧
  37.       self.x=0
  38.     else#进入屏幕左侧状态栏换到右侧
  39.       self.x=480
  40.     end

  41.     self.contents.clear
  42.     x=25
  43.     x=30 if !$game_switches[27]
  44.     y=75
  45.     y=40 if !$game_switches[27]
  46.     #actor = $game_party.actors[1]
  47.     draw_actor_graphic($game_party.actors[0], 20, 35)

  48.     self.contents.font.color = system_color
  49.     self.contents.draw_text(0, 55, 50, 20, "等级", 0)
  50.    
  51.     if $game_switches[42]
  52.       a=$game_variables[1]+81
  53.       if $game_variables[1]==3
  54.         a=116
  55.       end
  56.       if $game_variables[a]!=0
  57.         bitmap = Bitmap.new("Graphics/Pictures/up.png")
  58.         self.contents.blt(40,55 , bitmap, Rect.new(0, 0, 20, 20))
  59.       end
  60.     end

  61.     self.contents.draw_text(4, 65+x, 40, 20, "生命", 0)
  62.     self.contents.draw_text(4, 65+x*2, 40, 20, "攻击", 0)
  63.     self.contents.draw_text(4, 65+x*3, 40, 20,"防御", 0)
  64.     self.contents.draw_text(4, 65+x*4, 40, 20, "魔防", 0) if $game_switches[Playerdate_magicdef]
  65.     self.contents.draw_text(4, 65+x*5, 40, 20, "速度", 0) if $game_switches[27]

  66.     self.contents.draw_text(4, y+x*6, 40, 20, "经验", 0)
  67.     self.contents.draw_text(4, y+x*7, 40, 20, "金币", 0)

  68.     if $game_switches[26]
  69.       bitmap = RPG::Cache.icon("101-01")#黄钥匙)
  70.       self.contents.blt(10, 280, bitmap, Rect.new(0, 0, 32, 32))   
  71.       bitmap = RPG::Cache.icon("101-02")#蓝钥匙)
  72.       self.contents.blt(10, 307, bitmap, Rect.new(0, 0, 32, 32))
  73.       bitmap = RPG::Cache.icon("101-03")#红钥匙)
  74.       self.contents.blt(10, 334, bitmap, Rect.new(0, 0, 32, 32))
  75.       bitmap = RPG::Cache.icon("101-04") if $game_switches[43]#绿钥匙)
  76.       self.contents.blt(10, 361, bitmap, Rect.new(0, 0, 32, 32)) if $game_switches[43]

  77.     else
  78.       self.contents.font.color = text_color(6)   
  79.       self.contents.draw_text(8, 285, 50, 20, "黄钥匙", 0)
  80.       self.contents.font.color = text_color(4)   
  81.       self.contents.draw_text(8, 313, 50, 20, "蓝钥匙", 0)
  82.       self.contents.font.color = text_color(2)   
  83.       self.contents.draw_text(8, 341, 50, 20, "红钥匙", 0)
  84.       self.contents.font.color = text_color(3)   
  85.       self.contents.draw_text(8, 369, 50, 20, "绿钥匙", 0) if $game_switches[43]
  86.     end
  87.    
  88.     @xgraphic=$game_party.actors[0].character_name
  89.     @xfloor=$game_map.got_name($game_variables[3],$game_variables[2])
  90.     @xlevel=$game_actors[$game_variables[1]+1].level
  91.     @xlevelup=$game_variables[$game_variables[1]+81] if $game_switches[42]
  92.     @xlife=$game_actors[$game_variables[1]+1].hp
  93.     @xattact=$game_actors[$game_variables[1]+1].str
  94.     @xdefence=$game_actors[$game_variables[1]+1].dex
  95.     @xmagicdef=$game_actors[$game_variables[1]+1].int if $game_switches[Playerdate_magicdef]
  96.     @xspeed=$game_actors[$game_variables[1]+1].agi if $game_switches[27]
  97.     @xexp= $game_actors[$game_variables[1]+1].exp
  98.     @xgold=$game_party.gold
  99.     @xyellowkey=$game_party.item_number(Yellowkey_itemid)
  100.     @xbluekey=$game_party.item_number(Bluekey_itemid)
  101.     @xredkey=$game_party.item_number(Redkey_itemid)
  102.     @xgreenkey=$game_party.item_number(Greenkey_itemid) if $game_switches[43]
  103.     @xpoison=$game_switches[13]
  104.     @xpoor=$game_switches[15]
  105.     @xcurse=$game_switches[16]
  106.     @xslow=$game_switches[12]
  107.     @xchange=$game_switches[50]
  108.     @xt1=$game_switches[56]
  109.     @xt2=$game_switches[57]
  110.     @xt3=$game_switches[59]
  111.     @xx=$game_variables[3]
  112.     @yy=$game_variables[2]
  113.    
  114.    
  115.     self.contents.font.color = normal_color
  116.     self.contents.draw_text(40, 0, 80, 45, @xfloor.to_s, 2)
  117.    
  118.     self.contents.draw_text(50, 50, 65, 30, @xlevel.to_s, 2)
  119.     self.contents.draw_text(50, 50, 20, 35, @xname.to_s, 2)
  120.     self.contents.draw_text(43, 65+x, 72, 20,@xlife .to_s, 2)
  121.     self.contents.draw_text(50, 65+x*2, 65, 20,@xattact .to_s, 2)
  122.     self.contents.draw_text(50, 65+x*3, 65, 20,@xdefence .to_s, 2)
  123.     self.contents.draw_text(50, 65+x*4, 65, 20,@xmagicdef .to_s, 2) if $game_switches[Playerdate_magicdef]
  124.     self.contents.draw_text(50, 65+x*5, 65, 20,@xspeed .to_s, 2) if $game_switches[27]

  125.     self.contents.draw_text(50, y+x*6, 65, 20,@xexp.to_s, 2)
  126.     self.contents.draw_text(50, y+x*7, 65, 20, @xgold.to_s, 2)
  127.    
  128.     self.contents.draw_text(8, 440, 65, 20, "坐标"[email protected]_s+","[email protected]_s, 2)
  129.    
  130.     self.contents.font.color = text_color(6)
  131.     self.contents.draw_text(75, 285, 25, 20, @xyellowkey.to_s, 2)
  132.     self.contents.font.color = text_color(4)
  133.     self.contents.draw_text(75, 313, 25, 20, @xbluekey .to_s, 2)
  134.     self.contents.font.color = text_color(2)
  135.     self.contents.draw_text(75, 341, 25, 20, @xredkey.to_s, 2)
  136.     self.contents.font.color = text_color(3)
  137.     self.contents.draw_text(75, 369, 25, 20, @xgreenkey.to_s, 2) if $game_switches[43]
  138.    
  139.     self.contents.font.color = text_color(3)
  140.     self.contents.draw_text(8, 390, 20, 20, "毒".to_s, 0) if $game_switches[13]
  141.     self.contents.font.color = text_color(5)
  142.     self.contents.draw_text(36, 390, 20, 20, "衰".to_s, 0) if $game_switches[15]
  143.     self.contents.font.color = text_color(4)
  144.     self.contents.draw_text(64, 390, 20, 20, "咒".to_s, 0) if $game_switches[16]
  145.     self.contents.font.color = Color.new(rand(255),rand(255),rand(255))
  146.     self.contents.draw_text(8, 410, 20, 20, "胡".to_s, 0) if $game_switches[56]
  147.     self.contents.font.color = text_color(1)
  148.     self.contents.draw_text(92, 390, 20, 20, "慢".to_s, 0) if $game_switches[12]
  149.     self.contents.font.color = Color.new(rand(10),rand(10),rand(10))
  150.     self.contents.draw_text(36, 410, 40, 20, "魔咒".to_s, 0) if $game_switches[59]
  151.     self.contents.font.color = Color.new(0,255,255)
  152.     self.contents.draw_text(92, 410, 20, 20, "反".to_s, 0) if $game_switches[57]
  153.    
  154.    
  155.    
  156.   end
  157.   
  158.   def judge#用于判断是否数据变更,节约内存
  159.     return true if @xgraphic!=$game_party.actors[0].character_name
  160.     return true if @xfloor!=$game_map.got_name($game_variables[3],$game_variables[2])
  161.     return true if @xlevel!=$game_actors[$game_variables[1]+1].level
  162.     return true if @xlevelup!=$game_variables[$game_variables[1]+81] if $game_switches[42]
  163.     return true if @xlife!=$game_actors[$game_variables[1]+1].hp
  164.     return true if @xattact!=$game_actors[$game_variables[1]+1].str
  165.     return true if @xdefence!=$game_actors[$game_variables[1]+1].dex
  166.     return true if @xmagicdef!=$game_actors[$game_variables[1]+1].int if $game_switches[Playerdate_magicdef]
  167.     return true if @xspeed!=$game_actors[$game_variables[1]+1].agi if $game_switches[27]
  168.     return true if @xexp!= $game_actors[$game_variables[1]+1].exp
  169.     return true if @xgold!=$game_party.gold
  170.     return true if @xyellowkey!=$game_party.item_number(Yellowkey_itemid)
  171.     return true if @xbluekey!=$game_party.item_number(Bluekey_itemid)
  172.     return true if @xredkey!=$game_party.item_number(Redkey_itemid)
  173.     return true if @xgreenkey!=$game_party.item_number(Greenkey_itemid) if $game_switches[43]
  174.     return true if @xpoison!=$game_switches[13]
  175.     return true if @xpoor!=$game_switches[15]
  176.     return true if @xcurse!=$game_switches[16]
  177.     return true if @xslow!=$game_switches[12]
  178.     return true if @xchange!=$game_switches[50]
  179.     return true if @xt1!=$game_switches[56]
  180.     return true if @xt2!=$game_switches[57]
  181.     return true if @xt3!=$game_switches[59]
  182.     return false
  183.   end

  184. end

  185. ###########################################################################
  186. #                           下面的东西不需要掌握~                         #
  187. ###########################################################################

  188. class Scene_Map
  189. alias xy_66rpg_main main
  190. def main
  191.    @Playerdate_window = Window_PlayerDate.new
  192.    @Playerdate_window.x = $game_variables[105]
  193. #   @xy_window.y = 480 - 96
  194. #   @xy_window.opacity = 0
  195.    xy_66rpg_main
  196.    @Playerdate_window .dispose
  197. end
  198. #--------------------------------------------------------------------------
  199. # ● 刷新画面
  200. #--------------------------------------------------------------------------
  201. alias xy_66rpg_update update
  202. def update
  203.    xy_66rpg_update
  204.    if $game_switches[Playerdate_SWITCH]
  205.      @Playerdate_window .visible = true     
  206.      @Playerdate_window .refresh if @Playerdate_window.judge
  207.    else
  208.      @Playerdate_window .visible = false
  209.    end
  210. end
  211. end
  212. #==========================================================================
  213. # 本脚本来自www.66rpg.com,用于任何游戏请保留此信息。别以为加密就可以del哦
  214. #==========================================================================
复制代码

点评

如何让图标跟着角色的ID不同而改变?比如1号是这个物品。2号是那个物品。我打算做射击类游戏,所以需要。  发表于 2012-7-30 17:00
还有,如何弄不需要开关直接显示图标?  发表于 2012-7-30 16:50
Playerdate_magicdef =19 这个是干嘛的?  发表于 2012-7-30 16:45
如何显示图标?  发表于 2012-7-30 16:26

评分

参与人数 1梦石 +2 收起 理由
hcm + 2 认可答案

查看全部评分

回复

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3065
在线时间
1429 小时
注册时间
2009-7-27
帖子
1448
3
 楼主| 发表于 2012-7-30 20:37:36 | 只看该作者
hys111111 发表于 2012-7-30 14:13
晕倒了……
直接用这个改就可以了。

我用变量解决了我的问题了。但是有个问题。比我1号角色装备1号武器,就开1号开关,但是装备上之后回到地图,没有马上显示,而是当我再次打开菜单再回到地图时它才显示,卸下装备也一样。要开一下菜单才消失。
请问怎么解决?

博客:我的博客
回复

使用道具 举报

Lv3.寻梦者

双子人

梦石
0
星屑
3165
在线时间
3616 小时
注册时间
2009-4-4
帖子
4154

开拓者

4
发表于 2012-7-30 20:39:37 | 只看该作者
爆焰 发表于 2012-7-30 20:37
我用变量解决了我的问题了。但是有个问题。比我1号角色装备1号武器,就开1号开关,但是装备上之后回到地 ...

下面的def judge一定要改
添加了“@”的局部变量要判断数据是否改变从而节省内存

点评

搞定了,爱S你了。  发表于 2012-7-30 21:42
回复

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-26 08:06

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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