赞 | 1 |
VIP | 7 |
好人卡 | 9 |
积分 | 1 |
经验 | 7021 |
最后登录 | 2014-11-30 |
在线时间 | 140 小时 |
Lv1.梦旅人 小黑
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 140 小时
- 注册时间
- 2011-8-23
- 帖子
- 536
|
怎么让他两边对称移动啊(而不是至移动一个方向)- #东方绯想天式飘动title
- class Window_Title < Window_Selectable
- #--------------------------------------------------------------------------
- # 定义常量
- #--------------------------------------------------------------------------
- AMP = -50 #幅度,正数为向右,负数为向左
- WAITTIME = 300 #等待时间,单位:帧
- SPEED = 300 #飘动速度,值越大越慢
- OX = [130,150,170] #初始横坐标
- LOADDATA = 1 #读档指令的位置,如果不使用无存档时变暗功能,把此项设为nil
- WAIT_PER_PERIOD = false #每次飘动完成后等待
- #--------------------------------------------------------------------------
- # 初始化
- #--------------------------------------------------------------------------
- def initialize(x = -16, y = 200)
- bitmap = Cache.system("title_command")
- @width = bitmap.width
- @height= bitmap.height
- super(x, y, Graphics.width - 2 * x, @height + 32)
- self.opacity = 0
- @index = 0
- @column_max = 1
- @item_max = OX.size
- @height /= @item_max
- @sprites = []
- OX.size.times do |index|
- sprite = Sprite.new
- sprite.bitmap = bitmap
- sprite.src_rect.set(0, @height * index, bitmap.width, @height)
- sprite.y = y + @height * index + 16
- sprite.x = OX[index]
- @sprites.push(sprite)
- end
- if LOADDATA and Dir.glob('Save*.rvdata').empty? #读档按钮不可用时的颜色修正,可以根据图片的特点来修改以取得比较好的视觉效果
- @sprites[LOADDATA].opacity = 128 #半透明
- @sprites[LOADDATA].tone = Tone.new(0,0,0,255) #灰度化
- end
- @move_x = []
- @wait_time = 0
- @move_index = [0,0,0,0]
- SPEED.times {|index|@move_x.push((Math.cos(Math::PI * index / SPEED * 2) * AMP).round - AMP)}
- update
- end
- #--------------------------------------------------------------------------
- # 更新
- #--------------------------------------------------------------------------
- def update
- last_index = @index
- super
- if @index != last_index
- @wait_time = 0
- @stopping = true
- end
- if @move_index.all? {|index|index == 0}
- if @wait_time > WAITTIME
- sprite_move(0)
- @wait_time = 0
- @stopping = true if WAIT_PER_PERIOD
- else
- @stopping = false
- @wait_time += 1
- end
- else
- sprite_move(0) unless @stopping and @move_index[0] == 0
- (1...OX.size).each {|index| sprite_move(index) if @move_index[index] != 0 or @move_index[index - 1] >= 30}
- end
- end
- #--------------------------------------------------------------------------
- # 释放(再定义)
- #--------------------------------------------------------------------------
- def dispose
- @sprites.each do |sprite|
- sprite.bitmap.dispose
- sprite.dispose
- end
- super
- end
- #--------------------------------------------------------------------------
- # ● 获取项目要描画的矩形
- # index : 项目编号
- #--------------------------------------------------------------------------
- def item_rect(index)
- return Rect.new(0,index * @height, self.contents.width, @height)
- end
- #--------------------------------------------------------------------------
- # 精灵的移动
- #--------------------------------------------------------------------------
- def sprite_move(index)
- @move_index[index] < SPEED - 1 ? @move_index[index] += 1 : @move_index[index] = 0
- @sprites[index].ox = @move_x[@move_index[index]]
- end
- end
复制代码 |
评分
-
查看全部评分
|