Project1
标题:
好吧,无聊的动画播放
[打印本页]
作者:
secondsen
时间:
2008-7-22 05:44
标题:
好吧,无聊的动画播放
只不过是 缩放,或者是放大而已。。。。怎么调用,在那里调用,看用他的人了
class Sprite_C < Sprite_Base
#--------------------------------------------------------------------------
# ● 初始化对像
# viewport : 视口
# zoom : 放大率
#--------------------------------------------------------------------------
def initialize(viewport,index,zoom = nil)
super(viewport)
@index = index
@zoom = zoom
self.x = 100
self.y = 100
self.z = 100
setup
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def setup
if @index != 0
animation = $data_animations[@index]
start_animation(animation)
@index = 0
end
end
#--------------------------------------------------------------------------
# ● 设置动画活动块
# frame : 帧数据 (RPG::Animation::Frame)
#--------------------------------------------------------------------------
def animation_set_sprites(frame,zoom = nil)
cell_data = frame.cell_data
for i in 0..15
sprite = @animation_sprites[i]
next if sprite == nil
pattern = cell_data[i, 0]
if pattern == nil or pattern == -1
sprite.visible = false
next
end
if pattern < 100
sprite.bitmap = @animation_bitmap1
else
sprite.bitmap = @animation_bitmap2
end
sprite.visible = true
sprite.src_rect.set(pattern % 5 * 192,
pattern % 100 / 5 * 192, 192, 192)
if @animation_mirror
sprite.x = @animation_ox - cell_data[i, 1]
sprite.y = @animation_oy - cell_data[i, 2]
sprite.angle = (360 - cell_data[i, 4])
sprite.mirror = (cell_data[i, 5] == 0)
else
sprite.x = @animation_ox + cell_data[i, 1]
sprite.y = @animation_oy + cell_data[i, 2]
sprite.angle = cell_data[i, 4]
sprite.mirror = (cell_data[i, 5] == 1)
end
sprite.z = self.z + 300
sprite.ox = 96
sprite.oy = 96
sprite.zoom_x = cell_data[i, 3] / 100.0
sprite.zoom_y = cell_data[i, 3] / 100.0
#----------------------
if zoom
sprite.zoom_x = zoom * sprite.zoom_x
sprite.zoom_y = zoom * sprite.zoom_y
end
#----------------------
sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
sprite.blend_type = cell_data[i, 7]
end
end
#--------------------------------------------------------------------------
# ● 刷新动画
#--------------------------------------------------------------------------
def update_animation
if @animation_duration > 0
frame_index = @animation.frame_max - (@animation_duration + 3) / 4
animation_set_sprites(@animation.frames[frame_index],@zoom)
for timing in @animation.timings
if timing.frame == frame_index
animation_process_timing(timing)
end
end
else
dispose_animation
end
end
end
复制代码
调用
这个是在 自己作的scene里的。在地图上 播放缩小的动画或者 放大的动画。。。把scene改一下即可
class A < Scene_Base
def start
@viewport = Viewport.new(0, 0, 544, 416)
@sp = Sprite_C.new(@viewport,2,0.5)
end
def update
if @sp.animation?
@sp.update
else
@sp.dispose_animation
@sp.dispose
@viewport.dispose
@sp = nil
@viewport = Viewport.new(0, 0, 544, 416)
@sp = Sprite_C.new(@viewport,2,0.5)
end
end
end
复制代码
特别感谢 kiss 后面的记不住了。。。告诉我 viewport 没有释放{/hx}
作者:
secondsen
时间:
2008-7-22 06:09
鄙人觉得。。。绝对毫无技术性可言。。。仅是自娱自乐。。。或许有人想缩放就不用自己再去改了{/gg}
作者:
追梦使者
时间:
2008-7-24 04:08
我跟你想的一样……
作者:
火鸡三毛老大
时间:
2008-7-24 21:34
缩放=缩小/放大
看起来不错~~~
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1