赞 | 2 |
VIP | 0 |
好人卡 | 0 |
积分 | 20 |
经验 | 0 |
最后登录 | 2021-6-24 |
在线时间 | 410 小时 |
Lv3.寻梦者
- 梦石
- 0
- 星屑
- 1957
- 在线时间
- 410 小时
- 注册时间
- 2018-9-25
- 帖子
- 38
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 adahs 于 2020-3-25 16:52 编辑
在学习脚本中,最近就在试着修改别人写的脚本练习一下,在我修改一个标题界面显示指令的脚本的时候出了点问题,那个脚本原本只能显示图片,自己试着修改补充了一个用draw_text写开始游戏,继续游戏这些功能,但是不知道为什么draw_text出来的这些字隔大概二十多秒就会突然消失一瞬间,然后又重新出现,实在是搞不懂是哪里出了问题,希望有大佬能指点一下。
这是我修改的部分
- def update_ts_picture_cm
- @command_window.visible = false ; @command_window.x = -2000
- for i in 0...@command_window.list.size
- if i == @command_window.index
- @com_pictures[2][i]=1
- if !@com_pictures[1][i]
- rect = Rect.new(316, 0, 316, 26)
- bitmap2=Bitmap.new(316,26)
- bitmap2.blt(0, 0, @bitmap1, rect, 255)
- @com_pictures[0][i].bitmap =bitmap2
- draw_text(i)
- else
- rect = Rect.new(632, 0, 316, 26)
- bitmap2=Bitmap.new(316,26)
- bitmap2.blt(0, 0, @bitmap1, rect, 255)
- @com_pictures[0][i].bitmap =bitmap2
- draw_text(i)
- end
- else
- if @com_pictures[2][i]=1
- rect = Rect.new(0, 0, 316, 26)
- bitmap2=Bitmap.new(316,26)
- bitmap2.blt(0, 0, @bitmap1, rect, 255)
- @com_pictures[0][i].bitmap =bitmap2
- draw_text(i)
- @com_pictures[2][i]=1
- end
- end
- end
- update_tsprite_cursor
- end
-
- def draw_text(i)
- @com_pictures[0][i].bitmap.font.size=16
- @com_pictures[0][i].bitmap.font.outline=false
- @com_pictures[0][i].bitmap.font.name="黑体"
- @com_pictures[0][i].bitmap.font.color=Color.new(0,0,0)
- @com_pictures[0][i].bitmap.draw_text(0,0,316,26,MOG_TITLE_PICTURE_COMMANDS::TITLENAME[i],1)
- end
复制代码 完整的脚本- if true
- #==============================================================================
- # +++ MOG - 标题图片指令 - [独立版] (V1.1) +++
- #==============================================================================
- # By Moghunter
- # https://atelierrgss.wordpress.com/
- #==============================================================================
- # 添加指令图片
- #==============================================================================
- #==============================================================================
- # 命名格式:
- #
- # Com_0.png
- # Com_1.png
- # Com_2.png
- # Com_3.png...Com_999.png (最大值)
- #
- #==============================================================================
- #==============================================================================
- # 你需要把以上图片放在 /Graphics/Title1/
- #==============================================================================
- module MOG_TITLE_PICTURE_COMMANDS
- #--------------------------------------------------------------------------
- # 是否开启横向模式
- #--------------------------------------------------------------------------
- HORIZONTAL_MODE = false
- #--------------------------------------------------------------------------
- # 指令位置
- #--------------------------------------------------------------------------
- X_POS = 242
- Y_POS = 404
- #--------------------------------------------------------------------------
- # 指令间距
- #--------------------------------------------------------------------------
- X_SPACE = 0
- Y_SPACE = 13
- #--------------------------------------------------------------------------
- # 指令Z坐标
- #--------------------------------------------------------------------------
- SCREEN_Z = 90
- #--------------------------------------------------------------------------
- # 是否显示缩放效果
- #--------------------------------------------------------------------------
- ZOOM_EFFECT = false
- #--------------------------------------------------------------------------
- # 输入模式
- # 0 - 垂直 1 - 水平 2 - 垂直和水平
- #--------------------------------------------------------------------------
- INPUT_TYPE = 0
- #--------------------------------------------------------------------------
- # 是否显示指针. (需要图片 "Cursor.png")
- #--------------------------------------------------------------------------
- SPRITE_CURSOR = true
- #--------------------------------------------------------------------------
- # 指针位置
- #--------------------------------------------------------------------------
- SPRITE_CURSOR_X = -32
- SPRITE_CURSOR_Y = -16
- #--------------------------------------------------------------------------
- # 设置文件名
- #--------------------------------------------------------------------------
- FILE_NAME = "Com_"
- CURSOR_FILE_NAME = "Cursor"
-
- TITLENAME = [:开始游戏,:继续游戏,:成就,:结束游戏]
- end
- $imported = {} if $imported.nil?
- $imported[:mog_title_screen_picture_commands] = true
- #==============================================================================
- # ■ Window TittleCommand
- #==============================================================================
- class Window_TitleCommand < Window_Command
-
- #--------------------------------------------------------------------------
- # ● Down
- #--------------------------------------------------------------------------
- def cursor_down(wrap = false)
- return if !MOG_TITLE_PICTURE_COMMANDS::INPUT_TYPE == 0
- select((index + col_max) % item_max)
- end
-
- #--------------------------------------------------------------------------
- # ● Cursor Up
- #--------------------------------------------------------------------------
- def cursor_up(wrap = false)
- return if !MOG_TITLE_PICTURE_COMMANDS::INPUT_TYPE == 0
- select((index - col_max + item_max) % item_max)
- end
-
- #--------------------------------------------------------------------------
- # ● Cursor Right
- #--------------------------------------------------------------------------
- def cursor_right(wrap = false)
- return if !MOG_TITLE_PICTURE_COMMANDS::INPUT_TYPE == 1
- select((index + 1) % item_max)
- end
-
- #--------------------------------------------------------------------------
- # ● Cursor Left
- #--------------------------------------------------------------------------
- def cursor_left(wrap = false)
- return if !MOG_TITLE_PICTURE_COMMANDS::INPUT_TYPE == 1
- select((index - 1 + item_max) % item_max)
- end
-
- end
- #==============================================================================
- # ■ Scene Tittle
- #==============================================================================
- class Scene_Title < Scene_Base
- include MOG_TITLE_PICTURE_COMMANDS
- #--------------------------------------------------------------------------
- # ● Create Command Window
- #--------------------------------------------------------------------------
- alias mog_ts_picture_cm_create_command_window create_command_window
- def create_command_window
- mog_ts_picture_cm_create_command_window
- create_ts_picture_cm
- end
-
- #--------------------------------------------------------------------------
- # ● Terminate
- #--------------------------------------------------------------------------
- alias mog_ts_picture_cm_terminate terminate
- def terminate
- mog_ts_picture_cm_terminate
- dispose_ts_picture_cm
- end
-
- #--------------------------------------------------------------------------
- # ● Update
- #--------------------------------------------------------------------------
- alias mog_ts_picture_cm_update update
- def update
- mog_ts_picture_cm_update
- update_ts_picture_cm
- end
-
- #--------------------------------------------------------------------------
- # ● Create TS Picture CM
- #--------------------------------------------------------------------------
- def create_ts_picture_cm
- @command_window.visible = false ; @com_pictures = [[],[],[],[],[]]
- @command_window.list.each_with_index do |l, i|
- @com_pictures[0].push(Sprite.new)
- @bitmap1=Cache.title1(MOG_TITLE_PICTURE_COMMANDS::FILE_NAME.to_s)# + i.to_s)
- bitmap2 = Bitmap.new(316,26)
- rect = Rect.new(0, 0, 316, 26)
- bitmap2.blt(0, 0, @bitmap1, rect, 255)
- @com_pictures[0][i].bitmap =bitmap2
- draw_text(i)
- @com_pictures[0][i].ox = @com_pictures[0][i].bitmap.width / 2
- @com_pictures[0][i].oy = @com_pictures[0][i].bitmap.height / 2
- @com_pictures[0][i].z = MOG_TITLE_PICTURE_COMMANDS::SCREEN_Z
- sp = [MOG_TITLE_PICTURE_COMMANDS::X_SPACE * i, MOG_TITLE_PICTURE_COMMANDS::Y_SPACE * i]
- if MOG_TITLE_PICTURE_COMMANDS::HORIZONTAL_MODE
- @com_pictures[0][i].x = sp[0] + MOG_TITLE_PICTURE_COMMANDS::X_POS - @com_pictures[0][i].ox + (@com_pictures[0][i].bitmap.width * i)
- @com_pictures[0][i].y = sp[1] + MOG_TITLE_PICTURE_COMMANDS::Y_POS + @com_pictures[0][i].oy
- else
- @com_pictures[0][i].x = sp[0] + MOG_TITLE_PICTURE_COMMANDS::X_POS + @com_pictures[0][i].ox
- @com_pictures[0][i].y = sp[1] + MOG_TITLE_PICTURE_COMMANDS::Y_POS + @com_pictures[0][i].oy + (@com_pictures[0][i].bitmap.height * i)
- end
- @com_pictures[3][i] = [@com_pictures[0][i].x - @com_pictures[0][i].ox,@com_pictures[0][i].y - @com_pictures[0][i].oy]
- @com_pictures[1][i] = l[:enabled]
- @com_pictures[2][i] = 0
- end
- @npc = [-64,-64] ; create_tsprite_cursor
- end
-
- #--------------------------------------------------------------------------
- # ● Create Tsprite Cursor
- #--------------------------------------------------------------------------
- def create_tsprite_cursor
- return if !MOG_TITLE_PICTURE_COMMANDS::SPRITE_CURSOR
- @sprite_cursor = Sprite.new
- @sprite_cursor.bitmap = Cache.title1(MOG_TITLE_PICTURE_COMMANDS::CURSOR_FILE_NAME.to_s)
- @sprite_cursor.z = MOG_TITLE_PICTURE_COMMANDS::SCREEN_Z + 10
- @sprite_cursor.x = @com_pictures[3][0][0]
- @sprite_cursor.y = @com_pictures[3][0][1]
- @sprite_cursor.opacity = 0
- end
-
- #--------------------------------------------------------------------------
- # ● Update Sprite Cursor
- #--------------------------------------------------------------------------
- def update_tsprite_cursor
- return if !MOG_TITLE_PICTURE_COMMANDS::SPRITE_CURSOR
- @npc = [@com_pictures[3][@command_window.index][0] + MOG_TITLE_PICTURE_COMMANDS::SPRITE_CURSOR_X,
- @com_pictures[3][@command_window.index][1] + MOG_TITLE_PICTURE_COMMANDS::SPRITE_CURSOR_Y]
- execute_move_t_sprite(0,@sprite_cursor.x,@npc[0])
- execute_move_t_sprite(1,@sprite_cursor.y,@npc[1])
- @sprite_cursor.opacity += 15
- end
-
- #--------------------------------------------------------------------------
- # ● Execute Move T Sprite
- #--------------------------------------------------------------------------
- def execute_move_t_sprite(type,cp,np)
- sp = 5 + ((cp - np).abs / 5)
- if cp > np ; cp -= sp ; cp = np if cp < np
- elsif cp < np ; cp += sp ; cp = np if cp > np
- end
- @sprite_cursor.x = cp if type == 0 ; @sprite_cursor.y = cp if type == 1
- end
-
- #--------------------------------------------------------------------------
- # ● Dispose TS Picture CM
- #--------------------------------------------------------------------------
- def dispose_ts_picture_cm
- @com_pictures[0].each {|sprite| sprite.dispose }
- return if @sprite_cursor == nil
- @sprite_cursor.bitmap.dispose ; @sprite_cursor.dispose
- end
-
- #--------------------------------------------------------------------------
- # ● Update TS Picture CM
- #--------------------------------------------------------------------------
- def update_ts_picture_cm
- @command_window.visible = false ; @command_window.x = -2000
- for i in 0...@command_window.list.size
- if i == @command_window.index
- @com_pictures[2][i]=1
- if !@com_pictures[1][i]
- rect = Rect.new(316, 0, 316, 26)
- bitmap2=Bitmap.new(316,26)
- bitmap2.blt(0, 0, @bitmap1, rect, 255)
- @com_pictures[0][i].bitmap =bitmap2
- draw_text(i)
- else
- rect = Rect.new(632, 0, 316, 26)
- bitmap2=Bitmap.new(316,26)
- bitmap2.blt(0, 0, @bitmap1, rect, 255)
- @com_pictures[0][i].bitmap =bitmap2
- draw_text(i)
- end
- else
- if @com_pictures[2][i]=1
- rect = Rect.new(0, 0, 316, 26)
- bitmap2=Bitmap.new(316,26)
- bitmap2.blt(0, 0, @bitmap1, rect, 255)
- @com_pictures[0][i].bitmap =bitmap2
- draw_text(i)
- @com_pictures[2][i]=1
- end
- end
- end
- update_tsprite_cursor
- end
-
- def draw_text(i)
- @com_pictures[0][i].bitmap.font.size=16
- @com_pictures[0][i].bitmap.font.outline=false
- @com_pictures[0][i].bitmap.font.name="黑体"
- @com_pictures[0][i].bitmap.font.color=Color.new(0,0,0)
- @com_pictures[0][i].bitmap.draw_text(0,0,316,26,MOG_TITLE_PICTURE_COMMANDS::TITLENAME[i],1)
- end
-
- #--------------------------------------------------------------------------
- # ● Com Zoom Effect
- #--------------------------------------------------------------------------
- #~ def com_zoom_effect(i,type)
- #~ return if !MOG_TITLE_PICTURE_COMMANDS::ZOOM_EFFECT
- #~ if type == 0
- #~ if @com_pictures[2][i] == 0
- #~ @com_pictures[0][i].zoom_x += 0.01
- #~ @com_pictures[2][i] = 1 if @com_pictures[0][i].zoom_x >= 1.2
- #~ else
- #~ @com_pictures[0][i].zoom_x -= 0.01
- #~ @com_pictures[2][i] = 0 if @com_pictures[0][i].zoom_x <= 1.0
- #~ end
- #~ else
- #~ @com_pictures[2][i] = 0 ; @com_pictures[0][i].zoom_x -= 0.01
- #~ @com_pictures[0][i].zoom_x = 1.00 if @com_pictures[0][i].zoom_x < 1.00
- #~ end
- #~ @com_pictures[0][i].zoom_y = @com_pictures[0][i].zoom_x
- #~ end
-
- end
- #==============================================================================
- # ■ Window Command
- #==============================================================================
- class Window_Command < Window_Selectable
- attr_reader :list
- end
- end
复制代码
|
|