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

Project1

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

[已经过期] 修改内建NameInput

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
72 小时
注册时间
2008-10-27
帖子
70
跳转到指定楼层
1
发表于 2014-6-26 13:29:03 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 IRO 于 2014-6-26 13:31 编辑

我修改了RGSS里的Window_NameInput,想改成只有26个字母
但是光标上下移动的时后变得不正常......希望有高人能教我该怎么改OTZ

RUBY 代码复制
  1. #==============================================================================
  2. # ■ Window_NameInput
  3. #------------------------------------------------------------------------------
  4. #  輸入名稱的畫面、文字選擇視窗。
  5. #==============================================================================
  6.  
  7. class Window_NameInput < Window_Base
  8.   CHARACTER_TABLE =
  9.   [
  10.     "A","B","C","D","E",
  11.     "F","G","H","I","J",
  12.     "K","L","M","N","O",
  13.     "P","Q","R","S","T",
  14.     "U","V","W","X","Y",
  15.     "Z",
  16.   ]
  17.   #--------------------------------------------------------------------------
  18.   # ● 初始化物件
  19.   #--------------------------------------------------------------------------
  20.   def initialize
  21.     super(340, 160, 180, 260)
  22.     self.contents = Bitmap.new(width - 32, height - 32)
  23.     @index = 0
  24.     refresh
  25.     update_cursor_rect
  26.   end
  27.   #--------------------------------------------------------------------------
  28.   # ● 獲取文字
  29.   #--------------------------------------------------------------------------
  30.   def character
  31.     return CHARACTER_TABLE[@index]
  32.   end
  33.   #--------------------------------------------------------------------------
  34.   # ● 更新
  35.   #--------------------------------------------------------------------------
  36.   def refresh
  37.     self.contents.clear
  38.     for i in 0..25
  39.       x = 1 + i / 5 / 6 * 152 + i % 5 * 28
  40.       y = i / 5 % 6 * 32
  41.       self.contents.draw_text(x, y, 28, 32, CHARACTER_TABLE[i], 1)
  42.     end
  43.     self.contents.draw_text(80, 6 * 32, 64, 32, "Finish", 1)
  44.   end
  45.   #--------------------------------------------------------------------------
  46.   # ● 更新游標矩形
  47.   #--------------------------------------------------------------------------
  48.   def update_cursor_rect
  49.     # 游標位置在 [確定] 的情況下
  50.     if @index >= 26
  51.       self.cursor_rect.set(80, 9 * 32, 64, 32)
  52.     # 游標位置在 [確定] 以外的情況下
  53.     else
  54.       x = 1 + @index / 5 / 9 * 152 + @index % 5 * 28
  55.       y = @index / 5 % 9 * 32
  56.       self.cursor_rect.set(x, y, 28, 32)
  57.     end
  58.   end
  59.   #--------------------------------------------------------------------------
  60.   # ● 更新畫面
  61.   #--------------------------------------------------------------------------
  62.   def update
  63.     super
  64.     # 游標位置在 [確定] 的情況下
  65.     if @index >= 180
  66.       # 游標下
  67.       if Input.trigger?(Input::DOWN)
  68.         $game_system.se_play($data_system.cursor_se)
  69.         @index -= 180
  70.       end
  71.       # 游標上
  72.       if Input.repeat?(Input::UP)
  73.         $game_system.se_play($data_system.cursor_se)
  74.         @index -= 180 - 40
  75.       end
  76.     # 游標位置在 [確定] 以外的情況下
  77.     else
  78.       # 按下方向鍵右的情況下
  79.       if Input.repeat?(Input::RIGHT)
  80.         # 按下狀態不是重複的情況下、
  81.         # 游標位置不在右端的情況下
  82.         if Input.trigger?(Input::RIGHT) or
  83.            @index / 30 < 3 or @index % 5 < 4
  84.           # 游標向右移動
  85.           $game_system.se_play($data_system.cursor_se)
  86.           if @index % 5 < 4
  87.             @index += 1
  88.           else
  89.             @index += 30 - 4
  90.           end
  91.           if @index >= 180
  92.             @index -= 180
  93.           end
  94.         end
  95.       end
  96.       # 按下方向鍵左的情況下
  97.       if Input.repeat?(Input::LEFT)
  98.         # 按下狀態不是重複的情況下、
  99.         # 游標位置不在左端的情況下
  100.         if Input.trigger?(Input::LEFT) or
  101.            @index / 30 > 0 or @index % 5 > 0
  102.           # 游標向右移動
  103.           $game_system.se_play($data_system.cursor_se)
  104.           if @index % 5 > 0
  105.             @index -= 1
  106.           else
  107.             @index -= 30 - 4
  108.           end
  109.           if @index < 0
  110.             @index += 180
  111.           end
  112.         end
  113.       end
  114.       # 按下方向鍵下的情況下
  115.       if Input.repeat?(Input::DOWN)
  116.         # 游標向下移動
  117.         $game_system.se_play($data_system.cursor_se)
  118.         if @index % 30 < 25
  119.           @index += 5
  120.         else
  121.           @index += 180 - 40
  122.         end
  123.       end
  124.       # 按下方向鍵上的情況下
  125.       if Input.repeat?(Input::UP)
  126.         # 按下狀態不是重複的情況下、
  127.         # 游標位置不在上端的情況下
  128.         if Input.trigger?(Input::UP) or @index % 30 >= 5
  129.           # 游標向上移動
  130.           $game_system.se_play($data_system.cursor_se)
  131.           if @index % 30 >= 5
  132.             @index -= 5
  133.           else
  134.             @index += 180
  135.           end
  136.         end
  137.       end
  138.       # L 鍵與 R 鍵被按下的情況下
  139.       if Input.repeat?(Input::L) or Input.repeat?(Input::R)
  140.         # 平假名 / 片假名 之間移動
  141.         $game_system.se_play($data_system.cursor_se)
  142.         if @index / 30 < 2
  143.           @index += 90
  144.         else
  145.           @index -= 90
  146.         end
  147.       end
  148.     end
  149.     update_cursor_rect
  150.   end
  151. end

