设为首页 收藏本站
登录 /立即注册 /找回密码

URPGs

快捷导航
  • 门户Portal
  • 论坛BBS
  • 群组Group
  • 导读Guide
  • 家园Space
  • 工具Tools
  • 广播Follow
  • 期刊Periodical
  • 排行榜Ranklist
  • 社区茶坊
  • pixlr图片编辑
  • 资源列表
  • photobucket
  • RMVA Lite [In English]
  • RM RTP
  • TryRUBY
  • RMXP+RMVX下载[VeryCD]
  • RMVA下载[66RPG]
搜索
  • 本版
  • 帖子
  • 用户
URPGs»论坛 › 技术讨论 › 技术讨论 › 【搬运】仿SAO菜单提示效果
返回列表 发新帖
查看: 4657|回复: 1

[RMVA 技术讨论] 【搬运】仿SAO菜单提示效果

[复制链接]
鑫晴
鑫晴 当前离线
积分
3
查看详细资料 窥视卡 雷达卡
发表于 2013-8-26 17:33:28 | 显示全部楼层 |阅读模式
本帖最后由 鑫晴 于 2013-8-26 17:40 编辑

                                                                                                                             
                       要提前说一下,这脚本只是搬运过来的,

                                        6R的沙漠点灰发的主题

               简单OSU!解释器+仿刀剑神域物品获得提示[添加网盘地址]

                                  从6R过来的人应该都知道的。

                                                                                                                            
                                                                                                                                                                                      

            先上图:















                                                                                                

       不得不说,真的很厉害!

                                                                                                


附件:

请将XX.001.7z改为XX.7z.001
请将XX.002.7z改为XX.7z.002
请将XX.003.7z改为XX.7z.003











详细说明请看:

简单OSU!解释器+仿刀剑神域物品获得提示[添加网盘地址]





说说脚本吧,我好不容易把相关的脚本从他那里分离出来了。。。

                                                                                                                                                                                                            

【Sprite X Math X Bitmap】

[code=ruby]#encoding:utf-8
#==============================================================================
# ■ Sprite
#------------------------------------------------------------------------------
#  RGSS
#==============================================================================

class Sprite
        #--------------------------------------------------------------------------
        # ● 移动到
        #--------------------------------------------------------------------------
        def move_to(x, y, zoom, duration, opa=nil)
                @old_x = self.x
                @old_y = self.y
                @target_x = (x ? x : self.x)
                @target_y = (y ? y : self.y)
                @old_zoom = self.zoom_x
                @target_zoom = (zoom ? zoom : self.zoom_x)
                @target_opa = (opa ? opa : @target_opa)
                @old_opa = self.opacity
                @duration = duration
                @duration_full = duration.to_f
        end
        #--------------------------------------------------------------------------
        # ● 刷新移动
        #--------------------------------------------------------------------------
        def move_update
                return true if @duration.nil? or @duration <= 0
                @duration -= 1
                var = 1-Math.f(@duration/@duration_full+1)
                self.x = (@old_x + (@target_x-@old_x) *var+0.5).to_i
                self.y = (@old_y + (@target_y-@old_y) *var+0.5).to_i
                self.zoom_x = @old_zoom + (@target_zoom-@old_zoom) *var
                self.zoom_y  = self.zoom_x
                self.opacity = (@old_opa + (@target_opa - @old_opa)*var+0.5).to_i if @target_opa
                false
        end
end
def Math.f(x)
        return self.f(x+2) if x < 0
        return self.f(x-2) if x > 2
        (x-1)**2
end
class Bitmap
        def make_blt_rect(w, h)
                if self.width*h>=self.height*w # 切左右
                        t=self.height*w/h
                        return Rect.new((self.width-t)/2,0 , t, self.height)
                else # 切上下
                        t=self.width*h/w
                        return Rect.new(0, (self.height-t)/2, self.width, t)
                end
        end
end[/code]



                                                                                                                                                                                                

  Spriteset_Map

[code=ruby]#encoding:utf-8
#==============================================================================
# ■ Spriteset_Map
#------------------------------------------------------------------------------
#  处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。
#==============================================================================

