赞 | 0 |
VIP | 0 |
好人卡 | 1 |
积分 | 1 |
经验 | 8269 |
最后登录 | 2020-5-5 |
在线时间 | 61 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 60
- 在线时间
- 61 小时
- 注册时间
- 2006-9-15
- 帖子
- 946
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
只不过是 缩放,或者是放大而已。。。。怎么调用,在那里调用,看用他的人了
- 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} |
|