Lv2.观梦者

无节操

梦石
0
星屑
607
在线时间
795 小时
注册时间
2009-2-6
帖子
3939

开拓者贵宾

2
发表于 2014-6-26 13:38:37 | 只看该作者
不要修改原有的格式,只删改引号里的内容即可。
如果修改引号数目,会导致底下的许多数据都要修改,得不偿失。

点评

IRO
只是個解謎環節不是要取名,所以倒不需要小寫~  发表于 2014-6-26 14:28
IRO
刚刚试着把引号加回来,因为屏幕改小了所以光标会跑到屏幕外...有办法让它被忽略吗?><  发表于 2014-6-26 14:27
moy
况且,你难道不需要小写吗(  发表于 2014-6-26 14:20
moy
那些引号对应的就相当于屏幕中的位置,并且空的引号在光标移动时会被忽略,好好利用这点应该可以排版出来。  发表于 2014-6-26 14:20
IRO
呃...我想得的部分是版面会美观很多? 不需要那么多引号,有办法的话还是想改掉...  发表于 2014-6-26 14:15
Brandnew day, Brandnew Life
                              实在  中
暂为素材区版主,版其  琢磨
应援一下~
RPG制作大师授权素材推广计划
回复 支持 反对

使用道具 举报

Lv2.观梦者

无节操

梦石
0
星屑
607
在线时间
795 小时
注册时间
2009-2-6
帖子
3939

开拓者贵宾

3
发表于 2014-6-26 14:48:50 | 只看该作者
你改了分辨率的话,那只好都改了
修改引号数目以及坐标的话,这个页面里几乎所有牵扯到index的都需要调整。
不太清楚你要的效果,但最主要的是牵扯到这两段的刷新。
  1.   #--------------------------------------------------------------------------
  2.   # ● 更新
  3.   #--------------------------------------------------------------------------
  4.   def refresh
  5.     self.contents.clear
  6.     for i in 0..25
  7.       x = 1 + i / 5 / 6 * 152 + i % 5 * 28
  8.       y = i / 5 % 6 * 32
  9.       self.contents.draw_text(x, y, 28, 32, CHARACTER_TABLE[i], 1)
  10.     end
  11.     self.contents.draw_text(80, 6 * 32, 64, 32, "Finish", 1)
  12.   end
  13.   #--------------------------------------------------------------------------
  14.   # ● 更新游標矩形
  15.   #--------------------------------------------------------------------------
  16.   def update_cursor_rect
  17.     # 游標位置在 [確定] 的情況下
  18.     if @index >= 26
  19.       self.cursor_rect.set(80, 9 * 32, 64, 32)
  20.     # 游標位置在 [確定] 以外的情況下
  21.     else
  22.       x = 1 + @index / 5 / 9 * 152 + @index % 5 * 28
  23.       y = @index / 5 % 9 * 32
  24.       self.cursor_rect.set(x, y, 28, 32)
  25.     end
  26.   end
复制代码
这里有很多尺寸相关的数据,按照你的大小改吧。这个得自己调试才知道效果如何。

评分

参与人数 1星屑 +10 收起 理由
RyanBern + 10 塞糖

查看全部评分

Brandnew day, Brandnew Life
                              实在  中
暂为素材区版主,版其  琢磨
应援一下~
RPG制作大师授权素材推广计划
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-30 23:25

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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