class Spriteset_Map
        SHOW_WAIT_THRESHOLD = 3 # 允许等待显示帧数,0的话就是得到物品后立即显示
                                # 如果有多个物品的话,呵呵
        #--------------------------------------------------------------------------
        # ● 初始化对象
        #--------------------------------------------------------------------------
        alias initialize_old_dust initialize
        def initialize
                @_sao_counter = 0
                $game_temp.item_show ||= {}
                initialize_old_dust
        end
        #--------------------------------------------------------------------------
        # ● 刷新
        #--------------------------------------------------------------------------
        alias update_old_dust update
        def update
                update_old_dust
                if $game_temp.item_show.size > 0
                        @_sao_counter += 1
                        return show_item_getted if @_sao_counter >= SHOW_WAIT_THRESHOLD
                end
        end
        #--------------------------------------------------------------------------
        # ● 获取物品
        #--------------------------------------------------------------------------
        def show_item_getted
                #
                ary = []
                $game_temp.item_show.each{|key, value|
                        ary << [key, value]
                }
                SAO.callMSGBOX(ary, [[:String, "◆BONUSITEM◆"]])
                $game_temp.item_show.clear
                @_sao_counter = 0
        end
end[/code]


                                                                                                                                                                                                  

Game_Interpreter

[code=ruby]#encoding:utf-8
#==============================================================================
# ■ Game_Interpreter
#------------------------------------------------------------------------------
#  事件指令的解释器。
#   本类在 Game_Map、Game_Troop、Game_Event 类的内部使用。
#==============================================================================

class Game_Interpreter
        #--------------------------------------------------------------------------
        # ● 增减物品
        #--------------------------------------------------------------------------
        def command_126
                value = operate_value(@params[1], @params[2], @params[3])
                $game_temp.item_show ||= {}
                $game_temp.item_show[$data_items[@params[0]]] ||= 0
                $game_temp.item_show[$data_items[@params[0]]] += value
                $game_party.gain_item($data_items[@params[0]], value)
        end
        #--------------------------------------------------------------------------
        # ● 增减武器
        #--------------------------------------------------------------------------
        def command_127
                value = operate_value(@params[1], @params[2], @params[3])
                $game_temp.item_show ||= {}
                $game_temp.item_show[$data_weapons[@params[0]]] ||= 0
                $game_temp.item_show[$data_weapons[@params[0]]] += value
                $game_party.gain_item($data_weapons[@params[0]], value, @params[4])
        end
        #--------------------------------------------------------------------------
        # ● 增减护甲
        #--------------------------------------------------------------------------
        def command_128
                value = operate_value(@params[1], @params[2], @params[3])
                $game_temp.item_show ||= {}
                $game_temp.item_show[$data_armors[@params[0]]] ||= 0
                $game_temp.item_show[$data_armors[@params[0]]] += value
                $game_party.gain_item($data_armors[@params[0]], value, @params[4])
        end
end[/code]



                                                                                                                                                                                                  


●Game_Temp

[code=ruby]class Game_Temp
  attr_accessor :item_show                # SAO 式物品显示
end[/code]


                                                                                                                                                                                                  


●SAO MessageBox

[code=ruby]#==============================================================================
# ■ Sword Art Online
#------------------------------------------------------------------------------
#  储存SAO常量及特殊方法
#==============================================================================
class Bitmap
        @@fontName = ["sao", "SimHei"]
        def draw_textSAO(x, y, text)
                self.font.outline = false
                xPlus = 0
                tSize = font.size
                tHalf = ::SAO::FONT_SIZE-1
                text.gsub!("\\n") {"\n"}
                text.split(//).each{|char|
                        if char == "\n"
                                y+=self.font.size
                                xPlus = 0
                                next
                        end
                        if char.ord > 0xFF
                                self.font.name = @@fontName[1]
                                self.font.size = tSize-::SAO::FONT_SIZE
                                fontSizeRect = text_size(char)
                                draw_text(x+xPlus, y+tHalf, fontSizeRect.width+2, fontSizeRect.height, char)
                                xPlus += fontSizeRect.width+2
                        else
                                self.font.name = @@fontName[0]
                                self.font.size = tSize               
                                fontSizeRect = text_size(char)
                                draw_text(x+xPlus, y, fontSizeRect.width, fontSizeRect.height, char)
                                xPlus += fontSizeRect.width
                        end
                }
                self.font.size = tSize               
                self.font.name = @@fontName[0]
        end
