设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
12
返回列表 发新帖
楼主: 飞火流萤
打印 上一主题 下一主题

[已经解决] 要怎么样实现追赶效果呢?

[复制链接]

Lv4.逐梦者

梦石
0
星屑
12157
在线时间
4435 小时
注册时间
2014-4-11
帖子
5955

开拓者

11
发表于 2014-11-20 22:07:32 | 只看该作者
本帖最后由 yang1zhi 于 2014-11-20 23:37 编辑

@z2214557w
我只能改成这样了。行的话就拿去吧
我知道你已经解决了。我来加强自己刚刚写的脚本
  1. #==============================================================================
  2. # ■ Game_Character (接近专定义)
  3. #------------------------------------------------------------------------------
  4. #  处理角色的类。本类作为 Game_Player 类与 Game_Event
  5. # 类的超级类使用。
  6. #==============================================================================
  7. # 使用方法:
  8. # 在设置事件移动那里改为自定义,路线为:toward_player_add(x范围,y范围)
  9. #==============================================================================
  10. class Game_Character
  11. def toward_player_add(x = 1,y = 1)
  12.     new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
  13.     new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)

  14. # 求得与主角坐标的差
  15. sx = (@x - $game_player.x).abs
  16. sy = (@y - $game_player.y).abs
  17. if sx <= x and sy <= y
  18. turn_away_from_player
  19. if $game_map.passable?(new_x, new_y,0)
  20.   move_away_from_player
  21.   else
  22.   turn_left_90
  23.     new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
  24.     new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)

  25.   if $game_map.passable?(new_x, new_y,0)
  26.   move_forward
  27. else

  28.   turn_180
  29.       new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
  30.     new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)

  31.   if $game_map.passable?(new_x, new_y,0)
  32.   move_forward
  33. else
  34.   turn_left_90
  35. move_backward
  36.   turn_left_90
  37.       new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
  38.     new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)

  39.   if $game_map.passable?(new_x, new_y,0)
  40.   move_forward
  41. else
  42.   turn_180
  43.       new_x = @x + (@direction == 6 ? 1 : @direction == 4 ? -1 : 0)
  44.     new_y = @y + (@direction == 2 ? 1 : @direction == 8 ? -1 : 0)

  45.   if $game_map.passable?(new_x, new_y,0)
  46.   move_forward
  47. end
  48. end
  49. end
  50. end
  51. end
  52. else
  53. move_random
  54. end
  55. end
  56. end
复制代码

点评

谢谢啊!那我拿去试试看  发表于 2014-11-22 22:04
我擦,您辛苦了,我已经找到更好的方法了,就是用坐标识别,然后用事件移动,这样的效果没有一点卡顿,非常好  发表于 2014-11-20 22:37
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-9-22 11:34

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表