查看: 2719|回复: 2

[已经解决] 关于Flash播放器目录下创建指定文件夹

[复制链接]
梦石
0
星屑
4935
在线时间
918 小时
注册时间
2015-7-1
回帖
309
发表于 2018-1-7 22:53:22 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

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

×
本帖最后由 L7-wind 于 2018-1-7 22:52 编辑

是想用这个脚本在游戏播放影片,但是影片就这么扔在目录下实在太不好了,如果影片多的情况还会很乱,
所以请问有什么办法可以指定工程目录下的movie文件夹作为影片放置的地方呢?
[fold=脚本][pre lang="ruby"]class String
  
  CP_ACP = 0
  CP_UTF8 = 65001
  
  def u2s
    m2w = Win32API.new("kernel32", "MultiByteToWideChar", "ilpipi", "i")
    w2m = Win32API.new("kernel32", "WideCharToMultiByte", "ilpipipp", "i")
   
    len = m2w.call(CP_UTF8, 0, self, -1, nil, 0)
    buf = "\0" * (len*2)
    m2w.call(CP_UTF8, 0, self, -1, buf, buf.size/2)
   
    len = w2m.call(CP_ACP, 0, buf, -1, nil, 0, nil, nil)
    ret = "\0" * len
    w2m.call(CP_ACP, 0, buf, -1, ret, ret.size, nil, nil)
   
    return ret
  end
  
  def s2u
    m2w = Win32API.new("kernel32", "MultiByteToWideChar", "ilpipi", "i")
    w2m = Win32API.new("kernel32", "WideCharToMultiByte", "ilpipipp", "i")
  
    len = m2w.call(CP_ACP, 0, self, -1, nil, 0);
    buf = "\0" * (len*2)
    m2w.call(CP_ACP, 0, self, -1, buf, buf.size/2);
  
    len = w2m.call(CP_UTF8, 0, buf, -1, nil, 0, nil, nil);
    ret = "\0" * len
    w2m.call(CP_UTF8, 0, buf, -1, ret, ret.size, nil, nil);
     
    return ret
  end

  def s2u!
    self[0, length] = s2u
  end  
  
  def u2s!
    self[0, length] = u2s
  end
  
end

class Bitmap
  
  RtlMoveMemory_pi = Win32API.new('kernel32', 'RtlMoveMemory', 'pii', 'i')
  RtlMoveMemory_ip = Win32API.new('kernel32', 'RtlMoveMemory', 'ipi', 'i')

  def address
    buffer, ad = "xxxx", object_id * 2 + 16
    RtlMoveMemory_pi.call(buffer, ad, 4); ad = buffer.unpack("L")[0] + 8
    RtlMoveMemory_pi.call(buffer, ad, 4); ad = buffer.unpack("L")[0] + 16
    RtlMoveMemory_pi.call(buffer, ad, 4); return buffer.unpack("L")[0]
  end
  
end