end
module SAO
        SAO_GREY                = Color.new(90, 90, 90)
        HEIGHT                  = 46
        PRESS_SHOW_COUNT        =  5        # 点击效果延长显示帧数
        BTN_INIT_HRIGHT         = 50        # 初始化下落高度
        BTN_INIT_COUNT          = 10        # 初始化效果帧数
        BTN_INIT_COUNT_ADD      =  5        # 后续初始化效果增加帧数
        FONT_SIZE               =  5        # 中文字体减小大小
        
        def self.f(x)
                return self.f(x+1) if x < 0
                return self.f(x-1) if x > 2
                (x-1)**2
        end
        def self.makeY(a, b, c)
                c%2 == 0 ? (((a-b)%c-c/2)%c) : (((a-1-b)%c-c/2)%c)
        end
        def self.callMSGBOX(*arg)
                $game_topZ = 4096
                tmpRate = Graphics.frame_rate
                sao = ::Sword_Art_Online_MessageBox.new(*arg)
                Graphics.frame_rate = 60
                loop {Graphics.update;Input.update;sao.update;break if sao.phase == :exit}
                sao.dispose
                Graphics.frame_rate = tmpRate
                nil
        end
        def self.callMSGBOX_EX(t, c)
                if c.is_a?(Array)
                        a = []
                        c.each{|i|a<<[nil,i]}
                        self.callMSGBOX(a, [[:String, t]])
                else
                        self.callMSGBOX([[nil, c]], [[:String, t]])
                end
        end
end
#==============================================================================
# ■ Sword_Art_Online_MessageBox
#------------------------------------------------------------------------------
#  刀剑神域        消息盒子
#==============================================================================

