赞 | 287 |
VIP | 11 |
好人卡 | 74 |
积分 | 226 |
经验 | 281171 |
最后登录 | 2024-11-15 |
在线时间 | 9413 小时 |
Lv5.捕梦者 (暗夜天使) 只有笨蛋才会看到
- 梦石
- 1
- 星屑
- 21626
- 在线时间
- 9413 小时
- 注册时间
- 2012-6-19
- 帖子
- 7118
|
本帖最后由 喵呜喵5 于 2014-8-3 12:52 编辑
case的用法搞错了,你原本的代码中只有case when 0的时候才执行第二个draw_text方法,代码改成下面这样- def refresh
- self.contents.clear
- self.contents.draw_text(0, 0, 100, 24, "第#{$game_variables[98]}天")
- case $game_variables[99]
- when 3
- a1 = "深夜"
- when 2
- a1 = "夜晚"
- when 1
- a1 = "下午"
- when 0
- a1 = "上午"
- else
- a1 = nil
- end
- self.contents.draw_text(0, 32, 100, 24, a1) if a1
- end
复制代码 或者这样
def refresh self.contents.clear self.contents.draw_text(0, 0, 100, 24, "第#{$game_variables[98]}天") case $game_variables[99] when 3 a1 = "深夜" self.contents.draw_text(0, 32, 100, 24, a1) when 2 a1 = "夜晚" self.contents.draw_text(0, 32, 100, 24, a1) when 1 a1 = "下午" self.contents.draw_text(0, 32, 100, 24, a1) when 0 a1 = "上午" self.contents.draw_text(0, 32, 100, 24, a1) end end
def refresh
self.contents.clear
self.contents.draw_text(0, 0, 100, 24, "第#{$game_variables[98]}天")
case $game_variables[99]
when 3
a1 = "深夜"
self.contents.draw_text(0, 32, 100, 24, a1)
when 2
a1 = "夜晚"
self.contents.draw_text(0, 32, 100, 24, a1)
when 1
a1 = "下午"
self.contents.draw_text(0, 32, 100, 24, a1)
when 0
a1 = "上午"
self.contents.draw_text(0, 32, 100, 24, a1)
end
end
另外描绘文字需要花费一定的时间,因此refresh不建议放到update里面实时刷新,只有当这两个变量发生改变的时候再刷新 |
评分
-
查看全部评分
|