查看: 2786|回复: 2

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

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

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

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

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

是想用这个脚本在游戏播放影片,但是影片就这么扔在目录下实在太不好了,如果影片多的情况还会很乱,
所以请问有什么办法可以指定工程目录下的movie文件夹作为影片放置的地方呢?
脚本
  1. class String
  2.   
  3.   CP_ACP = 0
  4.   CP_UTF8 = 65001
  5.   
  6.   def u2s
  7.     m2w = Win32API.new("kernel32", "MultiByteToWideChar", "ilpipi", "i")
  8.     w2m = Win32API.new("kernel32", "WideCharToMultiByte", "ilpipipp", "i")
  9.    
  10.     len = m2w.call(CP_UTF8, 0, self, -1, nil, 0)
  11.     buf = "\0" * (len*2)
  12.     m2w.call(CP_UTF8, 0, self, -1, buf, buf.size/2)
  13.    
  14.     len = w2m.call(CP_ACP, 0, buf, -1, nil, 0, nil, nil)
  15.     ret = "\0" * len
  16.     w2m.call(CP_ACP, 0, buf, -1, ret, ret.size, nil, nil)
  17.    
  18.     return ret
  19.   end
  20.   
  21.   def s2u
  22.     m2w = Win32API.new("kernel32", "MultiByteToWideChar", "ilpipi", "i")
  23.     w2m = Win32API.new("kernel32", "WideCharToMultiByte", "ilpipipp", "i")
  24.   
  25.     len = m2w.call(CP_ACP, 0, self, -1, nil, 0);
  26.     buf = "\0" * (len*2)
  27.     m2w.call(CP_ACP, 0, self, -1, buf, buf.size/2);
  28.   
  29.     len = w2m.call(CP_UTF8, 0, buf, -1, nil, 0, nil, nil);
  30.     ret = "\0" * len
  31.     w2m.call(CP_UTF8, 0, buf, -1, ret, ret.size, nil, nil);
  32.      
  33.     return ret
  34.   end

  35.   def s2u!
  36.     self[0, length] = s2u
  37.   end  
  38.   
  39.   def u2s!
  40.     self[0, length] = u2s
  41.   end
  42.   
  43. end

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

  48.   def address
  49.     buffer, ad = "xxxx", object_id * 2 + 16
  50.     RtlMoveMemory_pi.call(buffer, ad, 4); ad = buffer.unpack("L")[0] + 8
  51.     RtlMoveMemory_pi.call(buffer, ad, 4); ad = buffer.unpack("L")[0] + 16
  52.     RtlMoveMemory_pi.call(buffer, ad, 4); return buffer.unpack("L")[0]
  53.   end
  54.   
  55. end

  56. class RMFlash

  57.         API_NEW                      = Win32API.new("RMFlash", "_new", "piil", "l")
  58.         API_UPDATE            = Win32API.new("RMFlash", "_update", "l", "v")
  59.         API_FREE              = Win32API.new("RMFlash", "_free", "l", "v")
  60.         API_PLAYING     = Win32API.new("RMFlash", "_is_playing", "l", "i")
  61.         API_PAUSE              = Win32API.new("RMFlash", "_pause", "l", "v")
  62.         API_RESUME            = Win32API.new("RMFlash", "_resume", "l", "v")
  63.         API_BACK              = Win32API.new("RMFlash", "_back", "l", "v")
  64.         API_REWIND            = Win32API.new("RMFlash", "_rewind", "l", "v")
  65.         API_FORWARD            = Win32API.new("RMFlash", "_forward", "l", "v")
  66.         API_CURFRAME          = Win32API.new("RMFlash", "_cur_frame", "l", "i")
  67.         API_TOTALFRAME        = Win32API.new("RMFlash", "_total_frames", "l", "i")
  68.         API_GOTOFRAME          = Win32API.new("RMFlash", "_goto_frame", "li", "v")
  69.         API_GETLOOP                  = Win32API.new("RMFlash", "_get_loop", "l", "i")
  70.         API_SETLOOP                  = Win32API.new("RMFlash", "_set_loop", "li", "v")
  71.         API_CLEARALL          = Win32API.new("RMFlash", "_clear_all", "v", "v")
  72.   API_VALID       = Win32API.new("RMFlash", "_valid", "l", "i")
  73.   API_SENDMSG     = Win32API.new("RMFlash", "_send_message", "liii", "l")
  74.        
  75.   CUR_PATH        = Dir.pwd
  76.   
  77.         def self.get_version

  78.         end

  79.         def self.clear_all
  80.                 API_CLEARALL.call
  81.         end
  82.   
  83.   def self.load(name, width, height, v = nil)
  84.     new("#{CUR_PATH}/#{name}".u2s, width, height, v)
  85.   end
  86.   
  87.   attr_reader   :valid

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

  95.         def viewport
  96.                 @sprite.viewport
  97.         end

  98.         def update
  99.                 API_UPDATE.call(@value)
  100.         end

  101.         def dispose
  102.                 API_FREE.call(@sprite.bitmap.address)
  103.     @sprite.bitmap.dispose
  104.     @sprite.dispose
  105.         end

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

  109.         def pause
  110.                 API_PAUSE.call(@value)
  111.         end

  112.         def resume
  113.                 API_RESUME.call(@value)
  114.         end

  115.         def back
  116.                 API_BACK.call(@value)
  117.         end

  118.         def rewind
  119.                 API_REWIND.call(@value)
  120.         end

  121.         def forward
  122.                 API_FORWARD.call(@value)
  123.         end

  124.         def current_frame
  125.                 API_CURFRAME.call(@value)
  126.         end

  127.         def total_frames
  128.                 API_TOTALFRAME.call(@value)
  129.         end

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

  133.         def x
  134.                 @sprite.x
  135.         end

  136.         def x=(v)
  137.                 @sprite.x = v
  138.         end

  139.         def y
  140.                 @sprite.y
  141.         end

  142.         def y=(v)
  143.                 @sprite.y = v
  144.         end

  145.         def z
  146.                 @sprite.z
  147.         end

  148.         def z=(v)
  149.                 @sprite.z = v
  150.         end

  151.         def width
  152.                 @sprite.bitmap.width
  153.         end

  154.         def height
  155.                 @sprite.bitmap.height
  156.         end

  157.         def loop?
  158.                 @loop
  159.         end

  160.         def loop=(v)
  161.                 if @loop != v
  162.                         @loop = v
  163.                         API_SETLOOP.call(@value, v)
  164.                 end
  165.         end
  166.   
  167.   def msg_to_flash(msg, wParam, lParam)
  168.     return API_SENDMSG.call(@value, msg, wParam, lParam)
  169.   end
  170.   
  171.   #  例
  172.   WM_MOUSEMOVE  = 0x0200
  173.   
  174.   def make_long(a, b)
  175.     return (a & 0xffff ) | (b & 0xffff) << 16
  176.   end
  177.   
  178.   def on_mouse_move(x, y)
  179.     return msg_to_flash(WM_MOUSEMOVE, 0, make_long(x, y))
  180.   end

  181. end

  182. module Kernel

  183.   alias origin_exit exit unless method_defined? :exit
  184.   
  185.   def exit(*args)
  186.     RMFlash.clear_all
  187.     origin_exit(*args)
  188.   end
  189.   
  190. end

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

  192. #while true
  193. #        Graphics.update
  194. #        Input.update
  195. #        fls.update
  196. #        break if Input.trigger?(13)
  197. #end
  198. #fls.dispose

  199. #exit

  200. =begin
  201. class RMFlash
  202.   API_NEW = Win32API.new("RMFlash", "_new", "piil", "l")
  203.   API_UPDATE = Win32API.new("RMFlash", "_update", "l", "v")
  204.   API_FREE = Win32API.new("RMFlash", "_free", "l", "v")
  205.   #def self.new(*args)
  206.   #  obj = super(*args)
  207.   #  obj.send :initialize, *args
  208.   #  obj
  209.   #end
  210.   
  211.   def initialize(flashname, fw, fh)
  212.    
  213.   end
  214.   
  215. end

  216. RMFlash.new
  217. exit
  218. =end



























复制代码

【四季】已上架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.

在本版发帖返回顶部