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

Project1

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

[已发主站] VA真·八方向行走

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1344
在线时间
962 小时
注册时间
2012-4-30
帖子
1475

开拓者

跳转到指定楼层
1
发表于 2012-7-22 16:07:03 | 显示全部楼层 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 铅笔描绘的思念 于 2012-7-23 11:53 编辑

因为这个帖子(><)所以就写了咱第一个脚本。。
貌似站上木有va的真八方。。就发布啦~\(≧▽≦)/~
并且还不不影响4方向哦。。只要把八方向的行走图重命名为原4方向的行走图+"_8D"放在Characters里
如果是8个角色元元的话。。那么八方向的的行走图也要是8个角色元的行走图。。角色元的index还是4方的index
类似下面:
4方向 八方向的 当然木有找到八方向的行走图就不会使用八方行走啦。。
效果截图: 。。(´Д`)不要吐槽网格。。。是有用滴。。


已知BUG一只。。。人物跟随会被拉的很远。。出现囧囧的效果。。
RUBY 代码复制
  1. #===============================================================================
  2. #  八方向行走
  3. #    by:铅笔描绘的思念
  4. #    在Characters里添加八方向行走图(命名规范:在四方向上的基础上+_8D)
  5. #    行走动画就为8方向的。否则就会原4方向的代替8方向的。
  6. #
  7. #    八方向:数字键盘方向对应的数字
  8. #     7   8   9
  9. #      ↖ ↑ ↗
  10. #     4← 0 →6
  11. #      ↙ ↓ ↘
  12. #     1   2   3
  13. #===============================================================================
  14. #==============================================================================
  15. # ■ Game_Player
  16. #==============================================================================
  17. class Game_Player < Game_Character
  18.   #--------------------------------------------------------------------------
  19.   # ● 八方向移动
  20.   #    d    :1、3、7、9 对应小键盘的四个方向
  21.   #--------------------------------------------------------------------------
  22.   def move_eight_dir(d)
  23.     move_diagonal(d + 3,2) if d == 1 || d == 3
  24.     move_diagonal(d - 3,8) if d == 7 || d == 9
  25.   end
  26.   #--------------------------------------------------------------------------
  27.   # ● 八方向按键
  28.   #--------------------------------------------------------------------------
  29.   def move_by_input
  30.     return if !movable? || $game_map.interpreter.running?
  31.     case Input.dir8
  32.      when 1,3,7,9;  move_eight_dir(Input.dir8)
  33.      when 2,4,6,8;  move_straight(Input.dir4)
  34.     end
  35.   end
  36.   #--------------------------------------------------------------------------
  37.   # ● 斜向移动
  38.   #     horz : 横向(4 or 6)
  39.   #     vert : 纵向(2 or 8)
  40.   #--------------------------------------------------------------------------
  41.   def move_diagonal(horz, vert)
  42.     @followers.move if diagonal_passable?(@x, @y, horz, vert)
  43.     @move_succeed = diagonal_passable?(x, y, horz, vert)
  44.     last_steps = $game_party.steps
  45.     if @move_succeed
  46.       @x = $game_map.round_x_with_direction(@x, horz)
  47.       @y = $game_map.round_y_with_direction(@y, vert)
  48.       @real_x = $game_map.x_with_direction(@x, reverse_dir(horz))
  49.       @real_y = $game_map.y_with_direction(@y, reverse_dir(vert))
  50.       increase_steps
  51.       # 八方向移动正确步数计算
  52.       if $game_party.steps - last_steps == 2
  53.         $game_party.decrease_steps
  54.       end
  55.     end
  56.     set_direction(2) if horz == 4 && vert == 2
  57.     set_direction(4) if horz == 4 && vert == 8
  58.     set_direction(6) if horz == 6 && vert == 2
  59.     set_direction(8) if horz == 6 && vert == 8
  60.   end
  61. end
  62. #==============================================================================
  63. # ■ Game_Party
  64. #==============================================================================
  65. class Game_Party < Game_Unit
  66.   def decrease_steps
  67.     @steps -= 1
  68.   end
  69. end
  70. #==============================================================================
  71. # ■ Sprite_Character
  72. #==============================================================================
  73. class Sprite_Character < Sprite_Base
  74.   #--------------------------------------------------------------------------
  75.   # ● 更新源位图(Source Bitmap)
  76.   #--------------------------------------------------------------------------
  77.   alias update_bitmap_8dir update_bitmap
  78.   def update_bitmap
  79.     update_bitmap_8dir
  80.     if @tile_id > 0            
  81.       @enable_slant = false
  82.       return
  83.     end
  84.     unless graphic_changed?
  85.      @enable_slant = true
  86.    end
  87.  
  88.     begin
  89.       @character_name_slant = "#{@character_name}_8D"
  90.       Cache.character(@character_name_slant)  
  91.     rescue
  92.       @enable_slant = false
  93.     end
  94.   end
  95.   #--------------------------------------------------------------------------
  96.   # ● 更新源矩形
  97.   #--------------------------------------------------------------------------
  98.   alias update_src_rect_8dir update_src_rect  
  99.   def update_src_rect
  100.     return if @tile_id > 0      
  101.     if @enable_slant && @character != $game_map.events
  102.       update_src_rect_for_slant
  103.     else
  104.       update_src_rect_8dir
  105.     end
  106.   end
  107.   #--------------------------------------------------------------------------
  108.   # ● 更新斜方向传送矩形
  109.   #--------------------------------------------------------------------------
  110.   def update_src_rect_for_slant
  111.     index = @character.character_index
  112.     pattern = @character.pattern < 3 ? @character.pattern : 1
  113.     sx = (index % 4 * 3 + pattern) * @cw
  114.     case Input.dir8 % 2
  115.     when 0  # 上下左右
  116.       if @last_slant
  117.         self.bitmap = Cache.character(@character_name)
  118.         @last_slant = false
  119.       end
  120.     else   
  121.       unless @last_slant
  122.         self.bitmap = Cache.character(@character_name_slant)
  123.         @last_slant = true
  124.       end
  125.     end
  126.       sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
  127.     self.src_rect.set(sx, sy, @cw, @ch)
  128.   end
  129. end

附件: 8fangxiang.zip (330.59 KB, 下载次数: 2224) dll自备

点评

发现bug!!!设置一下成员行走图跟随效果,你就懂了。。。  发表于 2012-7-22 17:34
表示bug暂无。。。但是如果要设置事件的八方向移动。。。该肿么办。。。  发表于 2012-7-22 17:31

评分

参与人数 6星屑 +724 +6 收起 理由
Shy07 + 6 主站收录
任F + 24 塞糖
Kimu + 400 话说行走图的说明写反了吧
明特·布兰马修 + 238 塞糖
荷包PIG蛋 + 14 感谢你的事件和脚本~
sszny + 48 塞糖

查看全部评分

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

本版积分规则

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

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

GMT+8, 2024-5-17 08:11

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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