Project1

标题: 如何在地图左下角显示某个物品和数量? [打印本页]

作者: 爆焰    时间: 2012-7-30 05:49
标题: 如何在地图左下角显示某个物品和数量?
请问如何在游戏左下角用窗口显示某个物品的图标及数量?当几号开关打开后。dsu_plus_rewardpost_czw
作者: hys111111    时间: 2012-7-30 14:13
晕倒了……
直接用这个改就可以了。

  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. #==========================================================================
复制代码

作者: 爆焰    时间: 2012-7-30 20:37
hys111111 发表于 2012-7-30 14:13
晕倒了……
直接用这个改就可以了。

我用变量解决了我的问题了。但是有个问题。比我1号角色装备1号武器,就开1号开关,但是装备上之后回到地图,没有马上显示,而是当我再次打开菜单再回到地图时它才显示,卸下装备也一样。要开一下菜单才消失。
请问怎么解决?
作者: hys111111    时间: 2012-7-30 20:39
爆焰 发表于 2012-7-30 20:37
我用变量解决了我的问题了。但是有个问题。比我1号角色装备1号武器,就开1号开关,但是装备上之后回到地 ...

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




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