class RMFlash

        API_NEW                      = Win32API.new("RMFlash", "_new", "piil", "l")
        API_UPDATE            = Win32API.new("RMFlash", "_update", "l", "v")
        API_FREE              = Win32API.new("RMFlash", "_free", "l", "v")
        API_PLAYING     = Win32API.new("RMFlash", "_is_playing", "l", "i")
        API_PAUSE              = Win32API.new("RMFlash", "_pause", "l", "v")
        API_RESUME            = Win32API.new("RMFlash", "_resume", "l", "v")
        API_BACK              = Win32API.new("RMFlash", "_back", "l", "v")
        API_REWIND            = Win32API.new("RMFlash", "_rewind", "l", "v")
        API_FORWARD            = Win32API.new("RMFlash", "_forward", "l", "v")
        API_CURFRAME          = Win32API.new("RMFlash", "_cur_frame", "l", "i")
        API_TOTALFRAME        = Win32API.new("RMFlash", "_total_frames", "l", "i")
        API_GOTOFRAME          = Win32API.new("RMFlash", "_goto_frame", "li", "v")
        API_GETLOOP                  = Win32API.new("RMFlash", "_get_loop", "l", "i")
        API_SETLOOP                  = Win32API.new("RMFlash", "_set_loop", "li", "v")
        API_CLEARALL          = Win32API.new("RMFlash", "_clear_all", "v", "v")
  API_VALID       = Win32API.new("RMFlash", "_valid", "l", "i")
  API_SENDMSG     = Win32API.new("RMFlash", "_send_message", "liii", "l")
       
  CUR_PATH        = Dir.pwd
  
        def self.get_version

        end

        def self.clear_all
                API_CLEARALL.call
        end
  
  def self.load(name, width, height, v = nil)
    new("#{CUR_PATH}/#{name}".u2s, width, height, v)
  end
  
  attr_reader   :valid

        def initialize(flash_name, flash_width, flash_height, viewport = nil)
                @sprite = Sprite.new(viewport)
                @sprite.bitmap = Bitmap.new(flash_width, flash_height)
                @value = API_NEW.call(flash_name, flash_width, flash_height, @sprite.bitmap.address)
                @loop = API_GETLOOP.call(@value) > 0
    @valid = API_VALID.call(@value) > 0
        end

        def viewport
                @sprite.viewport
        end

        def update
                API_UPDATE.call(@value)
        end

        def dispose
                API_FREE.call(@sprite.bitmap.address)
    @sprite.bitmap.dispose
    @sprite.dispose
        end

        def playing?
                API_PLAYING.call(@value) > 0
        end

        def pause
                API_PAUSE.call(@value)
        end

        def resume
                API_RESUME.call(@value)
        end

        def back
                API_BACK.call(@value)
        end

        def rewind
                API_REWIND.call(@value)
        end

        def forward
                API_FORWARD.call(@value)
        end

        def current_frame
                API_CURFRAME.call(@value)
        end

        def total_frames
                API_TOTALFRAME.call(@value)
        end

        def goto_frame(goal_frame)
                API_GOTOFRAME.call(@value, goal_frame)
        end

        def x
                @sprite.x
        end

        def x=(v)
                @sprite.x = v
        end

        def y
                @sprite.y
        end

        def y=(v)
                @sprite.y = v
        end

        def z
                @sprite.z
        end

        def z=(v)
                @sprite.z = v
        end

        def width
                @sprite.bitmap.width
        end

        def height
                @sprite.bitmap.height
        end

        def loop?
                @loop
        end

        def loop=(v)
                if @loop != v
                        @loop = v
                        API_SETLOOP.call(@value, v)
                end
        end
  
  def msg_to_flash(msg, wParam, lParam)
    return API_SENDMSG.call(@value, msg, wParam, lParam)
  end
  
  #  例
  WM_MOUSEMOVE  = 0x0200
  
  def make_long(a, b)
    return (a & 0xffff ) | (b & 0xffff) << 16
  end
  
  def on_mouse_move(x, y)
    return msg_to_flash(WM_MOUSEMOVE, 0, make_long(x, y))
  end

end

module Kernel

  alias origin_exit exit unless method_defined? :exit
  
  def exit(*args)
    RMFlash.clear_all
    origin_exit(*args)
  end
  
end

#fls = RMFlash.load("2.swf", 640, 480)

#while true
#        Graphics.update
#        Input.update
#        fls.update
#        break if Input.trigger?(13)
#end
#fls.dispose

#exit

=begin
class RMFlash
  API_NEW = Win32API.new("RMFlash", "_new", "piil", "l")
  API_UPDATE = Win32API.new("RMFlash", "_update", "l", "v")
  API_FREE = Win32API.new("RMFlash", "_free", "l", "v")
  #def self.new(*args)
  #  obj = super(*args)
  #  obj.send :initialize, *args
  #  obj
  #end
  
  def initialize(flashname, fw, fh)
   
  end
  
end

RMFlash.new
exit
=end



























[/pre][/fold]
【四季】已上架steam!欢迎大家来玩!
梦石
1
星屑
24088
在线时间
3339 小时
注册时间
2011-7-8
回帖
3862

开拓者

发表于 2018-1-7 23:12:34 | 显示全部楼层
本帖最后由 guoxiaomi 于 2018-1-7 23:13 编辑

80 行改为:
  1. CUR_PATH        = Dir.pwd + '/movie'
复制代码

点评

完美的解决了我的问题!赞~  发表于 2018-1-8 08:39

评分

参与人数 2星屑 +66 赞 +1 收起 理由
fux2 + 66 塞糖
L7-wind + 1 认可答案

查看全部评分

熟悉rgss和ruby,xp区版主~
正在填坑:《膜拜组传奇》讲述膜拜组和学霸们的故事。
已上steam:与TXBD合作的Reformers《变革者》
* 战斗调用公共事件 *
* RGSOS 网络脚本 *
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部