本帖最后由 guoxiaomi 于 2020-6-1 19:37 编辑
############################################################################### #######滚动式帮助窗口########################################################## #============================================================================== # ** Movement_Help #============================================================================== # modified by guoxiaomi 2020/05/31 # modified by guoxiaomi 2020/06/01 module Movement_Help Waits = [60, 60] # 移动前、后等待的帧数 Speed = 2 # 字幕移动的速度,像素/帧 Reverse = true # 到头后是否反着走 Start = 20 # 初始X坐标,不要改这个 end #============================================================================== # ■ Window_Help #------------------------------------------------------------------------------ # 特技及物品的说明、角色的状态显示的窗口。 #============================================================================== class Window_Help < Window_Base include Movement_Help alias _movement_initialize initialize def initialize _movement_initialize @sprite = Sprite.new end def set_text(text) if text != @text @text = text # use a default bitmap, since text_size == 0 cause error if @text == "" @sprite.bitmap = Bitmap.new(32, 32) @params = nil return end # create text bitmap width = self.contents.text_size(@text).width + 16 height = self.contents.text_size(@text).height @sprite.bitmap = Bitmap.new(width, height) @sprite.bitmap.draw_text(0, 0, width, height, @text) # set movement parameters @params = { :k => -Speed, :b => Start + Speed * Waits[0], :t => Waits[0] + (width + Start - self.width) / Speed + Waits[1], :r => Reverse, :max => Start, :min => self.width - width } # reset sprite position @sprite.x, @sprite.y, @sprite.z = @params[:max], 20, self.z + 1 @t = 0 end # calculate sprite.x return if !@params return if @params[:max] <= @params[:min] # calculate sprite.x if @params[:r] @t = (@t + 1) % (@params[:t] * 2) @sprite.x = (@params[:t] - (@t - @params[:t]).abs) * @params[:k] + @params[:b] else @t = (@t + 1) % @params[:t] @sprite.x = @t * @params[:k] + @params[:b] end @sprite.x = @params[:max] if @sprite.x > @params[:max] @sprite.x = @params[:min] if @sprite.x < @params[:min] end alias _movement_dispose dispose def dispose _movement_dispose @sprite.dispose end end
###############################################################################
#######滚动式帮助窗口##########################################################
#==============================================================================
# ** Movement_Help
#==============================================================================
# modified by guoxiaomi 2020/05/31
# modified by guoxiaomi 2020/06/01
module Movement_Help
Waits = [60, 60] # 移动前、后等待的帧数
Speed = 2 # 字幕移动的速度,像素/帧
Reverse = true # 到头后是否反着走
Start = 20 # 初始X坐标,不要改这个
end
#==============================================================================
# ■ Window_Help
#------------------------------------------------------------------------------
# 特技及物品的说明、角色的状态显示的窗口。
#==============================================================================
class Window_Help < Window_Base
include Movement_Help
alias _movement_initialize initialize
def initialize
_movement_initialize
@sprite = Sprite.new
end
def set_text(text)
if text != @text
@text = text
# use a default bitmap, since text_size == 0 cause error
if @text == ""
@sprite.bitmap = Bitmap.new(32, 32)
@params = nil
return
end
# create text bitmap
width = self.contents.text_size(@text).width + 16
height = self.contents.text_size(@text).height
@sprite.bitmap = Bitmap.new(width, height)
@sprite.bitmap.draw_text(0, 0, width, height, @text)
# set movement parameters
@params = {
:k => -Speed, :b => Start + Speed * Waits[0],
:t => Waits[0] + (width + Start - self.width) / Speed + Waits[1],
:r => Reverse, :max => Start, :min => self.width - width
}
# reset sprite position
@sprite.x, @sprite.y, @sprite.z = @params[:max], 20, self.z + 1
@t = 0
end
# calculate sprite.x
return if !@params
return if @params[:max] <= @params[:min]
# calculate sprite.x
if @params[:r]
@t = (@t + 1) % (@params[:t] * 2)
@sprite.x = (@params[:t] - (@t - @params[:t]).abs) * @params[:k] + @params[:b]
else
@t = (@t + 1) % @params[:t]
@sprite.x = @t * @params[:k] + @params[:b]
end
@sprite.x = @params[:max] if @sprite.x > @params[:max]
@sprite.x = @params[:min] if @sprite.x < @params[:min]
end
alias _movement_dispose dispose
def dispose
_movement_dispose
@sprite.dispose
end
end
稍微改了改,直接替换了原来的Window_Help,也不知道有没有其他后果
20200601 - fix bug,允许到头后反正移动 |