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

Project1

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

[已经解决] 如何在菜单状态窗口中用图片选择人物

[复制链接]

Lv1.梦旅人

梦石
0
星屑
635
在线时间
5 小时
注册时间
2014-5-7
帖子
3
跳转到指定楼层
1
发表于 2015-9-25 23:40:40 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 baidubb2733 于 2015-9-25 23:45 编辑

我想要的效果是,在菜单状态窗口中,用图片代表在队的角色,当选中某个角色时他的图片会变为另外一张,(相当于按钮的效果)。

我自己改的menustatus是这样的,现在能将这些图片摆在窗口中,但是因为用for添加的图片,不知道怎么修改单张图片的透明度,请问怎样写选中就能换图片的脚本呢?

刚开始学脚本,非常小白,好焦急,头像代表我的心情,跪求各位大神教教我。

RUBY 代码复制
  1. #==============================================================================
  2. # ■ Window_MenuStatus
  3. #------------------------------------------------------------------------------
  4. #  显示菜单画面和同伴状态的窗口。
  5. #==============================================================================
  6.  
  7. class Window_MenuStatus < Window_Selectable
  8.   #--------------------------------------------------------------------------
  9.   # ● 初始化目标
  10.   #--------------------------------------------------------------------------
  11.   def initialize
  12.     super(0, 0, 480, 480)
  13.     self.contents = Bitmap.new(width - 32, height - 32)
  14.     refresh
  15.     self.active = false
  16.     self.index = -1
  17.     self.z = 201
  18.   end
  19.  
  20.  
  21.  
  22.  
  23.   end
  24.   #--------------------------------------------------------------------------
  25.   # ● 刷新
  26.   #--------------------------------------------------------------------------
  27.   def refresh
  28.     self.contents.clear
  29.     @item_max = $game_party.actors.size
  30.     for i in 0...$game_party.actors.size
  31.       x = 80 + (i * 110)
  32.       y = 420
  33.       actor = $game_party.actors[i]
  34.       bitmap = Bitmap.new("Graphics/Menu/" + actor.id.to_s + "_2D")
  35.       cw = bitmap.width
  36.       ch = bitmap.height
  37.       src_rect = Rect.new(0, 0, cw, ch)
  38.       self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
  39.     end  
  40.     for i in 0...$game_party.actors.size
  41.       x = 80 + (i * 110)
  42.       y = 420
  43.       actor = $game_party.actors[i]
  44.       bitmap = Bitmap.new("Graphics/Menu/" + actor.id.to_s + "_2D_2")
  45.       cw = bitmap.width
  46.       ch = bitmap.height
  47.       src_rect = Rect.new(0, 0, cw, ch)
  48.       self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)   
  49.     end
  50. end
  51.   #--------------------------------------------------------------------------
  52.   # ● 刷新光标矩形
  53.   #--------------------------------------------------------------------------
  54.   def update_cursor_rect
  55.     if @index < 0
  56.       self.cursor_rect.empty
  57.     else
  58.       self.cursor_rect.set(0, @index * 116, self.width - 32, 96)
  59.     end
  60.   end

评分

参与人数 1星屑 +35 收起 理由
RyanBern + 35 手动认可奖励

查看全部评分

Lv4.逐梦者

「Pemercyia」


Urhurrenna

梦石
0
星屑
9397
在线时间
2748 小时
注册时间
2008-9-5
帖子
3543

开拓者短篇八RM组冠军短篇九导演组亚军白银编剧

2
发表于 2015-9-25 23:57:49 | 只看该作者
本帖最后由 cinderelmini 于 2015-9-26 00:20 编辑

