设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 3024|回复: 0
打印 上一主题 下一主题

[已经过期] 地图名脚本画直线、改坐标

[复制链接]

Lv1.梦旅人

梦石
0
星屑
60
在线时间
317 小时
注册时间
2009-1-18
帖子
177
跳转到指定楼层
1
发表于 2012-4-28 10:33:52 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 Majirefy 于 2012-4-28 10:36 编辑

还是在写那个地图名显示脚本,貌似遇到一点点问题哈。
还是不能理解这个Window中到底有什么self到底指什么,看了网上的教程,还是不太清楚self。
还有contents这个东西,是对应一个Window里面所有的内容都是Contents么?
一个Window中可以有多少个contents
代码更改了一下:
  1. class Window_MapNamePlus < Window_Base
  2.   #--------------------------------------------------------------------------
  3.   # * Settings
  4.   #--------------------------------------------------------------------------
  5.   FONT_NAME    = ["PMingLiU", "SimSong"]        # Font Name
  6.   FONT_SIZE_CH = 36                             # Chinese Font Size
  7.   FONT_SIZE_EN = 16                             # English Font Size
  8.   FONT_BOLD    = true                           # True if Font in Bold
  9.   FONT_COLOR   = Color.new(255, 255, 255, 255)  # Color of Font
  10.   FONT_OUT     = true                           # True if Font Has Outline
  11.   OUT_COLOR    = Color.new(0, 0, 0, 255)        # Color of Outline Color of Font
  12.   FONT_SHADOW  = false                          # True if Text Drops Shadow
  13.   MODIFIER     = "~"                            # Modifier Added beside Map Name
  14.   PADDING      = 12                             # Padding between Window's Frame and Contents
  15.   BACK_SWITCH  = false                          # True if Draws a Gradient Background
  16.   LINE_HEIGHT  = 4                              # Height of Split Line
  17.   #--------------------------------------------------------------------------
  18.   # * Public Instance Variables
  19.   #--------------------------------------------------------------------------
  20.   attr_writer :map_name_chinese                 # Chinese Map Name
  21.   attr_writer :map_name_english                 # English Map Name
  22.   #--------------------------------------------------------------------------
  23.   # * Object Initialization
  24.   #--------------------------------------------------------------------------
  25.   def initialize
  26.     #----------------------------------------------------------------------
  27.     # * Set the window in the middle of screen.
  28.     #----------------------------------------------------------------------
  29.     super(((Graphics.width - window_width) / 2),
  30.       ((Graphics.height - (FONT_SIZE_CH + PADDING * 2)) / 2),
  31.       window_width, FONT_SIZE_CH + PADDING * 2)
  32.     #----------------------------------------------------------------------
  33.     # * Custom font and style.
  34.     #----------------------------------------------------------------------
  35.     contents.font.name      = FONT_NAME
  36.     contents.font.size      = FONT_SIZE_CH
  37.     contents.font.bold      = FONT_BOLD
  38.     contents.font.color     = FONT_COLOR
  39.     contents.font.outline   = FONT_OUT
  40.     contents.font.out_color = OUT_COLOR
  41.     contents.font.shadow    = FONT_SHADOW
  42.     #----------------------------------------------------------------------
  43.     # * Set Window Opacity
  44.     #----------------------------------------------------------------------
  45.     self.opacity = 0
  46.     self.contents_opacity = 0
  47.     @show_count = 0
  48.     refresh
  49.   end
  50.   #--------------------------------------------------------------------------
  51.   # * Get Window Width
  52.   #--------------------------------------------------------------------------
  53.   def window_width
  54.     return Graphics.width
  55.   end
  56.   #--------------------------------------------------------------------------
  57.   # * Frame Update
  58.   #--------------------------------------------------------------------------
  59.   def update
  60.     super
  61.     if @show_count > 0 && $game_map.name_display
  62.       update_fadein
  63.       @show_count -= 1
  64.     else
  65.       update_fadeout
  66.     end
  67.   end
  68.   #--------------------------------------------------------------------------
  69.   # * Update Fadein
  70.   #--------------------------------------------------------------------------
  71.   def update_fadein
  72.     self.contents_opacity += 16
  73.   end
  74.   #--------------------------------------------------------------------------
  75.   # * Update Fadeout
  76.   #--------------------------------------------------------------------------
  77.   def update_fadeout
  78.     self.contents_opacity -= 16
  79.   end
  80.   #--------------------------------------------------------------------------
  81.   # * Open Window
  82.   #--------------------------------------------------------------------------
  83.   def open
  84.     refresh
  85.     @show_count = 150
  86.     self.contents_opacity = 0
  87.     self
  88.   end
  89.   #--------------------------------------------------------------------------
  90.   # * Close Window
  91.   #--------------------------------------------------------------------------
  92.   def close
  93.     @show_count = 0
  94.     self
  95.   end
  96.   #--------------------------------------------------------------------------
  97.   # * Refresh
  98.   #--------------------------------------------------------------------------
  99.   def refresh
  100.     contents.clear
  101.     set_map_name
  102.     unless $game_map.display_name.empty?
  103.       draw_map_name
  104.     end
  105.   end
  106.   #--------------------------------------------------------------------------
  107.   # * Draw Line
  108.   #--------------------------------------------------------------------------
  109.   def draw_line(rect)
  110.     temp_rect = rect.clone
  111.     temp_rect.height = LINE_HEIGHT
  112.     temp_rect.width /= 2
  113.     contents.gradient_fill_rect(temp_rect, color2, color1)
  114.     temp_rect.x = temp_rect.width
  115.     contents.gradient_fill_rect(temp_rect, color1, color2)
  116.   end
  117.   #--------------------------------------------------------------------------
  118.   # * Set Map Name
  119.   #--------------------------------------------------------------------------
  120.   def set_map_name
  121.     p $game_map.display_name
  122.     temp_map_name     = $game_map.display_name.split("@")
  123.     p temp_map_name
  124.     @map_name_chinese = temp_map_name[0]
  125.     @map_name_english = temp_map_name[1]
  126.   end
  127.   #--------------------------------------------------------------------------
  128.   # * Draw Map Name
  129.   #--------------------------------------------------------------------------
  130.   def draw_map_name
  131.    
  132.   end
  133.   #--------------------------------------------------------------------------
  134.   # * Get Color 1
  135.   #--------------------------------------------------------------------------
  136.   def color1
  137.     Color.new(255, 255, 255, 200)
  138.   end
  139.   #--------------------------------------------------------------------------
  140.   # * Get Color 2
  141.   #--------------------------------------------------------------------------
  142.   def color2
  143.     Color.new(255, 255, 255, 0)
  144.   end
  145. end
