赞 | 0 |
VIP | 30 |
好人卡 | 0 |
积分 | 1 |
经验 | 16142 |
最后登录 | 2019-4-26 |
在线时间 | 317 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 60
- 在线时间
- 317 小时
- 注册时间
- 2009-1-18
- 帖子
- 177
|
本帖最后由 Majirefy 于 2012-4-28 10:36 编辑
还是在写那个地图名显示脚本,貌似遇到一点点问题哈。
还是不能理解这个Window中到底有什么,self到底指什么,看了网上的教程,还是不太清楚self。
还有contents这个东西,是对应一个Window里面所有的内容都是Contents么?
一个Window中可以有多少个contents?
代码更改了一下:- class Window_MapNamePlus < Window_Base
- #--------------------------------------------------------------------------
- # * Settings
- #--------------------------------------------------------------------------
- FONT_NAME = ["PMingLiU", "SimSong"] # Font Name
- FONT_SIZE_CH = 36 # Chinese Font Size
- FONT_SIZE_EN = 16 # English Font Size
- FONT_BOLD = true # True if Font in Bold
- FONT_COLOR = Color.new(255, 255, 255, 255) # Color of Font
- FONT_OUT = true # True if Font Has Outline
- OUT_COLOR = Color.new(0, 0, 0, 255) # Color of Outline Color of Font
- FONT_SHADOW = false # True if Text Drops Shadow
- MODIFIER = "~" # Modifier Added beside Map Name
- PADDING = 12 # Padding between Window's Frame and Contents
- BACK_SWITCH = false # True if Draws a Gradient Background
- LINE_HEIGHT = 4 # Height of Split Line
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_writer :map_name_chinese # Chinese Map Name
- attr_writer :map_name_english # English Map Name
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize
- #----------------------------------------------------------------------
- # * Set the window in the middle of screen.
- #----------------------------------------------------------------------
- super(((Graphics.width - window_width) / 2),
- ((Graphics.height - (FONT_SIZE_CH + PADDING * 2)) / 2),
- window_width, FONT_SIZE_CH + PADDING * 2)
- #----------------------------------------------------------------------
- # * Custom font and style.
- #----------------------------------------------------------------------
- contents.font.name = FONT_NAME
- contents.font.size = FONT_SIZE_CH
- contents.font.bold = FONT_BOLD
- contents.font.color = FONT_COLOR
- contents.font.outline = FONT_OUT
- contents.font.out_color = OUT_COLOR
- contents.font.shadow = FONT_SHADOW
- #----------------------------------------------------------------------
- # * Set Window Opacity
- #----------------------------------------------------------------------
- self.opacity = 0
- self.contents_opacity = 0
- @show_count = 0
- refresh
- end
- #--------------------------------------------------------------------------
- # * Get Window Width
- #--------------------------------------------------------------------------
- def window_width
- return Graphics.width
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- super
- if @show_count > 0 && $game_map.name_display
- update_fadein
- @show_count -= 1
- else
- update_fadeout
- end
- end
- #--------------------------------------------------------------------------
- # * Update Fadein
- #--------------------------------------------------------------------------
- def update_fadein
- self.contents_opacity += 16
- end
- #--------------------------------------------------------------------------
- # * Update Fadeout
- #--------------------------------------------------------------------------
- def update_fadeout
- self.contents_opacity -= 16
- end
- #--------------------------------------------------------------------------
- # * Open Window
- #--------------------------------------------------------------------------
- def open
- refresh
- @show_count = 150
- self.contents_opacity = 0
- self
- end
- #--------------------------------------------------------------------------
- # * Close Window
- #--------------------------------------------------------------------------
- def close
- @show_count = 0
- self
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- contents.clear
- set_map_name
- unless $game_map.display_name.empty?
- draw_map_name
- end
- end
- #--------------------------------------------------------------------------
- # * Draw Line
- #--------------------------------------------------------------------------
- def draw_line(rect)
- temp_rect = rect.clone
- temp_rect.height = LINE_HEIGHT
- temp_rect.width /= 2
- contents.gradient_fill_rect(temp_rect, color2, color1)
- temp_rect.x = temp_rect.width
- contents.gradient_fill_rect(temp_rect, color1, color2)
- end
- #--------------------------------------------------------------------------
- # * Set Map Name
- #--------------------------------------------------------------------------
- def set_map_name
- p $game_map.display_name
- temp_map_name = $game_map.display_name.split("@")
- p temp_map_name
- @map_name_chinese = temp_map_name[0]
- @map_name_english = temp_map_name[1]
- end
- #--------------------------------------------------------------------------
- # * Draw Map Name
- #--------------------------------------------------------------------------
- def draw_map_name
-
- end
- #--------------------------------------------------------------------------
- # * Get Color 1
- #--------------------------------------------------------------------------
- def color1
- Color.new(255, 255, 255, 200)
- end
- #--------------------------------------------------------------------------
- # * Get Color 2
- #--------------------------------------------------------------------------
- def color2
- Color.new(255, 255, 255, 0)
- end
- end
复制代码 期望的效果如下:
可是不知道怎么修改这些文字的坐标(不想直接指定而是想通过计算得来),而且如何使那个横线可以随我文字的内容而改变长短呢?
先谢谢了~~~
这个代码其实是不能用的……
原来的代码是这样的:- # encoding: utf-8
- #==============================================================================
- # ** Window_MapNamePlus
- #------------------------------------------------------------------------------
- # This window displays the map name.
- #------------------------------------------------------------------------------
- # This class replaces the default Window_MapName class, adding more
- # modification and custom.
- #------------------------------------------------------------------------------
- # Author: Majirefy
- #------------------------------------------------------------------------------
- # Guide:
- # To use this script, create a new section below Materials in Script Editor
- # and paste the script there. Then turn to Scene_Map section, find string
- # "Window_MapName.new", replace it by "Winodw_MapNamePlus.new".
- # Map name should be set in pattern like "拉普兰德@Lapland", using symbol "@"
- # to split Chinese character and English text. You can also use "@" to split
- # everything in map name.
- #------------------------------------------------------------------------------
- # Change Log:
- # => v1.1 - Date: 20120424
- # Function Added:
- # Set Font
- # Set Font Size
- # Set Font Bold
- # Set Font Color
- # Set Outline Color On or Off
- # Set Outline Color of Text
- # Set Padding
- # To-Add Function:
- # Split Map Name by "@"
- # Add Modifier
- # Bugs:
- # Split Line Position Error
- # => v1.0 - Date: 20120419
- # Basic Function:
- # Set Window Position
- # Set Font
- # Set Font Size
- # Set Font Bold
- # Set Font Color
- # Set Outline Color On or Off
- # Set Outline Color of Text
- # Set Font Shadow On or Off
- # Set Padding
- # Set Modifier
- # Set Background On or Off
- # Set Split Line Height
- #==============================================================================
- class Window_MapNamePlus < Window_Base
- #--------------------------------------------------------------------------
- # * Settings
- #--------------------------------------------------------------------------
- FONT_NAME = ["PMingLiU", "SimSong"] # Font Name
- FONT_SIZE_CH = 36 # Chinese Font Size
- FONT_SIZE_EN = 16 # English Font Size
- FONT_BOLD = true # True if Font in Bold
- FONT_COLOR = Color.new(255, 255, 255, 255) # Color of Font
- FONT_OUT = true # True if Font Has Outline
- OUT_COLOR = Color.new(0, 0, 0, 255) # Color of Outline Color of Font
- FONT_SHADOW = false # True if Text Drops Shadow
- MODIFIER = "~" # Modifier Added beside Map Name
- PADDING = 12 # Padding between Window's Frame and Contents
- BACK_SWITCH = false # True if Draws a Gradient Background
- LINE_HEIGHT = 4 # Height of Split Line
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_writer :map_name_chinese # Chinese Map Name
- attr_writer :map_name_english # English Map Name
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize
- #----------------------------------------------------------------------
- # * Set the window in the middle of screen.
- #----------------------------------------------------------------------
- super(((Graphics.width - window_width) / 2),
- ((Graphics.height - (FONT_SIZE_CH + PADDING * 2)) / 2),
- window_width, FONT_SIZE_CH + PADDING * 2)
- #----------------------------------------------------------------------
- # * Custom font and style.
- #----------------------------------------------------------------------
- contents.font.name = FONT_NAME
- contents.font.size = FONT_SIZE_CH
- contents.font.bold = FONT_BOLD
- contents.font.color = FONT_COLOR
- contents.font.outline = FONT_OUT
- contents.font.out_color = OUT_COLOR
- contents.font.shadow = FONT_SHADOW
- #----------------------------------------------------------------------
- # * Set Window Opacity
- #----------------------------------------------------------------------
- self.opacity = 0
- self.contents_opacity = 0
- @show_count = 0
- refresh
- end
- #--------------------------------------------------------------------------
- # * Get Window Width
- #--------------------------------------------------------------------------
- def window_width
- return Graphics.width
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- super
- if @show_count > 0 && $game_map.name_display
- update_fadein
- @show_count -= 1
- else
- update_fadeout
- end
- end
- #--------------------------------------------------------------------------
- # * Update Fadein
- #--------------------------------------------------------------------------
- def update_fadein
- self.contents_opacity += 16
- end
- #--------------------------------------------------------------------------
- # * Update Fadeout
- #--------------------------------------------------------------------------
- def update_fadeout
- self.contents_opacity -= 16
- end
- #--------------------------------------------------------------------------
- # * Open Window
- #--------------------------------------------------------------------------
- def open
- refresh
- @show_count = 150
- self.contents_opacity = 0
- self
- end
- #--------------------------------------------------------------------------
- # * Close Window
- #--------------------------------------------------------------------------
- def close
- @show_count = 0
- self
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- contents.clear
- set_map_name
- unless $game_map.display_name.empty?
- draw_line(contents.rect)
- draw_text(contents.rect, @map_name_chinese, 1)
- draw_text(contents.rect, @map_name_english, 1)
- end
- end
- #--------------------------------------------------------------------------
- # * Draw Line
- #--------------------------------------------------------------------------
- def draw_line(rect)
- temp_rect = rect.clone
- temp_rect.height = LINE_HEIGHT
- temp_rect.width /= 2
- contents.gradient_fill_rect(temp_rect, color2, color1)
- temp_rect.x = temp_rect.width
- contents.gradient_fill_rect(temp_rect, color1, color2)
- end
- #--------------------------------------------------------------------------
- # * Set Map Name
- #--------------------------------------------------------------------------
- def set_map_name
- p $game_map.display_name
- temp_map_name = $game_map.display_name.split("@")
- p temp_map_name
- @map_name_chinese = temp_map_name[0]
- @map_name_english = temp_map_name[1]
- end
- #--------------------------------------------------------------------------
- # * Get Color 1
- #--------------------------------------------------------------------------
- def color1
- Color.new(255, 255, 255, 200)
- end
- #--------------------------------------------------------------------------
- # * Get Color 2
- #--------------------------------------------------------------------------
- def color2
- Color.new(255, 255, 255, 0)
- end
- end
复制代码 自己想好好修改一下……所以准备重写…… |
评分
-
查看全部评分
|