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

Project1

 找回密码
 注册会员
搜索
查看: 2669|回复: 6
打印 上一主题 下一主题

弹开效果

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
55
在线时间
0 小时
注册时间
2007-7-2
帖子
14
跳转到指定楼层
1
发表于 2007-7-4 22:04:42 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
代码:
#------------------------------------------------------------------------------
#  弹开效果。
#==============================================================================
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)

这个效果可以给地图上某些碰不得的东西加上

Lv1.梦旅人

梦石
0
星屑
55
在线时间
0 小时
注册时间
2007-7-2
帖子
14
2
 楼主| 发表于 2007-7-4 22:04:42 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
代码:
#------------------------------------------------------------------------------
#  弹开效果。
#==============================================================================
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)

这个效果可以给地图上某些碰不得的东西加上

Lv2.观梦者


  • 更新完成啦

梦石
0
星屑
784
在线时间
6267 小时
注册时间
2006-6-7
帖子
8462
3
发表于 2007-7-4 22:35:15 | 只看该作者
以前有一个游戏YS2  貌似就有这种效果  {/qiang}赞一个
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
270
在线时间
1373 小时
注册时间
2005-10-16
帖子
5113

贵宾

4
发表于 2007-7-5 01:10:14 | 只看该作者
{/jy}一直都是用事件做的....  =v=
我只个搬答案的
叔叔我已经当爹了~
婚后闪人了……
回复 支持 反对

使用道具 举报

Lv1.梦旅人

查无此人

梦石
0
星屑
50
在线时间
9 小时
注册时间
2006-5-8
帖子
1399
5
发表于 2007-7-5 01:58:48 | 只看该作者
完善版本, 范例中用来处理移动物体对主角冲撞的效果的, 看了下事件不知道这个脚本有什么用, 好象事件就能处理的样子..
  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
复制代码
KRKR + NS 学习中..........
回复 支持 反对

使用道具 举报

Lv1.梦旅人

风雪夜不归人

梦石
0
星屑
50
在线时间
276 小时
注册时间
2006-3-7
帖子
6721

贵宾

6
发表于 2007-7-5 06:33:54 | 只看该作者
使用方法是直接……写在事件里?
有些人,到了七八月份就会诈尸。
宫斗,是女生永远的爱。
冷门,是本人不变的欲。
作弊,是玩家自由的痛。
练级,是橙光割舍的情。
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

苹果梨

梦石
0
星屑
43
在线时间
6 小时
注册时间
2007-2-14
帖子
720
7
发表于 2007-7-5 07:28:36 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2025-7-21 18:55

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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