Project1

标题: 如何自动对话? [打印本页]

作者: pocket梦幻    时间: 2011-2-8 19:57
标题: 如何自动对话?
就是每次npc说完话之后..要按回车才能结束对话.....我想弄一段例如回忆的东西....NPC说完话自己就结束对话了...怎么弄?
作者: 塞巴斯特    时间: 2011-2-8 20:17
自动执行
显示文章-NPC:XXXXXXXXX
显示文章-主角:YYYYYYYYY
显示文章-NPC:ZZZZZZZZZ
独立开关A为ON

创建一个当独立开关A为ON的事件页
决定键执行
内容空白= =


作者: 凯蒂洛斯    时间: 2011-2-8 20:38
用66对话加强,插入以后里面有说明 记得|\好像是文字直接消失...

作者: z121310    时间: 2011-2-8 20:59
本帖最后由 fux2 于 2011-2-10 08:49 编辑

貌似在北欧海盗前辈的《福尔摩斯R剧》里用的就是NPC对话自动转换的脚本

脚本内容:
复制以下内容
  1. #==============================================================================
  2. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  3. #==============================================================================  


  4. #——说明

  5. #默认为一个字一个字的方式,如果需要一次全部显示,
  6. #请在游戏中使用脚本:$game_system.typing = true
  7.   
  8. #默认对话字没有声音,如果需要声音,
  9. #请在游戏中使用脚本:$game_system.soundname_on_speak = "这里输入文件名"
  10. #我唯一一个见过“胡乱配音”的游戏是天使帝国2代,该游戏说话的时候每个字符随机发一个外星语音

  11. # 其他在对话中可以使用的功能:
  12.   
  13. # \n[1]:显示1号角色的姓名

  14. # \name[李逍遥]:显示一个“李逍遥”方框,表示说话人姓名

  15. # \p[1]:对话框出现在1号事件的上方
  16. # \p[0]:主人公上方出现对话框
  17. #——————————————————使用\p功能后可以自动调整对话框大小

  18. # \\:显示"\"这个符号

  19. # \c[1-8]:更改颜色

  20. # \g:显示金钱窗口

  21. # \a[SE文件名]:对话的时候播放SE

  22. # \s[1-19]:更改弹字的速度

  23. # \. :停顿一刹那(1、2帧)
  24. # \| :停顿片刻(20帧)

  25. # \> :文字不用打字方式
  26. # \< :文字使用打字方式

  27. # \! :等待玩家按回车再继续
  28. # \~ :文字直接消失

  29. # \I :下一行从这个位置开始

  30. # \o[123]:文字透明度改为123,模拟将死之人(汗)

  31. # \h[12]:改用12号字

  32. # \b[50]:空50象素

  33. # \K[今天天气不错]:在出现“今天天气不错”这几个字的时候播放$game_system.soundname_on_speak设置的音效

  34. # \L[001]:在左边显示图片“Graphics/battlers/66rpg_001_h.png”
  35. # \R[001]:在右边显示图片“Graphics/battlers/66rpg_001_h.png”

  36. # \Lk:清除左边的图像
  37. # \Rk:清除右边的图像
  38. # \M[60]:等待60帧文字直接消失

  39. #脚本冲突可能:
  40. #不用说了。因为改了分辨率所有原有窗口需要自己定义,基本上可以算是和所有脚本冲突。

  41. #============================
  42. class Game_System
  43. attr_accessor :typing
  44. attr_accessor :soundname_on_speak
  45. alias carol3_ini initialize
  46. def initialize
  47. carol3_ini
  48. @typing = true
  49. @soundname_on_speak = nil
  50. end
  51. end
  52. #=================================
  53. #==============================================================================
  54. # ■ Window_Message
  55. #------------------------------------------------------------------------------
  56. class Window_Message < Window_Selectable
  57. #--------------------------------------------------------------------------
  58. # ● 初始化状态
  59. #--------------------------------------------------------------------------
  60. def initialize
  61. super(80, 304, 480, 160)
  62. self.contents = Bitmap.new(width - 32, height - 32)
  63. self.visible = false
  64. self.z = 9998
  65. @fade_in = false
  66. @fade_out = false
  67. @contents_showing = false
  68. @cursor_width = 0
  69. @autoclosetime = -1
  70. self.active = false
  71. self.index = -1
  72. if $game_system.soundname_on_speak == nil then
  73. $game_system.soundname_on_speak = ""
  74. end
  75. @opacity_text_buf = Bitmap.new(32, 32)
  76. end
  77. #--------------------------------------------------------------------------
  78. # ● 释放
  79. #--------------------------------------------------------------------------
  80. def dispose
  81. terminate_message
  82. $game_temp.message_window_showing = false
  83. if @input_number_window != nil
  84. @input_number_window.dispose
  85. end
  86. super
  87. end
  88. #--------------------------------------------------------------------------
  89. # ● 处理信息结束
  90. #--------------------------------------------------------------------------
  91. def terminate_message
  92. self.active = false
  93. self.pause = false
  94. self.index = -1
  95. self.contents.clear
  96. # 清除显示中标志
  97. @contents_showing = false
  98. # 呼叫信息调用
  99. if $game_temp.message_proc != nil
  100. $game_temp.message_proc.call
  101. end
  102. # 清除文章、选择项、输入数值的相关变量
  103. $game_temp.message_text = nil
  104. $game_temp.message_proc = nil
  105. $game_temp.choice_start = 99
  106. $game_temp.choice_max = 0
  107. $game_temp.choice_cancel_type = 0
  108. $game_temp.choice_proc = nil
  109. $game_temp.num_input_start = 99
  110. $game_temp.num_input_variable_id = 0
  111. $game_temp.num_input_digits_max = 0
  112. # 开放金钱窗口
  113. if @gold_window != nil
  114. @gold_window.dispose
  115. @gold_window = nil
  116. end
  117. if @name_window_frame != nil
  118. @name_window_frame.dispose
  119. @name_window_frame = nil
  120. end
  121. if @name_window_text != nil
  122. @name_window_text.dispose
  123. @name_window_text = nil
  124. end
  125. if @right_picture != nil and @right_keep == true
  126. @right_picture.dispose
  127. end  
  128. if @left_picture != nil and @left_keep == true
  129. @left_picture.dispose
  130. end
  131. end
  132. def refresh
  133. # 初期化
  134. self.contents.clear
  135. self.contents.font.color = normal_color
  136. self.contents.font.size = Font.default_size
  137. @x = @y = @max_x = @max_y = @indent = @lines = 0
  138. @left_keep = @right_keep = false
  139. @face_indent = 0
  140. @opacity = 255
  141. @cursor_width = 0
  142. @autoclosetime = -1
  143. @write_speed = 0
  144. @write_wait = 0
  145. @mid_stop = false
  146. @face_file = nil
  147. @popchar = -2
  148. if $game_temp.choice_start == 0
  149. @x = 8
  150. end
  151. if $game_temp.message_text != nil
  152. @now_text = $game_temp.message_text
  153. #——头像设置
  154. if (/\\[Ff]\[(.+?)\]/.match(@now_text))!=nil then
  155. @face_file = $1 + ".png"
  156. @x = @face_indent = 128
  157. if FileTest.exist?("Graphics/Pictures/" + $1 + ".png")
  158. self.contents.blt(16, 16, RPG::Cache.picture(@face_file), Rect.new(0, 0, 96, 96))
  159. end
  160. @now_text.gsub!(/\\[Ff]\[(.*?)\]/) { "" }
  161. end
  162. #——左半身像设置
  163. if (/\\[Ll]\[(.+?)\]/.match(@now_text))!=nil then
  164. @face = "66rpg_" + $1 + "_h.png"
  165. if $加密 == true
  166. if @left_picture != nil
  167. @left_picture.dispose
  168. end
  169. @left_picture = Sprite.new
  170. @left_picture.bitmap = Bitmap.new("Graphics/battlers/#{@face}")
  171. @left_picture.y = [email]480-@left_picture.bitmap.height[/email]
  172. @left_picture.x = 0
  173. @left_picture.mirror = true
  174. @now_text.gsub!(/\\[Ll]\[(.*?)\]/) { "" }
  175. else  
  176. if FileTest.exist?("Graphics/battlers/#{@face}")
  177. if @left_picture != nil
  178. @left_picture.dispose
  179. end
  180. @left_picture = Sprite.new
  181. @left_picture.bitmap = Bitmap.new("Graphics/battlers/#{@face}")
  182. @left_picture.y = [email]480-@left_picture.bitmap.height[/email]
  183. @left_picture.x = 0
  184. @left_picture.mirror = true
  185. @now_text.gsub!(/\\[Ll]\[(.*?)\]/) { "" }
  186. end
  187. end  
  188. end
  189. #——右半身像设置
  190. if (/\\[Rr]\[(.+?)\]/.match(@now_text))!=nil then
  191. @face = "66rpg_" + $1 + "_h.png"
  192. if $加密 == true
  193. if @right_picture != nil
  194. @right_picture.dispose
  195. end
  196. @right_picture = Sprite.new
  197. @right_picture.bitmap = Bitmap.new("Graphics/battlers/#{@face}")
  198. @right_picture.y = [email]480-@right_picture.bitmap.height[/email]
  199. @right_picture.x = [email]640-@right_picture.bitmap.width[/email]
  200. @now_text.gsub!(/\\[Rr]\[(.*?)\]/) { "" }
  201. else
  202. if FileTest.exist?("Graphics/battlers/#{@face}")
  203. if @right_picture != nil
  204. @right_picture.dispose
  205. end
  206. @right_picture = Sprite.new
  207. @right_picture.bitmap = Bitmap.new("Graphics/battlers/#{@face}")
  208. @right_picture.y = [email]480-@right_picture.bitmap.height[/email]
  209. @right_picture.x = [email]640-@right_picture.bitmap.width[/email]
  210. @now_text.gsub!(/\\[Rr]\[(.*?)\]/) { "" }
  211. end
  212. end
  213. end
  214. if (/\\[Rr]k/.match(@now_text)) != nil
  215. @right_keep = true
  216. @now_text.sub!(/\\[Rr]k/) { "" }
  217. end
  218. if (/\\[Ll]k/.match(@now_text)) != nil
  219. @left_keep = true
  220. @now_text.sub!(/\\[Ll]k/) { "" }
  221. end
  222. # 显示人物姓名
  223. name_window_set = false
  224. if (/\\[Nn]ame\[(.+?)\]/.match(@now_text)) != nil
  225. name_window_set = true
  226. name_text = $1
  227. @now_text.sub!(/\\[Nn]ame\[(.*?)\]/) { "" }
  228. end
  229.   
  230. # 文字位置的判定
  231. if (/\\[Pp]\[([-1,0-9]+)\]/.match(@now_text))!=nil then
  232. @popchar = $1.to_i
  233. if @popchar == -1
  234. @x = @indent = 48
  235. @y = 4
  236. end
  237. @now_text.gsub!(/\\[Pp]\[([-1,0-9]+)\]/) { "" }
  238. end
  239.   
  240. # 开始
  241. begin
  242. last_text = @now_text.clone
  243. @now_text.gsub!(/\\[Vv]\[([IiWwAaSs]?)([0-9]+)\]/) { convart_value($1, $2.to_i) }
  244. end until @now_text == last_text
  245. @now_text.gsub!(/\\[Nn]\[([0-9]+)\]/) do
  246. $game_actors[$1.to_i] != nil ? $game_actors[$1.to_i].name : ""
  247. end
  248. @now_text.gsub!(/\\\\/) { "\000" }
  249. @now_text.gsub!(/\\[Cc]\[([0-9]+)\]/) { "\001[#{$1}]" }
  250. @now_text.gsub!(/\\[Gg]/) { "\002" }
  251. @now_text.gsub!(/\\[Ss]\[([0-9]+)\]/) { "\003[#{$1}]" }
  252. @now_text.gsub!(/\\[Aa]\[(.*?)\]/) { "\004[#{$1}]" }
  253. @now_text.gsub!(/\\[.]/) { "\005" }
  254. @now_text.gsub!(/\\[|]/) { "\006" }
  255. @now_text.gsub!(/\\[Mm]\[([0-9]+)\]/) { "\050[#{$1}]" }
  256.   
  257. @now_text.gsub!(/\\[>]/) { "\016" }
  258. @now_text.gsub!(/\\[<]/) { "\017" }
  259. @now_text.gsub!(/\\[!]/) { "\020" }
  260. @now_text.gsub!(/\\[~]/) { "\021" }
  261.   
  262. @now_text.gsub!(/\\[Ii]/) { "\023" }
  263. @now_text.gsub!(/\\[Oo]\[([0-9]+)\]/) { "\024[#{$1}]" }
  264. @now_text.gsub!(/\\[Hh]\[([0-9]+)\]/) { "\025[#{$1}]" }
  265. @now_text.gsub!(/\\[Bb]\[([0-9]+)\]/) { "\026[#{$1}]" }
  266. @now_text.gsub!(/\\[Kk]\[(.*?)\]/) { "\027[#{$1}]" }
  267. if @popchar >= 0
  268. @text_save = @now_text.clone
  269. @max_x = 0
  270. @max_y = 4
  271. for i in 0..3
  272. line = @now_text.split(/\n/)[3-i]
  273. @max_y -= 1 if line == nil and @max_y <= 4-i
  274. next if line == nil
  275. cx = contents.text_size(line).width
  276. @max_x = cx if cx > @max_x
  277. end
  278. self.width = @max_x + 48 + @face_indent
  279. self.height = (@max_y - 1) * 32 + 64
  280. else
  281. @max_x = self.width - 32 - @face_indent
  282. end
  283. reset_window
  284. if name_window_set
  285. off_x = 0
  286. off_y = -40
  287. space = 2
  288. x = self.x + off_x - space / 2
  289. y = self.y + off_y - space / 2
  290. w = self.contents.text_size(name_text).width + 26 + space
  291. h = 40 + space
  292. @name_window_frame = Window_Frame.new(x, y, w, h)
  293. @name_window_frame.z = self.z + 1
  294. x = self.x + off_x + 4
  295. y = self.y + off_y
  296. @name_window_text = Air_Text.new(x+4, y+6, name_text)
  297. @name_window_text.z = self.z + 2
  298. end
  299. end
  300. reset_window
  301. if $game_temp.choice_max > 0
  302. @item_max = $game_temp.choice_max
  303. self.active = true
  304. self.index = 0
  305. end
  306. if $game_temp.num_input_variable_id > 0
  307. digits_max = $game_temp.num_input_digits_max
  308. number = $game_variables[$game_temp.num_input_variable_id]
  309. @input_number_window = Window_InputNumber.new(digits_max)
  310. @input_number_window.number = number
  311. @input_number_window.x = self.x + 8
  312. @input_number_window.y = self.y + $game_temp.num_input_start * 32
  313. end
  314. end
  315. #--------------------------------------------------------------------------
  316. # ● 更新
  317. #--------------------------------------------------------------------------
  318. def update
  319. super
  320. if @autoclosetime == 0
  321. @autoclosetime = -1
  322. terminate_message
  323. end
  324. if @autoclosetime >= 1
  325. @autoclosetime -= 1
  326. end
  327. if @fade_in
  328. self.contents_opacity += 24
  329. if @input_number_window != nil
  330. @input_number_window.contents_opacity += 24
  331. end
  332. if self.contents_opacity == 255
  333. @fade_in = false
  334. end
  335. return
  336. end
  337. @now_text = nil if @now_text == ""  
  338.   
  339. if @now_text != nil and @mid_stop == false
  340. if @write_wait > 0
  341. @write_wait -= 1
  342. return
  343. end
  344. text_not_skip = $game_system.typing
  345. while true
  346. @max_x = @x if @max_x < @x
  347. @max_y = @y if @max_y < @y
  348. if (c = @now_text.slice!(/./m)) != nil
  349. if c == "\000"
  350. c = "\\"
  351. end
  352. if c == "\001"
  353. @now_text.sub!(/\[([0-9]+)\]/, "")
  354. color = $1.to_i
  355. if color >= 0 and color <= 7
  356. self.contents.font.color = text_color(color)
  357. end
  358. c = ""
  359. end
  360. if c == "\002"
  361. if @gold_window == nil and @popchar <= 0
  362. @gold_window = Window_Gold.new
  363. @gold_window.x = 560 - @gold_window.width
  364. if $game_temp.in_battle
  365. @gold_window.y = 192
  366. else
  367. @gold_window.y = self.y >= 128 ? 32 : 384
  368. end
  369. @gold_window.opacity = self.opacity
  370. @gold_window.back_opacity = self.back_opacity
  371. end
  372. c = ""
  373. end
  374. if c == "\003"
  375. @now_text.sub!(/\[([0-9]+)\]/, "")
  376. speed = $1.to_i
  377. if speed >= 0 and speed <= 19
  378. @write_speed = speed
  379. end
  380. c = ""
  381. end
  382. if c == "\004"
  383. @now_text.sub!(/\[(.*?)\]/, "")
  384. buftxt = $1.dup.to_s
  385. if buftxt.match(/\//) == nil and buftxt != "" then
  386. $game_system.soundname_on_speak = "Audio/SE/" + buftxt
  387. else
  388. $game_system.soundname_on_speak = buftxt.dup
  389. end
  390. c = ""
  391. elsif c == "\004"  
  392. c = ""
  393. end
  394. if c == "\005"
  395. @write_wait += 5
  396. c = ""
  397. end
  398. if c == "\006"
  399. @write_wait += 20
  400. c = ""
  401. end
  402. if c == "\016"
  403. text_not_skip = false
  404. c = ""
  405. end
  406. if c == "\017"
  407. text_not_skip = true
  408. c = ""
  409. end
  410. if c == "\020"
  411. @mid_stop = true
  412. c = ""
  413. end
  414. if c == "\021"
  415. terminate_message
  416. return
  417. end
  418. if c == "\023"
  419. @indent = @x
  420. c = ""
  421. end
  422. if c == "\024"
  423. @now_text.sub!(/\[([0-9]+)\]/, "")
  424. @opacity = $1.to_i
  425. c = ""
  426. end
  427. if c == "\025"
  428. @now_text.sub!(/\[([0-9]+)\]/, "")
  429. self.contents.font.size = [[$1.to_i, 6].max, 32].min
  430. c = ""
  431. end
  432. if c == "\026"
  433. @now_text.sub!(/\[([0-9]+)\]/, "")
  434. @x += $1.to_i
  435. c = ""
  436. end
  437. if c == "\027"
  438. @now_text.sub!(/\[(.*?)\]/, "")
  439. @x += ruby_draw_text(self.contents, @x, @y * line_height + (line_height - self.contents.font.size), $1, @opacity)
  440. if $game_system.soundname_on_speak != ""
  441. Audio.se_play($game_system.soundname_on_speak)
  442. end
  443. c = ""
  444. end
  445. if c == "\030"
  446. @now_text.sub!(/\[(.*?)\]/, "")
  447. self.contents.blt(@x , @y * line_height + 8, RPG::Cache.icon($1), Rect.new(0, 0, 24, 24))
  448. if $game_system.soundname_on_speak != ""
  449. Audio.se_play($game_system.soundname_on_speak)
  450. end
  451. @x += 24
  452. c = ""
  453. end
  454. if c == "\050"

  455. @now_text.sub!(/\[([0-9]+)\]/, "")

  456. @autoclosetime = $1.to_i

  457. next

  458. end
  459. if c == "\n"
  460. if @lines >= $game_temp.choice_start
  461. @cursor_width = [@cursor_width, @max_x - @face_indent].max
  462. end
  463. @lines += 1
  464. @y += 1
  465. @x = 0 + @indent + @face_indent
  466. if @lines >= $game_temp.choice_start
  467. @x = 8 + @indent + @face_indent
  468. end
  469. c = ""
  470. end
  471. if c != ""
  472. # 文字描画
  473. @x += opacity_draw_text(self.contents, @x, @y * line_height + (line_height - self.contents.font.size), c, @opacity)
  474. if $game_system.soundname_on_speak != "" then
  475. Audio.se_play($game_system.soundname_on_speak)
  476. end
  477. end
  478. if Input.press?(Input::B)
  479. text_not_skip = false
  480. end
  481. else
  482. text_not_skip = true
  483. break
  484. end
  485. # 终了判定
  486. if text_not_skip
  487. break
  488. end
  489. end
  490. @write_wait += @write_speed
  491. return
  492. end
  493. if @input_number_window != nil
  494. @input_number_window.update
  495. # 决定
  496. if Input.trigger?(Input::C)
  497. $game_system.se_play($data_system.decision_se)
  498. $game_variables[$game_temp.num_input_variable_id] =
  499. @input_number_window.number
  500. $game_map.need_refresh = true
  501. @input_number_window.dispose
  502. @input_number_window = nil
  503. terminate_message
  504. end
  505. return
  506. end
  507. if @contents_showing
  508. if $game_temp.choice_max == 0
  509. self.pause = true
  510. end
  511. # 取消
  512. if Input.trigger?(Input::B)
  513. if $game_temp.choice_max > 0 and $game_temp.choice_cancel_type > 0
  514. $game_system.se_play($data_system.cancel_se)
  515. $game_temp.choice_proc.call($game_temp.choice_cancel_type - 1)
  516. terminate_message
  517. end
  518. end
  519. # 决定
  520. if Input.trigger?(Input::C)
  521. if $game_temp.choice_max > 0
  522. $game_system.se_play($data_system.decision_se)
  523. $game_temp.choice_proc.call(self.index)
  524. end
  525. if @mid_stop
  526. @mid_stop = false
  527. return
  528. else
  529. terminate_message
  530. end
  531. end
  532. return
  533. end
  534. if @fade_out == false and $game_temp.message_text != nil
  535. @contents_showing = true
  536. $game_temp.message_window_showing = true
  537. refresh
  538. Graphics.frame_reset
  539. self.visible = true
  540. self.contents_opacity = 0
  541. if @input_number_window != nil
  542. @input_number_window.contents_opacity = 0
  543. end
  544. @fade_in = true
  545. return
  546. end
  547. if self.visible
  548. @fade_out = true
  549. self.opacity -= 48
  550. if self.opacity == 0
  551. self.visible = false
  552. @fade_out = false
  553. $game_temp.message_window_showing = false
  554. end
  555. return
  556. end
  557. end
  558. #--------------------------------------------------------------------------
  559. # ● 获得字符
  560. #--------------------------------------------------------------------------
  561. def get_character(parameter)
  562. case parameter
  563. when 0  
  564. return $game_player
  565. else  
  566. events = $game_map.events
  567. return events == nil ? nil : events[parameter]
  568. end
  569. end
  570. #--------------------------------------------------------------------------
  571. # ● ウィンドウの位置と不透明度の设定
  572. #--------------------------------------------------------------------------
  573. def reset_window
  574. # 判定
  575. if @popchar >= 0
  576. events = $game_map.events
  577. if events != nil
  578. character = get_character(@popchar)
  579. x = [[character.screen_x - 0 - self.width / 2, 4].max, 636 - self.width].min
  580. y = [[character.screen_y - 48 - self.height, 4].max, 476 - self.height].min
  581. self.x = x
  582. self.y = y
  583. end
  584. elsif @popchar == -1
  585. self.x = -4
  586. self.y = -4
  587. self.width = 648
  588. self.height = 488
  589. else
  590. if $game_temp.in_battle
  591. self.y = 16
  592. else
  593. case $game_system.message_position
  594. when 0 # 上
  595. self.y = 16
  596. when 1 # 中
  597. self.y = 160
  598. when 2 # 下
  599. self.y = 304
  600. end
  601. self.x = 80
  602. if @face_file == nil
  603. self.width = 480
  604. else
  605. self.width = 600
  606. self.x -= 60
  607. end
  608. self.height = 160
  609. end
  610. end
  611. self.contents = Bitmap.new(self.width - 32, self.height - 32)
  612. if @face_file != nil
  613. self.contents.blt(16, 16, RPG::Cache.picture(@face_file), Rect.new(0, 0, 96, 96))
  614. end
  615. if @popchar == -1
  616. self.opacity = 255
  617. self.back_opacity = 0
  618. elsif $game_system.message_frame == 0
  619. self.opacity = 255
  620. self.back_opacity = 100
  621. else
  622. self.opacity = 0
  623. self.back_opacity = 100
  624. end
  625. end
  626. #--------------------------------------------------------------------------
  627. # ● line_height
  628. #--------------------------------------------------------------------------
  629. # 返回値:行高
  630. #--------------------------------------------------------------------------
  631. def line_height
  632. return 32
  633. if self.contents.font.size >= 20 and self.contents.font.size <= 24
  634. return 32
  635. else
  636. return self.contents.font.size * 15 / 10
  637. end
  638. end
  639. #--------------------------------------------------------------------------
  640. # ● 透过文字描画
  641. #--------------------------------------------------------------------------
  642. # target :描画対象。Bitmapクラスを指定。
  643. # x :x座标
  644. # y :y座标
  645. # str  :描画文字列
  646. # opacity:透过率(0~255)
  647. # 返回値 :文字幅(@x増加値)。
  648. #--------------------------------------------------------------------------
  649. def opacity_draw_text(target, x, y, str,opacity)
  650. height = target.font.size
  651. width = target.text_size(str).width
  652. opacity = [[opacity, 0].max, 255].min
  653. if opacity == 255
  654. target.draw_text(x, y, width, height, str)
  655. return width
  656. else
  657. if @opacity_text_buf.width < width or @opacity_text_buf.height < height
  658. @opacity_text_buf.dispose
  659. @opacity_text_buf = Bitmap.new(width, height)
  660. else
  661. @opacity_text_buf.clear
  662. end
  663. @opacity_text_buf.font.size = target.font.size
  664. @opacity_text_buf.draw_text(0, 0, width, height, str)
  665. target.blt(x, y, @opacity_text_buf, Rect.new(0, 0, width, height), opacity)
  666. return width
  667. end
  668. end
  669. def ruby_draw_text(target, x, y, str,opacity)
  670. sizeback = target.font.size
  671. target.font.size * 3 / 2 > 32 ? rubysize = 32 - target.font.size : rubysize = target.font.size / 2
  672. rubysize = [rubysize, 6].max
  673.   
  674. opacity = [[opacity, 0].max, 255].min
  675. split_s = str.split(/,/)
  676.   
  677. split_s[0] == nil ? split_s[0] = "" : nil
  678. split_s[1] == nil ? split_s[1] = "" : nil
  679. height = sizeback + rubysize
  680. width = target.text_size(split_s[0]).width
  681.   
  682. target.font.size = rubysize
  683. ruby_width = target.text_size(split_s[1]).width
  684. target.font.size = sizeback
  685.   
  686. buf_width = [target.text_size(split_s[0]).width, ruby_width].max
  687.   
  688. width - ruby_width != 0 ? sub_x = (width - ruby_width) / 2 : sub_x = 0
  689.   
  690. if opacity == 255
  691. target.font.size = rubysize
  692. target.draw_text(x + sub_x, y - target.font.size, target.text_size(split_s[1]).width, target.font.size, split_s[1])
  693. target.font.size = sizeback
  694. target.draw_text(x, y, width, target.font.size, split_s[0])
  695. return width
  696. else
  697. if @opacity_text_buf.width < buf_width or @opacity_text_buf.height < height
  698. @opacity_text_buf.dispose
  699. @opacity_text_buf = Bitmap.new(buf_width, height)
  700. else
  701. @opacity_text_buf.clear
  702. end
  703. @opacity_text_buf.font.size = rubysize
  704. @opacity_text_buf.draw_text(0 , 0, buf_width, rubysize, split_s[1], 1)
  705. @opacity_text_buf.font.size = sizeback
  706. @opacity_text_buf.draw_text(0 , rubysize, buf_width, sizeback, split_s[0], 1)
  707. if sub_x >= 0
  708. target.blt(x, y - rubysize, @opacity_text_buf, Rect.new(0, 0, buf_width, height), opacity)
  709. else
  710. target.blt(x + sub_x, y - rubysize, @opacity_text_buf, Rect.new(0, 0, buf_width, height), opacity)
  711. end
  712. return width
  713. end
  714. end
  715. #--------------------------------------------------------------------------
  716. # ● \V 变换
  717. #--------------------------------------------------------------------------
  718. def convart_value(option, index)
  719. option == nil ? option = "" : nil
  720. option.downcase!
  721. case option
  722. when "i"
  723. unless $data_items[index].name == nil
  724. r = sprintf("\030[%s]%s", $data_items[index].icon_name, $data_items[index].name)
  725. end
  726. when "w"
  727. unless $data_weapons[index].name == nil
  728. r = sprintf("\030[%s]%s", $data_weapons[index].icon_name, $data_weapons[index].name)
  729. end
  730. when "a"
  731. unless $data_armors[index].name == nil
  732. r = sprintf("\030[%s]%s", $data_armors[index].icon_name, $data_armors[index].name)
  733. end
  734. when "s"
  735. unless $data_skills[index].name == nil
  736. r = sprintf("\030[%s]%s", $data_skills[index].icon_name, $data_skills[index].name)
  737. end
  738. else
  739. r = $game_variables[index]
  740. end
  741. r == nil ? r = "" : nil
  742. return r
  743. end
  744. #--------------------------------------------------------------------------
  745. # ● 解放
  746. #--------------------------------------------------------------------------
  747. def dispose
  748. terminate_message
  749. if @gaiji_cache != nil
  750. unless @gaiji_cache.disposed?
  751. @gaiji_cache.dispose
  752. end
  753. end
  754. unless @opacity_text_buf.disposed?
  755. @opacity_text_buf.dispose
  756. end
  757. $game_temp.message_window_showing = false
  758. if @input_number_window != nil
  759. @input_number_window.dispose
  760. end
  761. super
  762. end
  763. #--------------------------------------------------------------------------
  764. # ● 矩形更新
  765. #--------------------------------------------------------------------------
  766. def update_cursor_rect
  767. if @index >= 0
  768. n = $game_temp.choice_start + @index
  769. self.cursor_rect.set(4 + @indent + @face_indent, n * 32 + 4, @cursor_width, 32)
  770. else
  771. self.cursor_rect.empty
  772. end
  773. end
  774. end
  775. #==============================================================================
  776. # ■ Window_Frame (枠だけで中身の无いウィンドウ)
  777. #==============================================================================
  778. class Window_Frame < Window_Base
  779. #--------------------------------------------------------------------------
  780. # ● オブジェクト初期化
  781. #--------------------------------------------------------------------------
  782. def initialize(x, y, width, height)
  783. super(x, y, width, height)
  784. self.contents = nil
  785. self.back_opacity = 100
  786. end
  787. #--------------------------------------------------------------------------
  788. # ● 解放
  789. #--------------------------------------------------------------------------
  790. def dispose
  791. super
  792. end
  793. end
  794. #==============================================================================
  795. # ■ Air_Text (何も无いところに文字描写 = 枠の无い瞬间表示メッセージウィンドウ)
  796. #==============================================================================
  797. class Air_Text < Window_Base
  798. #--------------------------------------------------------------------------
  799. # ● オブジェクト初期化
  800. #--------------------------------------------------------------------------
  801. def initialize(x, y, designate_text)
  802. super(x-16, y-16, 32 + designate_text.size * 12, 56)
  803. self.opacity = 0
  804. self.back_opacity = 0
  805. self.contents = Bitmap.new(self.width - 32, self.height - 32)
  806. w = self.contents.width
  807. h = self.contents.height
  808. self.contents.draw_text(0, 0, w, h, designate_text)
  809. end
  810. #--------------------------------------------------------------------------
  811. # ● 解放
  812. #--------------------------------------------------------------------------
  813. def dispose
  814. self.contents.clear
  815. super
  816. end
  817. end

  818.   

  819. #==============================================================================
  820. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  821. #==============================================================================
复制代码

作者: MeowSnow    时间: 2011-2-10 08:38
哈哈,教你一个临时想的方法,纯事件的,
你把要说的话截成图,到这种话时,
显示图片XX帧。




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1