| 赞 | 0 |
| VIP | |
| 好人卡 | |
| 积分 | 1 |
| 经验 | |
| 最后登录 | 2016-5-1 |
| 在线时间 | 381 小时 |
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 381 小时
- 注册时间
- 2012-8-13
- 回帖
- 103
|
发表于 2013-4-6 19:26:16
|
显示全部楼层
辛苦了!不知道鼠标操作的那个8方行走补丁是否可以考虑支持8方行走图?就是普遍使用的行走图+“_8D”来显示8方向的那个功能?
这个是铅笔写的键盘操作的8D行走图脚本,希望Sion可以参考一下:
- #===============================================================================
- # 八方向行走
- # by:铅笔描绘的思念
- # 在Characters里添加八方向行走图(命名规范:在四方向上的基础上+_8D)
- # 行走动画就为8方向的。否则就会原4方向的代替8方向的。
- #
- # 八方向:数字键盘方向对应的数字
- # 7 8 9
- # ↖ ↑ ↗
- # 4← 0 →6
- # ↙ ↓ ↘
- # 1 2 3
- #===============================================================================
- #==============================================================================
- # ■ Game_Player
- #==============================================================================
- class Game_Player < Game_Character
- #--------------------------------------------------------------------------
- # ● 八方向移动
- # d :1、3、7、9 对应小键盘的四个方向
- #--------------------------------------------------------------------------
- def move_eight_dir(d)
- move_diagonal(d + 3,2) if d == 1 || d == 3
- move_diagonal(d - 3,8) if d == 7 || d == 9
- end
- #--------------------------------------------------------------------------
- # ● 八方向按键
- #--------------------------------------------------------------------------
- def move_by_input
- return if !movable? || $game_map.interpreter.running?
- case Input.dir8
- when 1,3,7,9; move_eight_dir(Input.dir8)
- when 2,4,6,8; move_straight(Input.dir4)
- end
- end
- #--------------------------------------------------------------------------
- # ● 斜向移动
- # horz : 横向(4 or 6)
- # vert : 纵向(2 or 8)
- #--------------------------------------------------------------------------
- def move_diagonal(horz, vert)
- @followers.move if diagonal_passable?(@x, @y, horz, vert)
- @move_succeed = diagonal_passable?(x, y, horz, vert)
- last_steps = $game_party.steps
- if @move_succeed
- @x = $game_map.round_x_with_direction(@x, horz)
- @y = $game_map.round_y_with_direction(@y, vert)
- @real_x = $game_map.x_with_direction(@x, reverse_dir(horz))
- @real_y = $game_map.y_with_direction(@y, reverse_dir(vert))
- increase_steps
- # 八方向移动正确步数计算
- if $game_party.steps - last_steps == 2
- $game_party.decrease_steps
- end
- end
- set_direction(2) if horz == 4 && vert == 2
- set_direction(4) if horz == 4 && vert == 8
- set_direction(6) if horz == 6 && vert == 2
- set_direction(8) if horz == 6 && vert == 8
- end
- end
- #==============================================================================
- # ■ Game_Party
- #==============================================================================
- class Game_Party < Game_Unit
- def decrease_steps
- @steps -= 1
- end
- end
- #==============================================================================
- # ■ Sprite_Character
- #==============================================================================
- class Sprite_Character < Sprite_Base
- #--------------------------------------------------------------------------
- # ● 更新源位图(Source Bitmap)
- #--------------------------------------------------------------------------
- alias update_bitmap_8dir update_bitmap
- def update_bitmap
- update_bitmap_8dir
- if @tile_id > 0
- @enable_slant = false
- return
- end
- unless graphic_changed?
- @enable_slant = true
- end
-
- begin
- @character_name_slant = "#{@character_name}_8D"
- Cache.character(@character_name_slant)
- rescue
- @enable_slant = false
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新源矩形
- #--------------------------------------------------------------------------
- alias update_src_rect_8dir update_src_rect
- def update_src_rect
- return if @tile_id > 0
- if @enable_slant && @character != $game_map.events
- update_src_rect_for_slant
- else
- update_src_rect_8dir
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新斜方向传送矩形
- #--------------------------------------------------------------------------
- def update_src_rect_for_slant
- index = @character.character_index
- pattern = @character.pattern < 3 ? @character.pattern : 1
- sx = (index % 4 * 3 + pattern) * @cw
- case Input.dir8 % 2
- when 0 # 上下左右
- if @last_slant
- self.bitmap = Cache.character(@character_name)
- @last_slant = false
- end
- else
- unless @last_slant
- self.bitmap = Cache.character(@character_name_slant)
- @last_slant = true
- end
- end
- sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
- self.src_rect.set(sx, sy, @cw, @ch)
- end
- end
复制代码 |
|