赞 | 0 |
VIP | 0 |
好人卡 | 0 |
积分 | 1 |
经验 | 1204 |
最后登录 | 2019-7-29 |
在线时间 | 55 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 55
- 在线时间
- 55 小时
- 注册时间
- 2010-9-29
- 帖子
- 41
|
LZ中午好,这次是关于窗口内容大小的一个问题
Window_Base 里面初始化时候有个步骤设置窗口内可以绘制内容的区域大小,这个大小必须是
BitMap.new(width - 32, height - 32)么?
我自己建了个window的子类,把contents的大小改大了,可是调用窗口时候仍然是按照(width - 32, height - 32)绘制文字的,还会有内容超出范围而没有绘制。是不是draw_text时候的原点都是窗口左上角向下向右各16PIX呢?还是我哪里弄错了?- class Window_Time < Window
- WLH = 24
- def initialize(x,y,width,height)
- super()
- self.windowskin = Cache.system("Window")
- self.x = x
- self.y = y
- self.width = width
- self.height = height
- self.z = 100
- self.back_opacity = 204
- self.openness = 255
- create_contents
- update
- end
- def create_contents
- self.contents.dispose
- self.contents = Bitmap.new(width - 14, height - 8)
- end
- def dispose
- self.contents.dispose
- super
- end
- def update
- super
- self.draw_time
- end
- def get_time
- result = []
- result[0] = Time.now.year
- result[1] = Time.now.mon
- result[2] = Time.now.day
- result[3] = Time.now.hour
- result[4] = Time.now.min
- result[5] = Time.now.sec
- result[6] = Time.now.wday
- return result
- end
- def text_color(n)
- x = 64 + (n % 8) * 8
- y = 96 + (n / 8) * 8
- return windowskin.get_pixel(x, y)
- end
- def draw_time
- text = self.timetex
- self.contents.clear
- self.contents.font.color = text_color(6)
- self.contents.draw_text(0, 0, self.width- 14, WLH, text, 1)
- end
- def timetex
- result = ""
- time1 = Time.now.strftime("%y/%m/%d")
- time2 = Time.now.strftime("%H:%M/%S")
- case Time.now.wday
- when 0
- a = "日"
- when 1
- a = "月"
- when 2
- a = "火"
- when 3
- a = "水"
- when 4
- a = "木"
- when 5
- a = "金"
- else
- a = "土"
- end
- result += time1 + "(" + a + ") "
- result += time2
- return result
- end
- end
复制代码 如果调用@window_time = Window_Time.new(0,0,224,32),很多内容就超出范围无法绘制。 |
|