赞 | 1 |
VIP | 20 |
好人卡 | 8 |
积分 | 3 |
经验 | 6181 |
最后登录 | 2022-8-5 |
在线时间 | 271 小时 |
Lv2.观梦者 神隐的主犯
- 梦石
- 0
- 星屑
- 299
- 在线时间
- 271 小时
- 注册时间
- 2008-2-22
- 帖子
- 7691
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
先发上脚本:
- ==============================================================================
- # ■ Window_Byz_NumberInput
- #------------------------------------------------------------------------------
- # 信息窗口内部使用、输入数值的窗口。
- #==============================================================================
- class Window_Byz_NumberInput < Window_Base
- #--------------------------------------------------------------------------
- # ● 初始化对象
- # digits_max : 行数
- #--------------------------------------------------------------------------
- def initialize(x, y, w, h)
- super(x, y, w, h)
- @w = w
- @x = x
- @y = y
- @h = h
- @digits_max = 8
- @number = []
- @index = 0
- @bitmap = Bitmap.new("Graphics/System/Number#{Byz_Vocab::NUMBER}")
- self.active = false
- @viewport = Viewport.new(x+16, [email protected] - 20, w-32, @bitmap.height + 10)
- #~ @viewport.visible = true
- #~ @viewport.color = Color.new(0,0,0,150)
- @viewport.z = 9999
- @sprite_number = []
- for i in 0...@digits_max
- @number[i] = 0
- @sprite_number[i] = Sprite.new(@viewport)
- @sprite_number[i].bitmap = @bitmap
- @sprite_number[i].visible = false
- end
- refresh
- update_cursor
- end
- #--------------------------------------------------------------------------
- # ● 获取行数
- #--------------------------------------------------------------------------
- def digits_max
- return @digits_max
- end
- #--------------------------------------------------------------------------
- # ● 设置行数
- # digits_max : 新行数
- #--------------------------------------------------------------------------
- def digits_max=(digits_max)
- @digits_max = digits_max
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 获取数值
- #--------------------------------------------------------------------------
- def number
- n = 0
- @number.each_index{|i| n += @number[i] * 10 ** i}
- return n
- end
- #--------------------------------------------------------------------------
- # ● 设置数值
- # number : 新数值
- #--------------------------------------------------------------------------
- def number=(number)
- n = [number, 0].max
- @index = 0
- @number = dew(n)
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 设置光标
- #--------------------------------------------------------------------------
- def index=(number)
- @index = ([number, -1].max) % @digits_max
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 光标向右移动
- # wrap : 允许跳过
- #--------------------------------------------------------------------------
- def cursor_right(wrap)
- if @index < @number.size - 1 or wrap
- @index = (@index + 1) % @digits_max
- end
- end
- #--------------------------------------------------------------------------
- # ● 光标向左移动
- # wrap : 允许跳过
- #--------------------------------------------------------------------------
- def cursor_left(wrap)
- if @index > 0 or wrap
- @index = (@index + @number.size - 1) % @number.size
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新画面
- #--------------------------------------------------------------------------
- def update
- if self.active
- n = @number[@index]
- if Input.repeat?(Input::UP)
- #~ n = ((n + 1) % 10)
- @number[@index] += 1
- @number[@index] = 0 if n == 9
- move_sprite(@sprite_number[@index], true)
- end
- if Input.repeat?(Input::DOWN)
- #~ n = (n + 9) % 10
- @number[@index] -= 1
- move_sprite(@sprite_number[@index], false)
- end
- refresh
- last_index = @index
- if Input.repeat?(Input::RIGHT)
- cursor_right(Input.trigger?(Input::RIGHT))
- end
- if Input.repeat?(Input::LEFT)
- cursor_left(Input.trigger?(Input::LEFT))
- end
- if @index != last_index
- Sound.play_cursor
- end
- update_cursor
- end
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- for i in 0...@digits_max
- show_sprite(@number[i], @sprite_number[i], @w - 32 - (i+1) * @bitmap.width / 10 - 8, 0)
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新光标
- #--------------------------------------------------------------------------
- def update_cursor
- self.cursor_rect.set(24 + @index * 16, 0, 16, WLH)
- end
- #--------------------------------------------------------------------------
- # ● 显示 Sprite
- #--------------------------------------------------------------------------
- def show_sprite(numbers, sprite, x, y)
- sprite.src_rect.set(@bitmap.width / 10 * numbers, 0, @bitmap.width / 10, @bitmap.height)
- sprite.x = x
- sprite.y = y
- sprite.visible = true
- end
- #--------------------------------------------------------------------------
- # ● 移动 Sprite
- # bool: 旋转方向
- # true 向上
- # false 向下
- #--------------------------------------------------------------------------
- def move_sprite(sprite, bool)
- old_sprite = Sprite.new(@viewport)
- old_sprite.visible = false
- old_sprite.bitmap = @bitmap
- old_sprite.x = sprite.x
- old_sprite.y = 0
- if bool
- old_sprite.src_rect.x = sprite.src_rect.x + @bitmap.width / 10
- old_sprite.src_rect.x = 0 if old_sprite.src_rect.x > @bitmap.width
- old_sprite.oy = [email protected]
- old_sprite.visible = true
- for i in [email protected]
- old_sprite.oy += 1
- old_sprite.oy = 0 if old_sprite.oy > 0
- sprite.oy += 1
- Graphics.update
- end
- sprite = nil
- sprite = Sprite.new(@viewport)
- sprite.bitmap = @bitmap
- sprite.x = old_sprite.x
- sprite.y = 0
- sprite.src_rect.x = old_sprite.src_rect.x
- old_sprite.visible = false
- old_sprite.bitmap = nil
- old_sprite = nil
- else
- old_sprite.src_rect.x = sprite.src_rect.x - @bitmap.width / 10
- old_sprite.src_rect.x = 0 if old_sprite.src_rect.x < 0
- old_sprite.oy = @bitmap.height
- old_sprite.visible = true
- for i in [email protected]
- old_sprite.oy -= 1
- old_sprite.oy = 0 if old_sprite.oy < 0
- sprite.oy -= 1
- Graphics.update
- end
- sprite.src_rect.x -= @bitmap.width / 10
- sprite.src_rect.x = 0 if sprite.src_rect.x < 0
- end
- #~ old_sprite.bitmap = nil
- #~ old_sprite = nil
- #~ sprite.visible = true
- end
- #--------------------------------------------------------------------------
- # ● 位拆分
- #--------------------------------------------------------------------------
- def dew(x)
- return unless x.is_a?(Integer)
- de = []
- i = x % 10
- while x >= 10
- i = x % 10
- de.push(i)
- x /= 10
- end
- de.push(x)
- return de
- end
- end
复制代码
这个是效果图:
请注意红色框,发现什么了吧??(我语文不好,所以就不多说了)
求解决办法?{/hx}{/hx}
可以的话,顺便把 index 的刷新也解决了吧{/hx}。
至于报酬什么的,请开价。 前提是我能付的起。{/hx} |
|