说一下思路,先判断一行能放多上字节的字,把字符按一行放多少的字符拆成数组,再一个小 循环写上去....我临时写了个640*480的help窗口,没优化,有时间优化一下... #============================================================================== # ■ Window_Help2 #------------------------------------------------------------------------------ # 特技及物品的说明、角色的状态显示的窗口。 #============================================================================== class Window_Help2 < Window_Base #-------------------------------------------------------------------------- # ● 初始化对像 #-------------------------------------------------------------------------- def initialize super(0, 0, 640, 480) self.contents = Bitmap.new(width - 32, height - 32) end #-------------------------------------------------------------------------- # ● 设置文本 # text : 窗口显示的字符串 # align : 对齐方式 (0..左对齐、1..中间对齐、2..右对齐) #-------------------------------------------------------------------------- def set_text(text, align = 0) # 如果文本和对齐方式的至少一方与上次的不同 if text != @text or align != @align # 再描绘文本 self.contents.clear self.contents.font.color = normal_color text_size = 60 # 判断行数 22号字体,640长度,用70字节,但为保证不出问题,用60字节 line = text.size / text_size + 1 loop do if line * text_size > text.size text += " " else break end end text_arr = [] for i in 0...line text_arr.push(text[i*text_size...(i+1)*text_size]) end for i in 0...text_arr.size p text_arr[i].size self.contents.draw_text(4, i*32, self.width , 32, text_arr[i], align) end @text = text @align = align @actor = nil end self.visible = true end #-------------------------------------------------------------------------- # ● 设置角色 # actor : 要显示状态的角色 #-------------------------------------------------------------------------- def set_actor(actor) if actor != @actor self.contents.clear draw_actor_name(actor, 4, 0) draw_actor_state(actor, 140, 0) draw_actor_hp(actor, 284, 0) draw_actor_sp(actor, 460, 0) @actor = actor @text = nil self.visible = true end end #-------------------------------------------------------------------------- # ● 设置敌人 # enemy : 要显示名字和状态的敌人 #-------------------------------------------------------------------------- def set_enemy(enemy) text = enemy.name state_text = make_battler_state_text(enemy, 112, false) if state_text != "" text += " " + state_text end set_text(text, 1) end end |
呃……能把你现在用的脚本发出来么 |
站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作
GMT+8, 2024-12-25 00:17
Powered by Discuz! X3.1
© 2001-2013 Comsenz Inc.