本帖最后由 恐惧剑刃 于 2014-12-30 19:42 编辑
其实八方向走没有想象中的那么复杂!
Sprite_Character 中- sx = @character.pattern * @cw
- sy = (@character.direction - 2) / 2 * @ch
- self.src_rect.set(sx, sy, @cw, @ch)
复制代码 就是控制方向的,可以简单修改为- sx = @character.pattern * @cw
- case @character.direction
- when 2,4,6,8
- sy = (@character.direction - 2) / 2 * @ch
- when 1
- sy = 4 * @ch
- when 3
- sy = 5 * @ch
- when 7
- sy = 6 * @ch
- when 9
- sy = 7 * @ch
- end
- self.src_rect.set(sx, sy, @cw, @ch)
复制代码 再找到Game_Player
把- case Input.dir4
- when 2
- move_down
- when 4
- move_left
- when 6
- move_right
- when 8
- move_up
- end
复制代码 改为- case Input.dir8
- when 2
- move_down
- when 4
- move_left
- when 6
- move_right
- when 8
- move_up
- when 1
- @direction = 1
- move_lower_left
- when 3
- @direction = 3
- move_lower_right
- when 7
- @direction = 7
- move_upper_left
- when 9
- @direction = 9
- move_upper_right
- end
复制代码 可以看到,再移动的时候手动调整方向,在活动块中取得不同的图形
以上,应该没有错吧
如果是待机动画,加一行判断
case Input.dir8 when 2 # 更改图形什么的 move_down when 4 move_left when 6 move_right when 8 move_up when 1 @direction = 1 move_lower_left when 3 @direction = 3 move_lower_right when 7 @direction = 7 move_upper_left when 9 @direction = 9 move_upper_right else # 更改图形什么的,并且打开停止时动画 end
case Input.dir8
when 2
# 更改图形什么的
move_down
when 4
move_left
when 6
move_right
when 8
move_up
when 1
@direction = 1
move_lower_left
when 3
@direction = 3
move_lower_right
when 7
@direction = 7
move_upper_left
when 9
@direction = 9
move_upper_right
else
# 更改图形什么的,并且打开停止时动画
end
要修改速度在Game_Character 2中
if @anime_count > 18 - @move_speed * 2
if @anime_count > 18 - @move_speed * 2
就是这句 |