class Sword_Art_Online_MessageBox
        SHOW_COUNT           = 30     # 显示一行帧数
        ZOOM_COUNT           = 10     # 缩放帧数
        SCROLL_COUNT         = 15     # 滚动帧数
        
        LINE_HEIGHT          =  5     # 临时分界线位图高度
        
        HEAD_INIT_8          = 16     # 顶层不动位置0~它
        HEAD_INIT_5          = 46     # 顶层复制位置
        
        YFix                 = 32     # 整体向上移动距离
        
        MDL_ADD_HEIGHT       = 26     # 中间层复制基础量
        CONTENT_TEXT_X       = 80     # 中间层文字刻画X坐标
        CONTENT_ICON_X       = 70     # 中间层图标刻画X坐标
        
        #~ CONTENT_FONT_S       = 24     # 中间层文字大小
        
        TOW_X1               = 32     # 显示2、3个时, 第一个的X坐标
        TOW_X2               =280     # 显示2、3个时, 最后个的X坐标
        TOW_XM               =170     # 中间坐标
        attr_reader      :bool_SAOLeft
        attr_reader      :phase
        #--------------------------------------------------------------------------
        # ● 初始化对像
        #--------------------------------------------------------------------------
        def initialize(contents=[[nil, "文字测试"]], title=[[:String, "Message"]], x=0, y=0, &block)
                @contents = contents
                @box_viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
                @box_viewport.z = $game_topZ
                @box8 = Sprite.new(@box_viewport)
                @box8.bitmap = makeHead(title)
                @box8.ox = @box8.bitmap.width/2
                @box8.oy = @box8.bitmap.height
                @box8.x = Graphics.width/2 + x
                @box8.y = Graphics.height/2-YFix + y
                @box8.opacity = 0
                @box8.zoom_x = @box8.zoom_y = 0.0
               
                @box2 = Sprite.new(@box_viewport)
                @box2.bitmap = Cache.picture("box2")
                @box2.ox = @box2.bitmap.width/2
                @box2.x = @box8.x
                @box2.y = @box8.y-1
                @box2.opacity = 0
                @box2.zoom_x = @box2.zoom_y = 0.0
               
                @box5 = Sprite.new(@box_viewport)
                tBMP = Cache.picture("box5")
                @box5.bitmap = Bitmap.new(tBMP.width, tBMP.font.size*contents.size+MDL_ADD_HEIGHT)
                @box5.bitmap.font.name = 'sao'
                @box5.bitmap.font.color = SAO::SAO_GREY
                makeContent!(@box5.bitmap, tBMP)
                @box5.ox = @box5.bitmap.width/2
                @box5.x = @box8.x
                @box5.y = @box2.y+1
               
                @box5.src_rect.height = 0
                @phase = :zoom_out
                @phaseCounter = ZOOM_COUNT
                @bool_SAOLeft = false
                @block = block
                @block_called = false
        end
        #--------------------------------------------------------------------------
        # ● 生成内容!
        #--------------------------------------------------------------------------
        def makeContent!(bitmap, bBmp)
                bitmap.height.times{|y|bitmap.blt(0, y, bBmp, bBmp.rect)}
                @contents.each_with_index{|content, index|
                        nowY = MDL_ADD_HEIGHT/2+bitmap.font.size*index
                        if content[0] # 图标
                                icon_index = content[0].icon_index
                                icobmp = Cache.system("Iconset")
                                rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
                                bitmap.blt(TOW_X1,        nowY, icobmp, rect)
                                bitmap.draw_textSAO(CONTENT_TEXT_X, nowY, content[0].name)
                                bitmap.draw_textSAO(TOW_X2, nowY, "×#{content[1]}")
                                next
                        end
                        bitmap.draw_textSAO(CONTENT_TEXT_X, nowY, content[1])
                }
        end
        #--------------------------------------------------------------------------
        # ● 重新刻画内容
        #--------------------------------------------------------------------------
        def redrawC(c)
                @contents = c
                @box5.bitmap.clear
                makeContent!(@box5.bitmap, Cache.picture("box5"))
        end
        #--------------------------------------------------------------------------
        # ● 刷新放大效果
        #--------------------------------------------------------------------------
        def update_zoom_out
                @phaseCounter -= 1
                vul = SAO.f(@phaseCounter.to_f/ZOOM_COUNT)
                @box8.opacity = (vul*255).to_i
                @box8.zoom_x = @box8.zoom_y = vul
                @box2.opacity = @box8.opacity
                @box2.zoom_x = @box2.zoom_y =         @box8.zoom_x
                if @phaseCounter <= 0
                        @box2.y+=1
                        @box8.zoom_x = @box8.zoom_y = 1.0
                        @box2.zoom_x = @box2.zoom_y = 1.0
                        @box8.opacity = 255
                        @box2.opacity = 255
                        @box8.move_to(nil, @box8.y-@box5.bitmap.height/2, nil, SCROLL_COUNT)
                        @box2.move_to(nil, @box8.y+@box5.bitmap.height/2, nil, SCROLL_COUNT)
                        @phase = :scrolling_out
                        playOUTSE
                        return @phaseCounter = SCROLL_COUNT
                end
        end
        #--------------------------------------------------------------------------
        # ● 刷新缩小效果
        #--------------------------------------------------------------------------
        def update_zoom_in
                @phaseCounter -= 1
                vul = SAO.f(@phaseCounter.to_f/ZOOM_COUNT)
                @box8.opacity = 255-(vul*255).to_i
                @box8.zoom_x = @box8.zoom_y = 1.0 - vul
                @box2.opacity = @box8.opacity
                @box2.zoom_x = @box2.zoom_y =         @box8.zoom_x
                if @phaseCounter <= 0
                        @phase = :exit
                end
        end
        #--------------------------------------------------------------------------
        # ● 展开音效
        #--------------------------------------------------------------------------
        def playOUTSE
                Audio.se_play("Audio/SE/msg")
        end
        #--------------------------------------------------------------------------
        # ● 刷新展开效果
        #--------------------------------------------------------------------------
        def update_scrolling_out
                @phaseCounter -= 1
                @box8.move_update
                @box2.y = Graphics.height-YFix*2-@box8.y
                @box5.src_rect.height = (@box2.y-Graphics.height/2+YFix)*2
                @box5.src_rect.y = (@box5.bitmap.height-@box5.src_rect.height)/2
                @box5.oy = @box5.src_rect.height/2
                if @phaseCounter <= 0
                        @phase = :showing
                        return @phaseCounter = getShowCount
                end
        end
        #--------------------------------------------------------------------------
        # ● 刷新闭合效果
        #--------------------------------------------------------------------------
        def update_scrolling_in
                @phaseCounter -= 1
                @box8.move_update
                @box2.y = Graphics.height-YFix*2-@box8.y
                @box5.src_rect.height = (@box2.y-Graphics.height/2+YFix)*2
                @box5.src_rect.y = (@box5.bitmap.height-@box5.src_rect.height)/2
                @box5.oy = @box5.src_rect.height/2
                if @phaseCounter <= 0
                        @box8.y = Graphics.height/2-YFix
                        @box2.y = @box8.y-1
                        @box5.src_rect.height = 0
                        @phase = :zoom_in
                        return @phaseCounter = ZOOM_COUNT
                end
        end
        #--------------------------------------------------------------------------
        # ● 刷新显示
        #--------------------------------------------------------------------------
        def update_showing
                @phaseCounter -= 1
                if @phaseCounter <= 0
                        @box8.move_to(nil, Graphics.height/2-YFix, nil, SCROLL_COUNT)
                        @box2.move_to(nil, Graphics.height/2-YFix+1, nil, SCROLL_COUNT)
                        @phase = :scrolling_in
                        return @phaseCounter = SCROLL_COUNT
                end
        end
        #--------------------------------------------------------------------------
        # ● 获取显示帧数
        #--------------------------------------------------------------------------
        def getShowCount
                SHOW_COUNT * @contents.size
        end
        #--------------------------------------------------------------------------
        # ● 刷新
        #--------------------------------------------------------------------------
        def update
                case @phase
                when :zoom_out
                        update_zoom_out
                when :scrolling_out
                        update_scrolling_out
                when :showing
                        update_showing
                when :scrolling_in
                        update_scrolling_in
                when :zoom_in
                        update_zoom_in
                end
                #~ if (!@block_called || Mouse.trigger?(Mouse::RIGHT)) && @phase == :showing
                #~ @block_called = true
                #~ if @block
                #~ re = @block.call
                #~ eval(re) if re.is_a?(String)
                #~ end
                #~ end
        end
        #--------------------------------------------------------------------------
        # ● 释放对像
        #--------------------------------------------------------------------------
        def dispose
                @box2.dispose
                @box5.dispose
                @box5.bitmap.dispose
                @box8.dispose
                @box8.bitmap.dispose
                @box_viewport.dispose
        end
        #--------------------------------------------------------------------------
        # ● 生成头部 title.size-1的数来刻画分界线
        #--------------------------------------------------------------------------
        def makeHead(title)
                tBMP = Cache.picture("box8")
                reBMP= Bitmap.new(tBMP.width, (title.size-1)*HEAD_INIT_5+tBMP.height)
                reBMP.font.color = SAO::SAO_GREY
                reBMP.font.name = "SAO"
                # 复制位图信息
                bltRect = Rect.new(0, 0, tBMP.width, HEAD_INIT_8)
                reBMP.blt(0, 0, tBMP, bltRect)
                bltRect.set(0, HEAD_INIT_8, tBMP.width, HEAD_INIT_5)
                title.size.times{|i|
                        reBMP.blt(0, HEAD_INIT_8+i*HEAD_INIT_5, tBMP, bltRect)
                }
                bltRect.set(0, HEAD_INIT_8+HEAD_INIT_5, tBMP.width, tBMP.height-HEAD_INIT_8-HEAD_INIT_5)
                reBMP.blt(0, title.size*HEAD_INIT_5+HEAD_INIT_8, tBMP, bltRect)
               
                title.each_with_index{|i, index|
                        if index > 0 # 分割线生成
                                lineBitmap = Bitmap.new(tBMP.width, LINE_HEIGHT)
                                lineWidth  = tBMP.width*17/20
                                lineBitmap.fill_rect((tBMP.width-lineWidth)/2,
                                        LINE_HEIGHT/2-1, lineWidth, 3, Color.new(100, 100, 100, 100))
                                
                                lineBitmap.fill_rect((tBMP.width-lineWidth)/2,
                                        LINE_HEIGHT/2,lineWidth, 1, Color.new(100, 100, 100))
                                
                                lineBitmap.blur
                                
                                reBMP.blt(0, index*HEAD_INIT_5+HEAD_INIT_8, lineBitmap, lineBitmap.rect)
                                
                                lineBitmap.dispose
                        end
                        case i[0]
                        when :String
                                rStrBMPRect = reBMP.text_size(i[1])
                                reBMP.draw_textSAO((reBMP.width-rStrBMPRect.width)/2,
                                        index*HEAD_INIT_5+HEAD_INIT_8+(HEAD_INIT_5-rStrBMPRect.height)/2, i[1])
                        when :Three
                                reBMP.draw_textSAO(TOW_X1,
                                        index*HEAD_INIT_5+HEAD_INIT_8+(HEAD_INIT_5-reBMP.font.size)/2, i[1])
                                reBMP.draw_textSAO(TOW_X2,
                                        index*HEAD_INIT_5+HEAD_INIT_8+(HEAD_INIT_5-reBMP.font.size)/2, i[2])
                                reBMP.draw_textSAO(TOW_XM,
                                        index*HEAD_INIT_5+HEAD_INIT_8+(HEAD_INIT_5-reBMP.font.size)/2, i[3]) if i[3]
                        end
                }
                reBMP
        end
