| 赞 | 0 |
| VIP | |
| 好人卡 | |
| 积分 | 8 |
| 经验 | |
| 最后登录 | 2022-3-21 |
| 在线时间 | 636 小时 |
- 梦石
- 0
- 星屑
- 815
- 在线时间
- 636 小时
- 注册时间
- 2011-1-21
- 回帖
- 153
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本帖最后由 pokemonjs 于 2018-1-1 10:22 编辑
如题所示,最近在努力做一款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] |
|