Project1

标题: 請問有方法讓滾動文字置中嗎? [打印本页]

作者: grayshadow    时间: 2013-3-8 02:19
标题: 請問有方法讓滾動文字置中嗎?
本帖最后由 grayshadow 于 2013-3-8 22:27 编辑

各位大大好!
如題所問,請問有沒有方法能讓滾動文字自動置中,
而不需要自己把空白鍵按個幾十遍呢?
(最好是可以不影響到其他的對話框向左對齊,
不然,所有文字都置中了也好像不太好看。)

找了蠻久,似乎能確定軟件本身沒有這個功能,
搜索過本論壇,但好像沒看到類似的解決方案,
能請大大們幫個忙嗎?
謝謝!
作者: j433463    时间: 2013-3-8 12:22
卷动文字好像是用 draw_text_ex 来描绘的,它没有文字置中置右的参数,用来描绘带控制符的文字讯息,不知道换 draw_text 行不行?我没试过。

VX 倒是有卷动文字的脚本,可以置中,VA 好像没有见到过这种卷动文字脚本。
作者: grayshadow    时间: 2013-3-8 14:50
嗯……似乎不行?
不管怎樣,先謝謝大大你了!
作者: j433463    时间: 2013-3-8 16:57
本帖最后由 j433463 于 2013-3-8 17:00 编辑

您也许可以试试 VX 的卷动文字脚本,例如这一个:

http://forums.rpgmakerweb.com/in ... anas-credit-script/

这网址页中就是有人询问怎么在 VA 中使用的,方式很简单,把脚本贴到 Main 之前,然后把要显示的卷动文字内容剪贴到大约 64 行的 Credit= <<_MAP_CREDIT_ 下方,

像是这样:
  1. Credit= <<_MAP_CREDIT_


  2. <h>标题字
  3. <center>置中文字
  4. <left>置左文字
  5. <right>置右文字

  6. _MAP_CREDIT_
复制代码
不过 <b> 和 <i> 就别用了,会有问题。

调用它的方式是  SceneManager.scene.credit.start,测试效果还不错,但需要调整 @sprite.x 的位置:





如果屏蔽看不到网页,这是脚本内容:

RUBY 代码复制
  1. #===============================================================
  2. # ● [VX] ◦ Map Credit ◦ □
  3. #--------------------------------------------------------------
  4. # ◦ by Woratana [[email][email protected][/email]]
  5. # ◦ Thaiware RPG Maker Community
  6. # ◦ Released on: 09/05/2008
  7. # ◦ Version: 1.0
  8. #----------------------------------------------------
  9. # ◦ How to use:
  10. # ** To start Credit, call script:
  11. # $scene.credit.start
  12. #
  13. # ** To Stop and Clear Credit, call script:
  14. # $scene.credit.terminate
  15. #----------------------------------------------------
  16. # ◦ Special Tags for Decorate Text:
  17. # There are special tags that you can put in text to decorate that line
  18. #
  19. # You can also set default text decoration for all text in:
  20.   #-------------------------------------
  21.   # SETUP HEADER TEXT HERE
  22.   #-------------------------------------
  23. # for Header line (line that has tag <h>)
  24. # &
  25.   #-------------------------------------
  26.   # SETUP CONTENT TEXT HERE
  27.   #-------------------------------------
  28. # for Normal line~
  29. #-----------------------------------------------------
  30. # ◦ >= Tag List <= ◦
  31. # * These tags will only apply to the line it is in~
  32. # * You cannot use opposite tags in same line. (e.g. <b> and </b>)
  33. #
  34. # <b> :Bold Text
  35. # </b> :No Bold Text
  36. # <i> :Italic Text
  37. # </i> :No Italic Text
  38. # <center> :Align text to Center
  39. # <left> :Align text to left
  40. # <right> :Align text to right
  41. # <h> :Make that line become Header line
  42. #===========================================================================
  43. #----------------------------------------
  44. # Map Credit Main Script \('w' )
  45. #----------------------------------------
  46. class Wora_Map_Credit
  47.   BG_Image = '' # Background Image file name, image must be in folder 'Picture'
  48.   # You can leave this as '' for no background
  49.   BG_Image_Opacity = 255 # Background Opacity (0 - 255)
  50.  
  51.   Text_Begin_y = 416 # Use 0 - 416: Text will start in the screen
  52.   # Use 416+: Text will start below the screen
  53.  
  54.   Text_Scroll_Speed = 2 # Higher this number = Faster
  55.   Text_Scroll_Delay = 2 # Delay between each text move (0 for no delay)
  56.   Text_Opacity = 220 # Text Opacity
  57.   Text_Blend_Type = 0 # 0: Normal, 1: Add, 2: Subtraction
  58.  
  59.   Test_Text = 'I' # Text for test height,
  60.   # Change to taller alphabet if height is not right~
  61. #--------------------------
  62. # Start Credit
  63. #--------------------------
  64. Credit= <<_MAP_CREDIT_
  65.  
  66.  
  67. <h>HEADLINE
  68. CREDITS HERE
  69.  
  70.  
  71. _MAP_CREDIT_
  72. #--------------------------
  73. # End Credit
  74. #--------------------------
  75.   #-------------------------------------
  76.   # SETUP HEADER TEXT HERE
  77.   #-------------------------------------
  78.   def header_properties(bitmap)
  79.         bitmap.font.name = 'Twilight' # Text Font
  80.         bitmap.font.color = Color.new(0, 0, 255, 255) # (Red, Green, Blue, Opacity)
  81.         bitmap.font.size = 30 # Text size
  82.         bitmap.font.bold = true # Bold Text? (true/false)
  83.         bitmap.font.italic = false # Italic Text? (true/false)
  84.         bitmap.font.shadow = true # Shadowed Text? (true/false)
  85.         @text_outline = Color.new(0,0,0) # nil for no outline, Color.new(r,g,<img src='http://forums.rpgmakerweb.com/public/style_emoticons/<#EMO_DIR#>/cool.png' class='bbc_emoticon' alt='B)' /> for outline
  86.         @text_align = 1 # 0: Left, 1: Center, 2: Right
  87.   end
  88.  
  89.   #-------------------------------------
  90.   # SETUP CONTENT TEXT HERE
  91.   #-------------------------------------
  92.   def content_properties(bitmap)
  93.         bitmap.font.name = 'Tahoma'
  94.         bitmap.font.color = Color.new(255, 255, 255, 255)
  95.         bitmap.font.size = 22
  96.         bitmap.font.bold = true
  97.         bitmap.font.italic = false
  98.         bitmap.font.shadow = true
  99.         @text_outline = nil
  100.         @text_align = 1
  101.   end
  102. #-----------------------------------------------------------------------
  103. # -END- MAP CREDIT SCRIPT SETUP PART
  104. #===========================================================================
  105.   def initialize
  106.         @started = false
  107.   end
  108.  
  109.   # Delete credit if credit started
  110.   def terminate
  111.         if @started
  112.           if @bg != nil
  113.                 @bg.bitmap.dispose
  114.                 @bg.dispose
  115.           end
  116.           @sprite.bitmap.dispose
  117.           @sprite.dispose
  118.           @started = false
  119.         end
  120.   end
  121.  
  122.   # Start Credit
  123.   def start(text = Credit, bg = BG_Image)
  124.         # Create Background Sprite
  125.         if BG_Image != ''
  126.           @bg = Sprite.new
  127.           @bg.bitmap = Cache.picture(bg)
  128.           @bg.opacity = BG_Image_Opacity
  129.           @bg.z = 10000
  130.         end
  131.         # Create Text Sprite
  132.         [url=home.php?mod=space&uid=114926]@sprite[/url] = Sprite.new
  133.         @sprite.x = 122
  134.         @sprite.y = 0
  135.         @sprite.z = 10001
  136.         @sprite.opacity = Text_Opacity
  137.         @sprite.blend_type = Text_Blend_Type
  138.         # Calculate Credit Height
  139.         header_line = 0
  140.         content_line = 0
  141.         height = 0
  142.         text = text.split(/\n/)
  143.         text.each do |i|
  144.           if i.include?('<h>'); header_line += 1
  145.           else; content_line += 1
  146.           end
  147.         end
  148.         @sprite.bitmap = Bitmap.new(1,1)
  149.         # Test Header Properties
  150.         header_properties(@sprite.bitmap)
  151.         header_height = @sprite.bitmap.text_size(Test_Text).height
  152.         height += ( header_line * ( header_height ) )
  153.         # Test Content Properties
  154.         content_properties(@sprite.bitmap)
  155.         content_height = @sprite.bitmap.text_size(Test_Text).height
  156.         height += ( content_line * ( content_height ) )
  157.         @sprite.bitmap.dispose
  158.         # Finished Test, Draw Text
  159.         @sprite.bitmap = Bitmap.new(300, Text_Begin_y + height + 32)
  160.         content_x = 0
  161.         content_y = Text_Begin_y
  162.         text.each do |i|
  163.  
  164.           # Determine Special Tags
  165.           if i.include?('<h>')
  166.                 i.sub!('<h>', '')
  167.                 header_properties(@sprite.bitmap)
  168.                 bitmap_height = header_height
  169.           else
  170.                 content_properties(@sprite.bitmap)
  171.                 bitmap_height = content_height
  172.           end
  173.           # Bold Text
  174.           if i.include?('<b>')
  175.                 i.sub!('<b>', ''); @sprite.font.bold = true
  176.           elsif i.include?('</b>')
  177.                 i.sub!('</b>', ''); @sprite.font.bold = false
  178.           end
  179.           # Italic Text
  180.           if i.include?('<i>')
  181.                 i.sub!('<i>', ''); @sprite.font.italic = true
  182.           elsif i.include?('</i>')
  183.                 i.sub!('</i>', ''); @sprite.font.italic = false
  184.           end
  185.           # Align Text
  186.           if i.include?('<center>')
  187.                 i.sub!('<center>', ''); @text_align = 1
  188.           elsif i.include?('<left>')
  189.                 i.sub!('<left>', ''); @text_align = 0
  190.           elsif i.include?('<right>')
  191.                 i.sub!('<right>', ''); @text_align = 2
  192.           end
  193.           if !@text_outline.nil? # Text Outline
  194.                 ori_color = @sprite.bitmap.font.color.clone
  195.                 @sprite.bitmap.font.color = @text_outline
  196.                 @sprite.bitmap.draw_text(content_x-1, content_y, @sprite.bitmap.width,
  197. bitmap_height, i, @text_align)
  198.                 @sprite.bitmap.draw_text(content_x, content_y-1, @sprite.bitmap.width,
  199. bitmap_height, i, @text_align)
  200.                 @sprite.bitmap.draw_text(content_x, content_y+1, @sprite.bitmap.width,
  201. bitmap_height, i, @text_align)
  202.                 @sprite.bitmap.draw_text(content_x+1, content_y, @sprite.bitmap.width,
  203. bitmap_height, i, @text_align)
  204.                 @sprite.bitmap.font.color = ori_color
  205.           end
  206.  
  207.           # Draw Text
  208.           @sprite.bitmap.draw_text(content_x, content_y, @sprite.bitmap.width,
  209. bitmap_height, i, @text_align)
  210.           content_y += bitmap_height
  211.         end
  212.         @delay = 0
  213.         @started = true
  214.   end
  215.  
  216.   # Update credit if credit started~
  217.   def update
  218.         if @started
  219.           if @delay > 0
  220.                 @delay -= 1
  221.                 return
  222.           else
  223.                 @sprite.oy += Text_Scroll_Speed
  224.                 @delay += Text_Scroll_Delay
  225.           end
  226.         end
  227.   end
  228. end
  229. #----------------------------------------
  230. # Plug Credit to Map >_> <img src='http://forums.rpgmakerweb.com/public/style_emoticons/<#EMO_DIR#>/dry.png' class='bbc_emoticon' alt='<_<' />~
  231. #----------------------------------------
  232. class Scene_Map < Scene_Base
  233.   attr_reader :credit
  234.   alias wor_mapcre_scemap_str start
  235.   alias wor_mapcre_scemap_upd update
  236.   alias wor_mapcre_scemap_ter terminate
  237.   def start
  238.         [url=home.php?mod=space&uid=126758]@credit[/url] = Wora_Map_Credit.new # Create Credit
  239.         wor_mapcre_scemap_str
  240.   end
  241.  
  242.   def update
  243.         @credit.update # Update Credit
  244.         wor_mapcre_scemap_upd
  245.   end
  246.  
  247.   def terminate
  248.         @credit.terminate # Dispose Credit
  249.         wor_mapcre_scemap_ter
  250.   end
  251. end


作者: grayshadow    时间: 2013-3-8 22:25
噢!謝謝大大了!
效果的確蠻不錯的~




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