end[/code]



                                                                                                                                                                                                  

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×

评分

参与人数 1金币 +1 银币 +5 经验 +100 收起 理由
水终结者 + 1 + 5 + 100 塞糖~

查看全部评分

回复

使用道具 举报

  • 提升卡
  • 置顶卡
  • 沉默卡
  • 喧嚣卡
  • 变色卡
  • 抢沙发
  • 千斤顶
  • 显身卡
鑫晴
鑫晴 当前离线
积分
3
查看详细资料 窥视卡 雷达卡
 楼主| 发表于 2013-8-26 17:51:52 | 显示全部楼层
本帖最后由 鑫晴 于 2013-8-26 17:56 编辑

喔,忘了说一点,关于显示文章的,需要在事件中插入脚本:

[code=ruby]SAO.callMSGBOX_EX[/code]




比如“

=======================================================

SAO.callMSGBOX_EX("单行测试", "卧槽")

=======================================================

SAO.callMSGBOX_EX("多行测试", ["卧槽", "这泥煤竟然是第二行","这是第三行"])

=======================================================

SAO.callMSGBOX([[nil, "第一行"],
[nil, "第二行"]],[[:String, "原始方法"],
[:String, "这泥煤竟然是第二行"]])

=======================================================


评分

参与人数 1经验 +10 收起 理由
水终结者 + 10 赞一个! 很负责。

查看全部评分

回复 Like Dislike

使用道具 举报

  • 显身卡
返回列表 发新帖
高级模式
B Color Image Link Quote Code Smilies
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

站点统计|Archiver|手机版|意见反馈[feedback]| URPGs RPG Maker 游戏制作讨论

GMT+8, 2025-5-9 22:20 , Processed in 0.030412 second(s), 11 queries .

Powered by Discuz! X3.5

© 2011-2019 URPGs (Discuz! X3.4 © 2001-2019 Comsenz Inc.)

积分 0, 距离下一级还需 积分
快速回复 返回顶部 返回列表