复制代码
期望的效果如下:

可是不知道怎么修改这些文字的坐标(不想直接指定而是想通过计算得来),而且如何使那个横线可以随我文字的内容而改变长短呢?
先谢谢了~~~
这个代码其实是不能用的……
原来的代码是这样的:
  1. # encoding: utf-8
  2. #==============================================================================
  3. # ** Window_MapNamePlus
  4. #------------------------------------------------------------------------------
  5. #  This window displays the map name.
  6. #------------------------------------------------------------------------------
  7. #    This class replaces the default Window_MapName class, adding more
  8. #   modification and custom.
  9. #------------------------------------------------------------------------------
  10. #  Author: Majirefy
  11. #------------------------------------------------------------------------------
  12. #  Guide:
  13. #    To use this script, create a new section below Materials in Script Editor
  14. #   and paste the script there. Then turn to Scene_Map section, find string
  15. #   "Window_MapName.new", replace it by "Winodw_MapNamePlus.new".
  16. #    Map name should be set in pattern like "拉普兰德@Lapland", using symbol "@"
  17. #   to split Chinese character and English text. You can also use "@" to split
  18. #   everything in map name.
  19. #------------------------------------------------------------------------------
  20. #  Change Log:
  21. # => v1.1 - Date: 20120424
  22. #     Function Added:
  23. #      Set Font
  24. #      Set Font Size
  25. #      Set Font Bold
  26. #      Set Font Color
  27. #      Set Outline Color On or Off
  28. #      Set Outline Color of Text
  29. #      Set Padding
  30. #     To-Add Function:
  31. #      Split Map Name by "@"
  32. #      Add Modifier
  33. #     Bugs:
  34. #      Split Line Position Error
  35. # => v1.0 - Date: 20120419
  36. #     Basic Function:
  37. #      Set Window Position
  38. #      Set Font
  39. #      Set Font Size
  40. #      Set Font Bold
  41. #      Set Font Color
  42. #      Set Outline Color On or Off
  43. #      Set Outline Color of Text
  44. #      Set Font Shadow On or Off
  45. #      Set Padding
  46. #      Set Modifier
  47. #      Set Background On or Off
  48. #      Set Split Line Height
  49. #==============================================================================

  50. class Window_MapNamePlus < Window_Base
  51.   #--------------------------------------------------------------------------
  52.   # * Settings
  53.   #--------------------------------------------------------------------------
  54.   FONT_NAME    = ["PMingLiU", "SimSong"]        # Font Name
  55.   FONT_SIZE_CH = 36                             # Chinese Font Size
  56.   FONT_SIZE_EN = 16                             # English Font Size
  57.   FONT_BOLD    = true                           # True if Font in Bold
  58.   FONT_COLOR   = Color.new(255, 255, 255, 255)  # Color of Font
  59.   FONT_OUT     = true                           # True if Font Has Outline
  60.   OUT_COLOR    = Color.new(0, 0, 0, 255)        # Color of Outline Color of Font
  61.   FONT_SHADOW  = false                          # True if Text Drops Shadow
  62.   MODIFIER     = "~"                            # Modifier Added beside Map Name
  63.   PADDING      = 12                             # Padding between Window's Frame and Contents
  64.   BACK_SWITCH  = false                          # True if Draws a Gradient Background
  65.   LINE_HEIGHT  = 4                              # Height of Split Line
  66.   #--------------------------------------------------------------------------
  67.   # * Public Instance Variables
  68.   #--------------------------------------------------------------------------
  69.   attr_writer :map_name_chinese                 # Chinese Map Name
  70.   attr_writer :map_name_english                 # English Map Name
  71.   #--------------------------------------------------------------------------
  72.   # * Object Initialization
  73.   #--------------------------------------------------------------------------
  74.   def initialize
  75.     #----------------------------------------------------------------------
  76.     # * Set the window in the middle of screen.
  77.     #----------------------------------------------------------------------
  78.     super(((Graphics.width - window_width) / 2),
  79.       ((Graphics.height - (FONT_SIZE_CH + PADDING * 2)) / 2),
  80.       window_width, FONT_SIZE_CH + PADDING * 2)
  81.     #----------------------------------------------------------------------
  82.     # * Custom font and style.
  83.     #----------------------------------------------------------------------
  84.     contents.font.name      = FONT_NAME
  85.     contents.font.size      = FONT_SIZE_CH
  86.     contents.font.bold      = FONT_BOLD
  87.     contents.font.color     = FONT_COLOR
  88.     contents.font.outline   = FONT_OUT
  89.     contents.font.out_color = OUT_COLOR
  90.     contents.font.shadow    = FONT_SHADOW
  91.     #----------------------------------------------------------------------
  92.     # * Set Window Opacity
  93.     #----------------------------------------------------------------------
  94.     self.opacity = 0
  95.     self.contents_opacity = 0
  96.     @show_count = 0
  97.     refresh
  98.   end
  99.   #--------------------------------------------------------------------------
  100.   # * Get Window Width
  101.   #--------------------------------------------------------------------------
  102.   def window_width
  103.     return Graphics.width
  104.   end
  105.   #--------------------------------------------------------------------------
  106.   # * Frame Update
  107.   #--------------------------------------------------------------------------
  108.   def update
  109.     super
  110.     if @show_count > 0 && $game_map.name_display
  111.       update_fadein
  112.       @show_count -= 1
  113.     else
  114.       update_fadeout
  115.     end
  116.   end
  117.   #--------------------------------------------------------------------------
  118.   # * Update Fadein
  119.   #--------------------------------------------------------------------------
  120.   def update_fadein
  121.     self.contents_opacity += 16
  122.   end
  123.   #--------------------------------------------------------------------------
  124.   # * Update Fadeout
  125.   #--------------------------------------------------------------------------
  126.   def update_fadeout
  127.     self.contents_opacity -= 16
  128.   end
  129.   #--------------------------------------------------------------------------
  130.   # * Open Window
  131.   #--------------------------------------------------------------------------
  132.   def open
  133.     refresh
  134.     @show_count = 150
  135.     self.contents_opacity = 0
  136.     self
  137.   end
  138.   #--------------------------------------------------------------------------
  139.   # * Close Window
  140.   #--------------------------------------------------------------------------
  141.   def close
  142.     @show_count = 0
  143.     self
  144.   end
  145.   #--------------------------------------------------------------------------
  146.   # * Refresh
  147.   #--------------------------------------------------------------------------
  148.   def refresh
  149.     contents.clear
  150.     set_map_name
  151.     unless $game_map.display_name.empty?
  152.       draw_line(contents.rect)
  153.       draw_text(contents.rect, @map_name_chinese, 1)
  154.       draw_text(contents.rect, @map_name_english, 1)
  155.     end
  156.   end
  157.   #--------------------------------------------------------------------------
  158.   # * Draw Line
  159.   #--------------------------------------------------------------------------
  160.   def draw_line(rect)
  161.     temp_rect = rect.clone
  162.     temp_rect.height = LINE_HEIGHT
  163.     temp_rect.width /= 2
  164.     contents.gradient_fill_rect(temp_rect, color2, color1)
  165.     temp_rect.x = temp_rect.width
  166.     contents.gradient_fill_rect(temp_rect, color1, color2)
  167.   end
  168.   #--------------------------------------------------------------------------
  169.   # * Set Map Name
  170.   #--------------------------------------------------------------------------
  171.   def set_map_name
  172.     p $game_map.display_name
  173.     temp_map_name     = $game_map.display_name.split("@")
  174.     p temp_map_name
  175.     @map_name_chinese = temp_map_name[0]
  176.     @map_name_english = temp_map_name[1]
  177.   end
  178.   #--------------------------------------------------------------------------
  179.   # * Get Color 1
  180.   #--------------------------------------------------------------------------
  181.   def color1
  182.     Color.new(255, 255, 255, 200)
  183.   end
  184.   #--------------------------------------------------------------------------
  185.   # * Get Color 2
  186.   #--------------------------------------------------------------------------
  187.   def color2
  188.     Color.new(255, 255, 255, 0)
  189.   end
  190. end
复制代码
自己想好好修改一下……所以准备重写……

评分

参与人数 1星屑 +2000 收起 理由
精灵使者 + 2000 恭喜你踩中230000帖子,2000积分增加.

查看全部评分

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-11-26 04:03

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表