如题所示,最近在努力做一款ARPG,关于ARPG中地图上技能的显示遇到了一些问题。起初我是用一个行走图是动画图形的Game_Event来作为地图上的技能事件,但是后来发现有些动画并不很合适用行走图来表示,于是我将其改成了一个行走图为空的Game_Event,并且用animation_id属性来控制它显示的技能动画,但是在实际操作中发现,这些动画并不能出现在屏幕上,我尝试着p出了这个事件的坐标,通过与角色坐标的对比发现确实是在视野范围中的,而且动画虽然不显示,但是动画背景SE是有的,而且似乎是在循环播放,这是为什么呢?求教,谢谢各位!
[pre lang="ruby"]#地图技能类
class Game_MNSkill < Game_Character
#单位长度,技能的实际长宽分别乘以动画的放大率
UNITSIZE=128
attr_reader :collider
def initialize(owner,skill_id)
super()
@skill=$data_skills[skill_id]
@owner=owner
@x=owner.x
@y=owner.y
@real_x=owner.real_x
@real_y=owner.real_y
@animation1=$data_animations[@skill.animation1_id]
@animation2=$data_animations[@skill.animation2_id]
@through=true
@index=0
@frame_max=@animation1.frame_max
#碰撞盒子
val=Toolkit.get_anim_rect(@animation1,@index)
@collider=Rect.new(
@real_x+UNITSIZE*val[0],
@real_y+UNITSIZE*val[1],
UNITSIZE*val[2],
UNITSIZE*val[2]
)
#将一些特殊标记效果存储在marks中,如@marks["瞬杀"]=true
@marks=Hash.new()
@move_speed=@owner.move_speed*1.5
@animation_id=skill_id
#移动初始化处理
moveto(owner.x,owner.y)
@direction=owner.direction
@mmove_type=0#默认静止
#1-直线 2-待定
common_event=$data_common_events[$data_skills[skill_id].common_event_id]
for i in common_event.list
if i.code==108 && i.parameters[0][0,9]=="move_type"
@mmove_type=i.parameters[0][10,1].to_i
#str[0]是一个char,也就是ASCII码值
#str[0,1]是一个长度为1的string
end
end if common_event!=nil
end
def update
super()
@index+=1
@index=0 if @index>=@frame_max
case @mmove_type
when 1
@direction_fix=true
move_forward
end unless moving?
#更新碰撞盒子
val=Toolkit.get_anim_rect(@animation1,@index)
@collider=Rect.new(
@real_x+UNITSIZE*val[0],
@real_y+UNITSIZE*val[1],
UNITSIZE*val[2],
UNITSIZE*val[2]
)
end
#--------------------------------------------------------------------------
# ● 接触事件启动判定
#--------------------------------------------------------------------------
def check_event_trigger_touch(x, y)
result = false
# 事件执行中的情况下
if $game_system.map_interpreter.running?
return result
end
#对所有敌人进行循环
for enemy in $game_mbs.enemy_list
if enemy.collider?(self)
enemy.damage_by(self)
result=true
end
end
#对角色队伍进行循环
for player in $game_players
if player.collider?(self)
player.damage_by(self)
result=true
end
end
return result
end
end
#地图敌人类中的攻击方法
def fire_on(target)
skill=Game_MNSkill.new(self,1)#1代表普攻
@spe_effs.each_pair do |key,val|
if skill.spe_effs.has_key?
case spe_effs[key].class
when Numberic
skill.spe_effs[key] += val
when TrueClass
skill.spe_effs[key] ||= val
next
when FalseClass
skill.spe_effs[key] ||= val
next
end
else
skill.spe_effs[key]=val
end
end
$game_map.add_effect(skill)
end[/pre]作者: Im剑侠客 时间: 2017-12-31 19:28
行走图虽然可以为空,但是要确保这个行走图存在。可以尝试用一张透明的行走图作为替代。祝你好运( ^_^)/作者: 梦幻想 时间: 2018-1-1 09:33
想知道脚本哪里出问题你得把脚本贴出来啊……不过我猜要么是没建立RPG::Sprite,要么是Z值不对图形被覆盖了,要么就是没刷新的问题……作者: guoxiaomi 时间: 2018-1-1 15:42
不太清楚,楼上几位的说法都有可能,,除此之外,会不会是指定的Sprite被设置了visible = false?作者: yang1zhi 时间: 2018-1-1 17:39
可以使用那个在地图指定坐标显示动画的脚本,而不是在人物身上显示
论坛里能找到