#==============================================================================
# GIFFile クラス
#------------------------------------------------------------------------------
class GIFFile
#--------------------------------------------------------------------------
# ● クラス変数
#--------------------------------------------------------------------------
begin
@@loader = Win32API.new('wfbitmap','gifLoader',%w(p i p p p p),'l').freeze
@@load = Win32API.new('wfbitmap','gifLoadImage',%w(l i),'l').freeze
@@count = Win32API.new('wfbitmap','gifImageCount','v','l').freeze
@@close = Win32API.new('wfbitmap','GifClose','v','v').freeze
rescue Exception
raise if debug?
raise(LoadError,"cannot read modules.(wfbitmap.dll)")
end
#--------------------------------------------------------------------------
# ● 定数
#--------------------------------------------------------------------------
RGSSA_FILE = rpgvx? ? (rpgvxace? ? "Game.rgss3a" : "Game.rgss2a") :
"Game.rgssad"
RGSSA_VERSION = rpgvx? ? (rpgvxace? ? 3 : 2) : 1
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_reader :bitmap
attr_reader :count
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize( giffile )
w = "\x00" * 2
h = "\x00" * 2
@loaded = false
begin
infile = giffile.gsub(/\//){ "\\" }
i = @@loader.call(RGSSA_FILE,RGSSA_VERSION,
infile,String.utf82ansi(infile), w , h )
raise(Errno::ENOENT,infile) if i < 0
@loaded = true
@count = @@count.call()
width = w.unpack("S").first
height = h.unpack("S").first
@bitmap = Array.new( @count ){ Bitmap.new( width , height ) }
i = 0
for bitmap in @bitmap
@@load.call( bitmap.object_id , i )
i += 1
end
ensure
@@close.call() if @loaded
end
end
#--------------------------------------------------------------------------
# ● 解放
#--------------------------------------------------------------------------
def dispose
for bitmap in @bitmap
bitmap.dispose
end
end
end
#==============================================================================
# GifSprite クラス
#------------------------------------------------------------------------------
class GifSprite < Sprite
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize( giffile , wait = 1 , viewport = nil)
super(viewport)
@gif = GIFFile.new( giffile )
@wait = wait
self.bitmap = @gif.bitmap.at(0)
@_count = 0
@_index = 0
end
#--------------------------------------------------------------------------
# ● 解放
#--------------------------------------------------------------------------
def dispose
@gif.dispose
super
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
super
@_count += 1
if @_count >= @wait
@_index += 1
@_index %= @gif.count
self.bitmap = @gif.bitmap.at(@_index)
@_count = 0
end
end
end
리드미 메모장...
-------------------------------------------------- ------------------------------
■ 클래스 GIFFile
-------------------------------------------------- ------------------------------
initialize (giffile)
-------------------------------------------------- ------------------------------
in : giffile (String)
out : ----
-------------------------------------------------- ------------------------------
GIF 파일을로드합니다. 애니메이션 GIF의 경우 그 매수로드합니다.
데이터는 32bit 비트 맵 열기 때문에
큰 GIF 애니메이션 파일은 용량을 크게 소비합니다. 주의하시기 바랍니다.
giffile은 Graphics에서 패스를 설정해야합니다.
예) Graphics / Pictures / test.gif
-------------------------------------------------- ------------------------------
● 메소드
-------------------------------------------------- ------------------------------
dispose
-------------------------------------------------- ------------------------------
in : 없음
out : ----
-------------------------------------------------- ------------------------------
GIF 파일을 해제합니다.
-------------------------------------------------- ------------------------------
■ 클래스 GifSprite <Sprite
-------------------------------------------------- ------------------------------
initialize (giffile, wait = 1, viewport = nil)
-------------------------------------------------- ------------------------------
in : giffile (String)
in : wait (Fixnum)
in : viewport (Viewport)
out : ----
-------------------------------------------------- ------------------------------
GIF 애니메이션을위한 스프라이트를 생성합니다.
wait 프레임 간격으로 애니메이션합니다.
데이터는 내부적으로 32bit 비트 맵 열기 때문에
큰 GIF 애니메이션 파일은 용량을 크게 소비합니다. 주의하시기 바랍니다.
giffile은 Graphics에서 패스를 설정해야합니다.
예) Graphics / Pictures / test.gif
-------------------------------------------------- ------------------------------
● 메소드
-------------------------------------------------- ------------------------------
dispose
-------------------------------------------------- ------------------------------
in : 없음
out : ----
-------------------------------------------------- ------------------------------
GIF 스프라이트를 해제합니다.
-------------------------------------------------- ------------------------------
update
-------------------------------------------------- ------------------------------
in : 없음
out : ----
-------------------------------------------------- ------------------------------
GIF 애니메이션을 업데이트합니다.
wait 프레임 간격으로 애니메이션합니다.
원칙적으로 1 프레임에 1 회이 메소드를 호출합니다.
================================================== ==============================
루비같은딩
잉잉 나도 몰라잉 잉잉 징징대지만 말고 루비까지 알려줬으면 직접해결해봐야지. 질문을 일목요연하게 정리해서 다시 질문 올리던가.
중딩때 내친구 이걸로 겜만들던데