Project1

标题: VX如何可以进行“斜走”(双键同时按下) [打印本页]

作者: tjjlb    时间: 2012-11-6 20:59
标题: VX如何可以进行“斜走”(双键同时按下)
本帖最后由 tjjlb 于 2012-11-6 21:18 编辑

VX如何可以进行“斜走”?(双键同时按下)

例如 ↑ 和 →  一起按下,就可以像右上方行走


@protosssonny P叔这次可以么?



感谢P叔!!!
作者: 怪蜀黍    时间: 2012-11-6 21:17
简单的饭菜应该留给大家。
但是你又是指定P叔回答,浪费饭菜了。
还有就是@失效了。
按照《6道》作者的方法吧,《八方向行走脚本》是可行的。
八方向行走脚本:

  1. #==============================================================================
  2. # ■ Game_Character
  3. #==============================================================================

  4. class Game_Character
  5.   #--------------------------------------------------------------------------
  6.   # ● 八方向
  7.   #--------------------------------------------------------------------------
  8.   def direction_8dir
  9.     return @direction
  10.   end
  11.   #--------------------------------------------------------------------------
  12.   # ● 变成指定方向
  13.   #     direction : 方向
  14.   #--------------------------------------------------------------------------
  15.   alias set_direction_8fangxiang set_direction
  16.   def set_direction(direction)
  17.     last_dir = @direction
  18.     set_direction_8fangxiang(direction)
  19.     if !@direction_fix && direction != 0
  20.       @direction_8dir = direction
  21.     end
  22.   end
  23.   #--------------------------------------------------------------------------
  24.   # ● 向左下移动
  25.   #--------------------------------------------------------------------------
  26.   alias move_lower_left_8fangxiang move_lower_left
  27.   def move_lower_left
  28.     move_lower_left_8fangxiang
  29.     @direction_8dir = 1 unless @direction_fix
  30.   end
  31.   #--------------------------------------------------------------------------
  32.   # ● 向右下移动
  33.   #--------------------------------------------------------------------------
  34.   alias move_lower_right_8fangxiang move_lower_right
  35.   def move_lower_right
  36.     move_lower_right_8fangxiang
  37.     @direction_8dir = 3 unless @direction_fix
  38.   end
  39.   #--------------------------------------------------------------------------
  40.   # ● 向左上移动
  41.   #--------------------------------------------------------------------------
  42.   alias move_upper_left_8fangxiang move_upper_left
  43.   def move_upper_left
  44.     move_upper_left_8fangxiang
  45.     @direction_8dir = 7 unless @direction_fix
  46.   end
  47.   #--------------------------------------------------------------------------
  48.   # ● 向右上移动
  49.   #--------------------------------------------------------------------------
  50.   alias move_upper_right_8fangxiang move_upper_right
  51.   def move_upper_right
  52.     move_upper_right_8fangxiang
  53.     @direction_8dir = 9 unless @direction_fix
  54.   end
  55. end
  56. #==============================================================================
  57. # ■ Game_Party
  58. #==============================================================================

  59. class Game_Party < Game_Unit
  60.   def decrease_steps
  61.     @steps -= 1
  62.   end
  63. end

  64. #==============================================================================
  65. # ■ Game_Player
  66. #==============================================================================

  67. class Game_Player < Game_Character

  68.   #--------------------------------------------------------------------------
  69.   # ●八方向
  70.   #--------------------------------------------------------------------------
  71.   def direction_8dir
  72.     @direction_8dir = @direction if @direction_8dir == nil
  73.     return @direction_8dir
  74.   end
  75.   #--------------------------------------------------------------------------
  76.   # ● 八方向按键
  77.   #--------------------------------------------------------------------------
  78.   def move_by_input
  79.     return unless movable?
  80.     return if $game_map.interpreter.running?
  81.     last_steps = $game_party.steps
  82.     case Input.dir8
  83.     when 1;  move_down; move_left; @direction = 2
  84.     when 2;  move_down
  85.     when 3;  move_down; move_right; @direction = 6
  86.     when 4;  move_left
  87.     when 6;  move_right
  88.     when 7;  move_up; move_left; @direction = 4
  89.     when 8;  move_up
  90.     when 9;  move_up; move_right; @direction = 8
  91.     else;    return
  92.     end
  93.     @direction_8dir = Input.dir8
  94.     # 斜方向移动正确步数计算
  95.     if $game_party.steps - last_steps == 2
  96.       $game_party.decrease_steps
  97.     end
  98.   end
  99.   
  100.   #--------------------------------------------------------------------------
  101.   # ● 移动更新
  102.   #--------------------------------------------------------------------------
  103.   def update_move
  104.     distance = 2 ** @move_speed   
  105.     if dash?                     
  106.       distance *= 2
  107.     end
  108.     distance = Integer(distance)
  109.     @real_x = [@real_x - distance, @x * 256].max if @x * 256 < @real_x
  110.     @real_x = [@real_x + distance, @x * 256].min if @x * 256 > @real_x
  111.     @real_y = [@real_y - distance, @y * 256].max if @y * 256 < @real_y
  112.     @real_y = [@real_y + distance, @y * 256].min if @y * 256 > @real_y
  113.     update_bush_depth unless moving?
  114.     if @walk_anime
  115.       @anime_count += 1.5
  116.     elsif @step_anime
  117.       @anime_count += 1
  118.     end
  119.   end
  120. end
  121. #==============================================================================
  122. # ■ Sprite_Character
  123. #==============================================================================
  124. class Sprite_Character < Sprite_Base
  125.   
  126.   ANIME_TABLE = { 1=>2, 3=>6, 7=>4, 9=>8 }
  127.   #--------------------------------------------------------------------------
  128.   # ● 更新位图
  129.   #--------------------------------------------------------------------------
  130.   alias update_bitmap_8fangxiang update_bitmap
  131.   def update_bitmap
  132.     name_changed = (@character_name != @character.character_name)
  133.     update_bitmap_8fangxiang
  134.     if @tile_id > 0            
  135.       @enable_slant = false
  136.       return
  137.     end
  138.     return unless name_changed  
  139.     @enable_slant = true
  140.     begin
  141.       @character_name_slant = @character_name + "#"
  142.       Cache.character(@character_name_slant)
  143.     rescue
  144.       @enable_slant = false
  145.     end
  146.   end
  147.   #--------------------------------------------------------------------------
  148.   # ● 更新传送矩形
  149.   #--------------------------------------------------------------------------
  150.   alias update_src_rect_8fangxiang update_src_rect
  151.   def update_src_rect
  152.     return if @tile_id > 0  
  153.     if @enable_slant
  154.       update_src_rect_for_slant
  155.     else
  156.       update_src_rect_8fangxiang
  157.     end
  158.   end
  159.   #--------------------------------------------------------------------------
  160.   # ● 更新斜方向传送矩形
  161.   #--------------------------------------------------------------------------
  162.   def update_src_rect_for_slant
  163.     index = @character.character_index
  164.     pattern = @character.pattern < 3 ? @character.pattern : 1
  165.     sx = (index % 4 * 3 + pattern) * @cw
  166.     dir = @character.direction_8dir
  167.     case dir % 2
  168.     when 0  # 上下左右
  169.       if @last_slant
  170.         self.bitmap = Cache.character(@character_name)
  171.         @last_slant = false
  172.       end
  173.     else   
  174.       unless @last_slant
  175.         self.bitmap = Cache.character(@character_name_slant)
  176.         @last_slant = true
  177.       end
  178.       dir = ANIME_TABLE[dir]
  179.     end
  180.     sy = (index / 4 * 4 + (dir - 2) / 2) * @ch
  181.     self.src_rect.set(sx, sy, @cw, @ch)
  182.   end
  183. end

复制代码

作者: tjjlb    时间: 2012-11-6 21:18
protosssonny 发表于 2012-11-6 21:17
简单的饭菜应该留给大家。
但是你又是指定P叔回答,浪费饭菜了。
还有就是@失效了。{:4_ ...

感谢!!!
作者: 826472493    时间: 2012-11-11 10:37
刚好我也在找




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