Project1

标题: 弹开效果 [打印本页]

作者: sf945    时间: 2007-7-4 22:04
标题: 弹开效果
代码:
#------------------------------------------------------------------------------
#  弹开效果。
#==============================================================================
class Game_Player
  attr_accessor:px
  attr_accessor:py
end

def tk
  case $game_player.direction
    when 2  # 下
      $game_player.moveto($game_player.px,$game_player.py-3)
    when 4  # 左
      $game_player.moveto($game_player.px+3,$game_player.py)
    when 6  # 右
      $game_player.moveto($game_player.px-3,$game_player.py)
    when 8  # 上
      $game_player.moveto($game_player.px,$game_player.py+3)
  end
end

在Game_Player类的passable?方法中加入这两句
@px=x + (d == 6 ? 1 : d == 4 ? -1 : 0)
@py=y + (d == 2 ? 1 : d == 8 ? -1 : 0)

这个效果可以给地图上某些碰不得的东西加上
作者: sf945    时间: 2007-7-4 22:04
标题: 弹开效果
代码:
#------------------------------------------------------------------------------
#  弹开效果。
#==============================================================================
class Game_Player
  attr_accessor:px
  attr_accessor:py
end

def tk
  case $game_player.direction
    when 2  # 下
      $game_player.moveto($game_player.px,$game_player.py-3)
    when 4  # 左
      $game_player.moveto($game_player.px+3,$game_player.py)
    when 6  # 右
      $game_player.moveto($game_player.px-3,$game_player.py)
    when 8  # 上
      $game_player.moveto($game_player.px,$game_player.py+3)
  end
end

在Game_Player类的passable?方法中加入这两句
@px=x + (d == 6 ? 1 : d == 4 ? -1 : 0)
@py=y + (d == 2 ? 1 : d == 8 ? -1 : 0)

这个效果可以给地图上某些碰不得的东西加上
作者: 小传子    时间: 2007-7-4 22:35
以前有一个游戏YS2  貌似就有这种效果  {/qiang}赞一个
作者: 亿万星辰    时间: 2007-7-5 01:10
{/jy}一直都是用事件做的....  =v=
作者: frantice    时间: 2007-7-5 01:58
完善版本, 范例中用来处理移动物体对主角冲撞的效果的, 看了下事件不知道这个脚本有什么用, 好象事件就能处理的样子..
  1. #===============================#
  2. # EDGE WALKING
  3. # By Jimme Reashu
  4. # Version 1
  5. # Last edit: October 21

  6. # Always include the Readme file when distributing
  7. # the script together with the demo. Always.

  8. # This header may not be removed
  9. #===============================#
  10. PLAYER_EDGE = 5
  11. EVENT_EDGE = 6
  12. class Game_Character
  13.   alias jimmr_edgewalk_passable? passable?
  14.   def passable?(x,y,d)
  15.     unless (self.is_a?(Game_Event) && $game_switches[EVENT_EDGE] == true) or (self.is_a?(Game_Player) && $game_switches[PLAYER_EDGE] == true)
  16.       return jimmr_edgewalk_passable?(x,y,d)
  17.     else
  18.       $game_switches[EVENT_EDGE] = false if self.is_a?(Game_Event)
  19.       $game_switches[PLAYER_EDGE] = false if self.is_a?(Game_Player)
  20.       new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
  21.       new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
  22.       unless $game_map.valid?(new_x, new_y) and $game_map.valid?(x, y)
  23.         return true
  24.       end
  25.       if @through
  26.         return true
  27.       end
  28.       unless $game_map.passable?(x, y, d, self)
  29.         return false
  30.       end
  31.       unless $game_map.passable?(new_x, new_y, 10 - d)
  32.         return false
  33.       end
  34.       for event in $game_map.events.values
  35.         if event.x == new_x and event.y == new_y
  36.           unless event.through
  37.             if self != $game_player
  38.               return false
  39.             end
  40.             if event.character_name != ""
  41.               return false
  42.             end
  43.           end
  44.         end
  45.       end
  46.       if $game_player.x == new_x and $game_player.y == new_y
  47.         unless $game_player.through
  48.           if @character_name != ""
  49.             return false
  50.           end
  51.         end
  52.       end
  53.       return true
  54.     end
  55.   end
  56. end

  57. class Game_Player < Game_Character
  58.     def passable?(x, y, d)
  59.     new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
  60.     new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
  61.     if $DEBUG and Input.press?(Input::CTRL) and $game_map.valid?(new_x, new_y)
  62.       return true
  63.     end
  64.     super
  65.   end
  66. end
复制代码

作者: 风雪优游    时间: 2007-7-5 06:33
使用方法是直接……写在事件里?
作者: gpra8764    时间: 2007-7-5 07:28
提示: 作者被禁止或删除 内容自动屏蔽




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1