唔……XP的机制怪怪的,好像只能搬运一下update的内容然后加refresh进去了。
  1. #==============================================================================
  2. # ■ Window_MenuStatus
  3. #------------------------------------------------------------------------------
  4. #  显示菜单画面和同伴状态的窗口。
  5. #==============================================================================

  6. class Window_MenuStatus < Window_Selectable
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化目标
  9.   #--------------------------------------------------------------------------
  10.   def initialize
  11.     super(0, 0, 480, 480)
  12.     self.contents = Bitmap.new(width - 32, height - 32)
  13.     refresh
  14.     self.active = false
  15.     self.index = -1
  16.     self.z = 201
  17.   end
  18.   #--------------------------------------------------------------------------
  19.   # ● 刷新
  20.   #--------------------------------------------------------------------------
  21.   def refresh
  22.     self.contents.clear
  23.     @item_max = $game_party.actors.size
  24.     for i in 0...$game_party.actors.size
  25.       x = 80 + (i * 110)
  26.       y = 420
  27.       actor = $game_party.actors[i]
  28.       file_name = i == self.index ?  "_2D" :  "_2D_2"
  29.       bitmap = Bitmap.new("Graphics/Menu/" + actor.id.to_s + file_name)
  30.       cw = bitmap.width
  31.       ch = bitmap.height
  32.       src_rect = Rect.new(0, 0, cw, ch)
  33.       self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
  34.     end
  35.   end
  36.   #--------------------------------------------------------------------------
  37.   # ● 刷新光标矩形
  38.   #--------------------------------------------------------------------------
  39.    def update_cursor_rect
  40.      if @index < 0
  41.        self.cursor_rect.empty
  42.      else
  43.        self.cursor_rect.set(0, @index * 116, self.width - 32, 96)
  44.      end
  45.    end
  46.   #--------------------------------------------------------------------------
  47.   # ● 刷新画面
  48.   #--------------------------------------------------------------------------
  49.   def update
  50.     # super 不用继承
  51.     # 可以移动光标的情况下
  52.     if self.active and @item_max > 0 and @index >= 0
  53.       # 方向键下被按下的情况下
  54.       if Input.repeat?(Input::DOWN)
  55.         # 列数不是 1 并且不与方向键下的按下状态重复的情况、
  56.         # 或光标位置在(项目数-列数)之前的情况下
  57.         if (@column_max == 1 and Input.trigger?(Input::DOWN)) or
  58.            @index < @item_max - @column_max
  59.           # 光标向下移动
  60.           $game_system.se_play($data_system.cursor_se)
  61.           @index = (@index + @column_max) % @item_max
  62.           refresh
  63.         end
  64.       end
  65.       # 方向键上被按下的情况下
  66.       if Input.repeat?(Input::UP)
  67.         # 列数不是 1 并且不与方向键下的按下状态重复的情况、
  68.         # 或光标位置在列之后的情况下
  69.         if (@column_max == 1 and Input.trigger?(Input::UP)) or
  70.            @index >= @column_max
  71.           # 光标向上移动
  72.           $game_system.se_play($data_system.cursor_se)
  73.           @index = (@index - @column_max + @item_max) % @item_max
  74.           # 刷新
  75.           refresh
  76.         end
  77.       end
  78.       # 方向键右被按下的情况下
  79.       if Input.repeat?(Input::RIGHT)
  80.         # 列数为 2 以上并且、光标位置在(项目数 - 1)之前的情况下
  81.         if @column_max >= 2 and @index < @item_max - 1
  82.           # 光标向右移动
  83.           $game_system.se_play($data_system.cursor_se)
  84.           @index += 1
  85.           # 刷新
  86.           refresh
  87.         end
  88.       end
  89.       # 方向键左被按下的情况下
  90.       if Input.repeat?(Input::LEFT)
  91.         # 列数为 2 以上并且、光标位置在 0 之后的情况下
  92.         if @column_max >= 2 and @index > 0
  93.           # 光标向左移动
  94.           $game_system.se_play($data_system.cursor_se)
  95.           @index -= 1
  96.           # 刷新
  97.           refresh
  98.         end
  99.       end
  100.       # R 键被按下的情况下
  101.       if Input.repeat?(Input::R)
  102.         # 显示的最后行在数据中最后行上方的情况下
  103.         if self.top_row + (self.page_row_max - 1) < (self.row_max - 1)
  104.           # 光标向后移动一页
  105.           $game_system.se_play($data_system.cursor_se)
  106.           @index = [@index + self.page_item_max, @item_max - 1].min
  107.           self.top_row += self.page_row_max
  108.           # 刷新
  109.           refresh
  110.         end
  111.       end
  112.       # L 键被按下的情况下
  113.       if Input.repeat?(Input::L)
  114.         # 显示的开头行在位置 0 之后的情况下
  115.         if self.top_row > 0
  116.           # 光标向前移动一页
  117.           $game_system.se_play($data_system.cursor_se)
  118.           @index = [@index - self.page_item_max, 0].max
  119.           self.top_row -= self.page_row_max
  120.           # 刷新
  121.           refresh
  122.         end
  123.       end
  124.     end
  125.     # 刷新帮助文本 (update_help 定义了继承目标)
  126.     if self.active and @help_window != nil
  127.       update_help
  128.     end
  129.     # 刷新光标矩形
  130.     update_cursor_rect
  131.   end
  132.   
  133.   #--------------------------------------------------------------------------
  134.   # ● 设置光标的位置
  135.   #     index : 新的光标位置
  136.   #--------------------------------------------------------------------------
  137.   def index=(index)
  138.     super(index)
  139.     # 刷新
  140.     refresh
  141.   end
  142. end
复制代码

评分

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

查看全部评分

回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
635
在线时间
5 小时
注册时间
2014-5-7
帖子
3
3
 楼主| 发表于 2015-9-26 13:09:09 | 只看该作者
cinderelmini 发表于 2015-9-25 23:57
唔……XP的机制怪怪的,好像只能搬运一下update的内容然后加refresh进去了。

没想到这么快就有回复了,啊啊啊感动哭了,和我想要的效果一模一样,看了简直醍醐灌顶,十分感谢!!!
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
635
在线时间
5 小时
注册时间
2014-5-7
帖子
3
4
 楼主| 发表于 2015-9-26 13:20:46 | 只看该作者
cinderelmini 发表于 2015-9-25 23:57
唔……XP的机制怪怪的,好像只能搬运一下update的内容然后加refresh进去了。

还有一个小小问题,我不太分得清refresh和update,请问怎么分辨他们呢?

点评

所以如果不是必要(比如时间窗口)的话,要在update加上各种条件,以本帖为例的话,就是按下各个方向键的时候才refresh一次,不然游戏进入菜单会很卡  发表于 2015-9-26 14:46
refresh一般是描绘窗口内容用的,因为描绘需要消耗机器资源,而且没必要持续描绘一样的东西。  发表于 2015-9-26 14:44
唔,一般来说,update是作为持续更新用的,像是窗口里的选项光框之类的,必须每帧都更新的东西。  发表于 2015-9-26 14:43
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-23 03:26

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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