本帖最后由 俄罗斯方块 于 2014-7-12 21:48 编辑
@VIPArcher
@taroxd
就范例,我先是照着把Sprite_Base里的@ani_rate改成了1,然后那个奇葩的效果让我明白了动画为什么4帧更新一次,也就是说为什么FPS看上去像15。
然后我把原来的update_animation给改成了这样
#-------------------------------------------------------------------------- # ● 更新动画 #-------------------------------------------------------------------------- def update_animation return unless animation? @ani_duration -= 1 if @ani_duration % 1 == 0 if @ani_duration > 0 frame_index = @animation.frame_max frame_index -= 1+ @ani_duration / @ani_rate animation_set_sprites(@animation.frames[frame_index]) if @ani_duration % @ani_rate == 0 @animation.timings.each do |timing| animation_process_timing(timing) if timing.frame == frame_index end end else end_animation end end end
#--------------------------------------------------------------------------
# ● 更新动画
#--------------------------------------------------------------------------
def update_animation
return unless animation?
@ani_duration -= 1
if @ani_duration % 1 == 0
if @ani_duration > 0
frame_index = @animation.frame_max
frame_index -= 1+ @ani_duration / @ani_rate
animation_set_sprites(@animation.frames[frame_index])
if @ani_duration % @ani_rate == 0
@animation.timings.each do |timing|
animation_process_timing(timing) if timing.frame == frame_index
end
end
else
end_animation
end
end
end
嗯,粗略的说就是把原来许多@ani_rate都换成1让它一帧更新一次,然后把
@animation.timings.each do |timing| animation_process_timing(timing) if timing.frame == frame_index end
@animation.timings.each do |timing|
animation_process_timing(timing) if timing.frame == frame_index
end
这个单独分离开,用@ani_rate来控制速度。这样就既能一帧一更新,又可以不让它播得太快就像之前那样了
这是不是算解决了?我还想提问题是不是该另开帖啦? |