Project1
标题:
怎样让RMXP放视频动画
[打印本页]
作者:
qw499032252
时间:
2010-8-19 12:43
标题:
怎样让RMXP放视频动画
怎样让RMXP放视频动画如果要脚本的话把脚本发过来
作者:
qw499032252
时间:
2010-8-19 12:47
加一句怎样使用
作者:
497406594
时间:
2010-8-19 14:55
本帖最后由 497406594 于 2010-8-19 18:24 编辑
下面是我自己在用的FLASH播放器,可以播放swf格式的
LZ可以先用格式工厂转换下格式,这个大家基本都知道怎么转了
之前用过AVI播放器,可是太麻烦了,弄到最后还是只听到声音,没了图像
这个好些,效果很不错,不过我自己遇到的一些问题就是,播放完之后要等1小点时间才能关掉
如果是转移场所的话他就立刻关了。这是我自己测试自己视频后得出的结论
不知道楼主会不会这样,我在最下面附上使用方法
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)
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
复制代码
楼主可以按照这个来调整,我自己感觉这样最佳
未命名.jpg
(25.49 KB, 下载次数: 12)
下载附件
保存到相册
2010-8-19 14:54 上传
把2句脚本语言发给你好了 Graphics.frame_rate = 40
fls = RMFlash.load("3.swf",640,480)
fls.x = 0
fls.y = 0
fls.loop = 1
while true
Graphics.update
# Input.update
fls.update
break if !fls.playing?
# break if Input.trigger?(13)
end
fls.dispose
上面那个3.swf可以换成你的文件名,只需把文件放在游戏的文件夹就行
flash.rar
(963.25 KB, 下载次数: 645)
2010-8-19 18:23 上传
点击文件名下载附件
刚才忘记了,把这个解压到原文件夹就OK
作者:
懒De说
时间:
2010-8-19 16:06
再送LZ一个和LZ不一样的播放脚本
#==============================================================================
# ☆★☆ AVI播放器 ☆★☆
#------------------------------------------------------------------------------
# - FantasyDR
# - 2006.3.12
#------------------------------------------------------------------------------
# MSN:
[email protected]
#------------------------------------------------------------------------------
# Note:
#
# 1.在下方 PROJECT_NAME = 后面填写你的游戏工程名.
#
# 2.在游戏中,调用脚本事件播放你的视频文件,如果一行写不下可以在逗号后换行.
#
# $MP.play(movie_name, movie_length,
# skip, fullscr,
# x, y, width, height, loop)
#
# 参数说明:
#
# movie_name : 视频文件名(*.avi),必须
# movie_length : 电影时间,单位是秒,必须
# skip : 是否可以按A键跳过,true/false,默认是true
# fullscr : 是否强制为全屏幕播放,true/false,默认是false
# x,y : 视频播放的左上角坐标,默认是0,0
# width,height : 视频的宽度,可以任意.默认是640,480
# loop : 循环播放,true/false,默认是true
#
# 例如播放logo.avi,时间13秒,禁止跳过,强制全屏,范围(是0,0)-(640,480),循环播放
# $MP.play("logo.avi",13,false,true)
#==============================================================================
# ★★★请先这里填写游戏的工程名★★★
PROJECT_NAME = "骑士の圣堂"
#==============================================================================
# ■ Win32API
#------------------------------------------------------------------------------
# 需要用到的API
#==============================================================================
# 切换到全屏延时
SWITCH_DELAY = 0.1
# API使用的一些常数
WS_EX_TOPMOST = 0x8
WS_EX_TOOLWINDOW= 0x80
WS_VISIBLE = 0x10000000
WS_POPUP = 0x80000000
GWL_HINSTANCE = (-6)
WM_CLOSE = 0x10
WS_CHILD = 0x40000000
WS_NONE = 0x16000000
CP_ACP = 0
CP_UTF8 = 65001
# 字符编码转换API
$MP_m2w = Win32API.new('kernel32', 'MultiByteToWideChar', '%w(i,l,p,i,p,i)', 'i')
$MP_w2m = Win32API.new('kernel32', 'WideCharToMultiByte', '%w(i,l,p,i,p,i,p,p)', 'i')
# 按键API
$MP_keybd = Win32API.new('user32', 'keybd_event', '%w(i,i,l,l)', 'v')
# 视频播放API
$MP_mciSendString = Win32API.new('winmm','mciSendString','%w(p,p,l,l)','V')
# 锁定窗口
# hWnd,ifEnable
$MP_EnableWindow = Win32API.new('user32','EnableWindow','%w(l,l)','L')
# 激活窗口
# hWnd
$MP_SetActiveWindow = Win32API.new('user32','SetActiveWindow','%w(l)','L')
# 当前活动窗口
$MP_GetActiveWindow = Win32API.new('user32','GetActiveWindow','%w()','L')
# hWnd,wMsg,wParam,lParam
$MP_PostMessage = Win32API.new('user32','PostMessage','%w(l,l,l,p)','L')
# 获取当前窗口句柄
$MP_FindWindowEX = Win32API.new('user32','FindWindowEx','%w(l,l,p,p)','L')
# 获取屏幕坐标
$MP_ClientToScreen = Win32API.new("user32", "ClientToScreen", 'ip', 'i')
# 获取hInt
$MP_GetWindowLong= Win32API.new('user32','GetWindowLong','%w(l,l)','L')
# 获取类名
# hWnd,lpClassName,maxCount
$MP_GetClassName= Win32API.new('user32','GetClassName','%w(l,p,l)','L')
# 建立窗体
# ExStyle,ClassName,WindowName,
# style,x,y,width,height
# 0,0,hInstance,0
$MP_CreateWindowEX = Win32API.new('user32','CreateWindowEx','%w(l,p,p,l,l,l,l,l,l,l,l,p)','L')
#==============================================================================
# ■ MoviePlayer
#------------------------------------------------------------------------------
# 处理视频播放画面的类。
#==============================================================================
class MoviePlayer
#--------------------------------------------------------------------------
# ● 初始化
# project_name : 工程名称
#--------------------------------------------------------------------------
def initialize(project_name = PROJECT_NAME)
@sys_timer=SystemTimer.new()
buffer = "\0\0" * project_name.size
@project_name = "\0" * project_name.size
$MP_m2w.call(CP_UTF8, 0, project_name, -1, buffer, project_name.size)
$MP_w2m.call(CP_ACP,0,buffer,-1,@project_name,project_name.size,0,0)
@hWnd = $MP_FindWindowEX.call(0,0,nil,@project_name)
@hInt = $MP_GetWindowLong.call(@hWnd,GWL_HINSTANCE)
@class_name = " " * 256
$MP_GetClassName.call(@hWnd,@class_name,256)
end
#--------------------------------------------------------------------------
# ● 是否已经全屏幕
#--------------------------------------------------------------------------
def is_full?
# 播放起始坐标
point = [0, 0].pack('ll')
if $MP_ClientToScreen.call(@hWnd, point) == 0
return false
end
x, y = point.unpack('ll')
if x == 0 and y == 0
return true
else
return false
end
end
#--------------------------------------------------------------------------
# ● 切换全屏
#--------------------------------------------------------------------------
def switch_full
$MP_keybd.call (0xA4, 0, 0, 0)
$MP_keybd.call (13, 0, 0, 0)
$MP_keybd.call (13, 0, 2, 0)
$MP_keybd.call (0xA4, 0, 2, 0)
sleep(SWITCH_DELAY)
for i in 1..3
Graphics.update
end
end
#--------------------------------------------------------------------------
# ● 播放电影
# movie_name : 视频文件名(*.avi)
# movie_length : 电影时间,单位是秒
# skip : 是否可以按键跳过
# fullscr : 是否强制为全屏幕播放
# x,y,width,height: 播放的位置以及宽度
# loop : 循环播放
#--------------------------------------------------------------------------
def play(movie_name,movie_length,
skip = true,fullscr = false,
x = 0,y = 0,width = 640,height = 480,loop = true)
# 数据不合法则退出
return true if movie_name == nil or movie_length <= 0
# 文件不存在
return true unless FileTest.exist?(movie_name)
# 窗口宽度
width -= (x + width)- 640 if (x + width) > 640
height -= (y + height)- 480 if (y + height) > 480
if fullscr and !is_full?
self.switch_full
end
fullscr = self.is_full?
# 播放起始坐标
point = [x, y].pack('ll')
if $MP_ClientToScreen.call(@hWnd, point) == 0
return true
end
x, y = point.unpack('ll')
return true if (x + width) < 0 or (y+height) < 0
if fullscr
wnd = $MP_CreateWindowEX.call(WS_EX_TOPMOST,@class_name,@project_name,
WS_VISIBLE | WS_POPUP,x,y,width,height,
0,0,@hInt,0)
else
wnd = $MP_CreateWindowEX.call(WS_EX_TOOLWINDOW,@class_name,@project_name,
WS_VISIBLE | WS_POPUP,x,y,width,height,
0,0,@hInt,0)
end
# 窗体建立失败
return true if wnd == 0
# 屏蔽原窗体
$MP_EnableWindow.call(@hWnd,0)
$MP_mciSendString.call("open \"" + movie_name + "\"" +
" alias FILE style 1073741824 parent " +\
wnd.to_s,0,0,0)
if loop
$MP_mciSendString.call("play FILE repeat window",0,0,0)
else
$MP_mciSendString.call("play FILE window",0,0,0)
end
@sys_timer.clear()
step = 0.1
begin
loop do
# 如果在窗口模式
unless fullscr
# 变成全屏
if self.is_full?
break
else
Graphics.update
end
end
#sleep(step)
if skip
Input.update
break if Input.trigger?(Input::A)
end
if @sys_timer.now_s >= movie_length
break
end
if $MP_GetActiveWindow.call() != wnd
$MP_SetActiveWindow.call(wnd)
end
end
Graphics.update
# 关闭当前窗体
$MP_PostMessage.call(wnd,WM_CLOSE,0,0)
$MP_mciSendString.call("close FILE",0,0,0)
$MP_EnableWindow.call(@hWnd,1)
$MP_SetActiveWindow.call(@hWnd)
return true
rescue Hangup
retry
end
end
end
$MP = MoviePlayer.new
复制代码
作者:
Allguard
时间:
2010-8-19 16:33
提示:
作者被禁止或删除 内容自动屏蔽
作者:
日月星辰
时间:
2010-8-19 16:45
66 提到过这个问题,他除了建议使用播放avi动画的那个脚本,它还做了一个教程,就是连续播放图片。search一下看看。
作者:
liqunsz
时间:
2010-8-19 17:59
AVI播放器的高精度计时器呢……
Flash播放器的DLL和OCX呢
连续播放,小游戏+少、小图片倒还好,大一点在个别老机器上面跑不动
Flash播放器跳帧请先把影片转换成flv,导入到Flash,选择导入到场景啥的,总之不要用它提供的插件啥的,设置好尺寸和
帧频
,重要的就是帧频了,自制的Flash可以使用原帧频,电影之类的截下来就要使用30fps,然后输出,输出的swf大概跟flv差不多。
注意转码为flv时帧频也要对应好,不然速度也会有问题……
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1