赞 | 287 |
VIP | 11 |
好人卡 | 74 |
积分 | 226 |
经验 | 281171 |
最后登录 | 2024-11-17 |
在线时间 | 9415 小时 |
Lv5.捕梦者 (暗夜天使) 只有笨蛋才会看到
- 梦石
- 1
- 星屑
- 21636
- 在线时间
- 9415 小时
- 注册时间
- 2012-6-19
- 帖子
- 7118
|
本帖最后由 喵呜喵5 于 2016-11-17 17:16 编辑
- module M5Console20161117
- class Line < Sprite
- def initialize(height, offset, index, view=nil)
- super(view)
- @line_height = height
- @offset = offset
- self.bitmap = Bitmap.new(Graphics.width, height)
- self.index = index
- end
- def index=(index)
- self.y = (@offset + @line_height) * index
- end
- def draw(text = nil)
- self.bitmap.clear
- self.bitmap.draw_text(0,0,Graphics.width,@line_height,text) if text
- end
- def dispose
- super
- self.bitmap.dispose
- end
- end
- class Screen
- def initialize
- @lines = Array.new(line_total)do |i|
- Line.new(line_height, line_offset, i)
- end
- @index = 3
- end
- def line_total; 10; end
- def line_height; 24; end
- def line_offset; 1; end
- def draw(text)
- if @index == line_total
- @lines.push(@lines.shift)
- @lines.each_with_index{|l,i| l.index = i}
- @lines[@index-1].draw(text)
- else
- @lines[@index].draw(text)
- @index += 1
- end
- end
- def clear
- @index = 0
- @lines.each(&:draw)
- end
- def dispose
- @lines.each(&:dispose)
- end
- end
- # 测试界面
- class Scene < Scene_Base
- def start
- super
- @screen = Screen.new
- end
- def update
- super
- if Input.trigger?(:C)
- @screen.draw("本行内容#{rand}")
- end
- return_scene if Input.trigger?(:B)
- end
- def terminate
- super
- @screen.dispose
- end
- end
- def self.open
- SceneManager.call(Scene)
- end
- end
复制代码
稍微写了一段范例代码,用
M5Console20161117.open
打开界面看具体效果 |
|