Project1
标题:
请教在地图上同时显示多个动画
[打印本页]
作者:
zgm1100
时间:
2010-10-2 14:05
标题:
请教在地图上同时显示多个动画
能不能在地图上同时显示多个动画在角色身上。请教这样的脚本,示范。。谢谢!!
作者:
笨鸟の先飞
时间:
2010-10-2 14:22
并行处理 要不然你把多个动画拼成一个动画.........
作者:
zgm1100
时间:
2010-10-2 14:33
并行不行,只能显示一个动画。
这个代码好像可以,但是在显示两个动画时游戏就自动关闭了。是哪里出错了吗?
#--------------------------------------------------
# 此脚本来自www.66RPG.com,使用请保留此信息
#--------------------------------------------------
module RPG
class Sprite < ::Sprite
def initialize(viewport = nil)
super(viewport)
@_whiten_duration = 0
@_appear_duration = 0
@_escape_duration = 0
@_collapse_duration = 0
@_damage_duration = 0
@_animation_duration = 0
@_blink = false
@_animation = []
end
def animation(animation, hit)
return if animation == nil
num = @_animation.size
@_animation.push([animation, hit, animation.frame_max, []])
bitmap = RPG::Cache.animation(animation.animation_name,
animation.animation_hue)
if @@_reference_count.include?(bitmap)
@@_reference_count[bitmap] += 1
else
@@_reference_count[bitmap] = 1
end
if @_animation[num][0] != 3 or not @@_animations.include?(animation)
for i in 0..15
sprite = ::Sprite.new
sprite.bitmap = bitmap
sprite.visible = false
@_animation[num][3].push(sprite)
end
unless @@_animations.include?(animation)
@@_animations.push(animation)
end
end
update_animation(@_animation[num])
end
def loop_animation(animation)
return if animation == @_loop_animation
dispose_loop_animation
@_loop_animation = animation
return if @_loop_animation == nil
@_loop_animation_index = 0
animation_name = @_loop_animation.animation_name
animation_hue = @_loop_animation.animation_hue
bitmap = RPG::Cache.animation(animation_name, animation_hue)
if @@_reference_count.include?(bitmap)
@@_reference_count[bitmap] += 1
else
@@_reference_count[bitmap] = 1
end
@_loop_animation_sprites = []
for i in 0..15
sprite = ::Sprite.new
sprite.bitmap = bitmap
sprite.visible = false
@_loop_animation_sprites.push(sprite)
end
# update_loop_animation
end
def dispose_animation
for anime in @_animation.reverse
sprite = anime[3][0]
if sprite != nil
@@_reference_count[sprite.bitmap] -= 1
if @@_reference_count[sprite.bitmap] == 0
sprite.bitmap.dispose
end
end
for sprite in anime[3]
sprite.dispose
end
@_animation.delete(anime)
end
end
def update
super
if @_whiten_duration > 0
@_whiten_duration -= 1
self.color.alpha = 128 - (16 - @_whiten_duration) * 10
end
if @_appear_duration > 0
@_appear_duration -= 1
self.opacity = (16 - @_appear_duration) * 16
end
if @_escape_duration > 0
@_escape_duration -= 1
self.opacity = 256 - (32 - @_escape_duration) * 10
end
if @_collapse_duration > 0
@_collapse_duration -= 1
self.opacity = 256 - (48 - @_collapse_duration) * 6
end
if @_damage_duration > 0
@_damage_duration -= 1
case @_damage_duration
when 38..39
@_damage_sprite.y -= 4
when 36..37
@_damage_sprite.y -= 2
when 34..35
@_damage_sprite.y += 2
when 28..33
@_damage_sprite.y += 4
end
@_damage_sprite.opacity = 256 - (12 - @_damage_duration) * 32
if @_damage_duration == 0
dispose_damage
end
end
for anime in @_animation
if (Graphics.frame_count % 2 == 0)
anime[2] -= 1
update_animation(anime)
end
end
if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
update_loop_animation
@_loop_animation_index += 1
@_loop_animation_index %= @_loop_animation.frame_max
end
if @_blink
@_blink_count = (@_blink_count + 1) % 32
if @_blink_count < 16
alpha = (16 - @_blink_count) * 6
else
alpha = (@_blink_count - 16) * 6
end
self.color.set(255, 255, 255, alpha)
end
@@_animations.clear
end
def update_animation(anime)
if anime[2] > 0
frame_index = anime[0].frame_max - anime[2]
cell_data = anime[0].frames[frame_index].cell_data
position = anime[0].position
animation_set_sprites(anime[3], cell_data, position)
for timing in anime[0].timings
if timing.frame == frame_index
animation_process_timing(timing, anime[1])
end
end
else
@@_reference_count[anime[3][0].bitmap] -= 1
if @@_reference_count[anime[3][0].bitmap] == 0
anime[3][0].bitmap.dispose
end
for sprite in anime[3]
sprite.dispose
end
@_animation.delete(anime)
end
end
def animation_set_sprites(sprites, cell_data, position)
for i in 0..15
sprite = sprites[i]
pattern = cell_data[i, 0]
if sprite == nil or pattern == nil or pattern == -1
sprite.visible = false if sprite != nil
next
end
sprite.visible = true
sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
if position == 3
if self.viewport != nil
sprite.x = self.viewport.rect.width / 2
if $game_temp.in_battle and self.battler.is_a?(Game_Enemy)
sprite.y = self.viewport.rect.height - 320
else
sprite.y = self.viewport.rect.height - 160
end
else
sprite.x = 320
sprite.y = 240
end
else
sprite.x = self.x + self.viewport.rect.x -
self.ox + self.src_rect.width / 2
if $game_temp.in_battle and self.battler.is_a?(Game_Enemy)
sprite.y = self.y - self.oy * self.zoom_y / 2 +
self.viewport.rect.y
if position == 0
sprite.y -= self.src_rect.height * self.zoom_y / 4
elsif position == 2
sprite.y += self.src_rect.height * self.zoom_y / 4
end
else
sprite.y = self.y + self.viewport.rect.y -
self.oy + self.src_rect.height / 2
sprite.y -= self.src_rect.height / 4 if position == 0
sprite.y += self.src_rect.height / 4 if position == 2
end
end
sprite.x += cell_data[i, 1]
sprite.y += cell_data[i, 2]
sprite.z = 2000
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 position != 3
sprite.zoom_x *= self.zoom_x
sprite.zoom_y *= self.zoom_y
end
sprite.angle = cell_data[i, 4]
sprite.mirror = (cell_data[i, 5] == 1)
sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
sprite.blend_type = cell_data[i, 7]
end
end
end
end
复制代码
作者:
zgm1100
时间:
2010-10-2 14:34
没有这方面的脚本吗?
作者:
笨鸟の先飞
时间:
2010-10-2 16:43
没见过 再说有时并不是所有的东西都要脚本的
作者:
zgm1100
时间:
2010-10-2 16:46
那这个该怎么做?
作者:
429259591
时间:
2010-10-2 16:51
用并行的话会卡的,只能把多个动画合成一个动画,或者是一个一个动画来
作者:
zgm1100
时间:
2010-10-2 17:29
我想要的是几个动画同时显示。
作者:
429259591
时间:
2010-10-2 17:36
几个动画同时会卡住,请LZ把多个动画合成一个吧
作者:
zgm1100
时间:
2010-10-3 10:29
...........好麻烦、。
作者:
禾西
时间:
2010-10-3 10:34
http://rpg.blue/forum.php?mod=viewthread&tid=84595
作者:
goahead
时间:
2010-10-3 15:43
提示:
作者被禁止或删除 内容自动屏蔽
作者:
zgm1100
时间:
2010-10-4 17:52
不行啊。。这个怎么用?
作者:
429259591
时间:
2010-10-4 17:56
纯引用里面的
#==============================================================================
# ■ Sprite_Character
#------------------------------------------------------------------------------
# 角色显示用脚本。监视 Game_Character 类的实例、
# 自动变化脚本状态。
#==============================================================================
class Sprite_Character < RPG::Sprite
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_accessor :character # 角色
#--------------------------------------------------------------------------
# ● 初始化对像
# viewport : 查看端口
# character : 角色 (Game_Character)
#--------------------------------------------------------------------------
def initialize(viewport, character = nil)
super(viewport)
@character = character
update
end
#--------------------------------------------------------------------------
# ● 更新画面
#--------------------------------------------------------------------------
def update
# 元件 ID、文件名、色相与现在的情况存在差异的情况下
if @tile_id != @character.tile_id or
@character_name != @character.character_name or
@character_hue != @character.character_hue
# 记忆元件 ID 与文件名、色相
@tile_id = @character.tile_id
@character_name = @character.character_name
@character_hue = @character.character_hue
# 元件 ID 为有效值的情况下
if @tile_id >= 384
self.bitmap = RPG::Cache.tile($game_map.tileset_name,
@tile_id, @character.character_hue)
self.src_rect.set(0, 0, 32, 32)
self.ox = 16
self.oy = 32
# 元件 ID 为无效值的情况下
else
self.bitmap = RPG::Cache.character(@character.character_name,
@character.character_hue)
@cw = bitmap.width / 4
@ch = bitmap.height / 4
self.ox = @cw / 2
self.oy = @ch
end
end
# 设置可视状态
self.visible = (not @character.transparent)
# 图形是角色的情况下
if @tile_id == 0
# 设置传送目标的矩形
sx = @character.pattern * @cw
sy = (@character.direction - 2) / 2 * @ch
self.src_rect.set(sx, sy, @cw, @ch)
end
# 设置脚本的坐标
self.x = @character.screen_x
self.y = @character.screen_y
self.z = @character.screen_z(@ch)
# 设置不透明度、合成方式、茂密
self.opacity = @character.opacity
self.blend_type = @character.blend_type
self.bush_depth = @character.bush_depth
# 动画
if @character.animation_id != 0
animation = $data_animations[@character.animation_id]
animation(animation, true)
@character.animation_id = 0
end
super
end
end
复制代码
作者:
zgm1100
时间:
2010-10-4 18:51
没有几个动画一起显示啊。。还是只显示了一个。
作者:
zgm1100
时间:
2010-10-4 19:02
不行啊。。还是只显示后面一个动画。
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1