Project1
标题:
【 行走图 】 使用 ___ 8个方向行走图 __ 的脚本 ?
[打印本页]
作者:
Ceopal
时间:
2013-8-4 20:02
标题:
【 行走图 】 使用 ___ 8个方向行走图 __ 的脚本 ?
本帖最后由 Ceopal 于 2013-8-5 02:12 编辑
就是那种使用8个方向的人物行走图的脚本
作者:
Sion
时间:
2013-8-4 22:22
#===============================================================================
# 八方向行走
# by:铅笔描绘的思念
# 在Characters里添加八方向行走图(命名规范:在四方向上的基础上+_8D)
# 行走动画就为8方向的。否则就会原4方向的代替8方向的。
#
# 八方向:数字键盘方向对应的数字
# 7 8 9
# ↖ ↑ ↗
# 4← 0 →6
# ↙ ↓ ↘
# 1 2 3
#
# 2013.4.30 Edited by me
#
# 各种bug修正 + 各种效率优化
# 8d行走图需用.png格式
#
# 这个脚本可以独立正常工作
# 注意:同鼠标脚本配合使用,需要置于·八方移动补丁·上方!
#
#===============================================================================
class Game_Player
def move_by_input
return if !movable? || $game_map.interpreter.running?
case Input.dir8
when 2,4,6,8; move_straight(Input.dir8)
when 1; move_diagonal(4, 2)
when 3; move_diagonal(6, 2)
when 7; move_diagonal(4, 8)
when 9; move_diagonal(6, 8)
end
end
end
class Game_CharacterBase
def move_diagonal(horz, vert)
@move_succeed = diagonal_passable?(x, y, horz, vert)
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
end
if horz == 4
vert == 2 ? set_direction(1) : set_direction(7)
else
vert == 2 ? set_direction(3) : set_direction(9)
end
end
end
class Sprite_Character < Sprite_Base
def set_character_bitmap
if File.exist?("Graphics/Characters/#{@character_name}_8D.png")
@_8d = true
bitmap1 = Cache.character(@character_name)
bitmap2 = Cache.character(@character_name + "_8D")
width = bitmap1.width
height = bitmap1.height
rect = Rect.new(0, 0, width, height)
self.bitmap = Bitmap.new(width * 2, height * 2)
self.bitmap.blt(0, 0, bitmap1, rect)
self.bitmap.blt(width, 0, bitmap2, rect)
sign = @character_name[/^[\!\$]./]
if sign && sign.include?("$")
@cw = width / 3
@ch = height / 4
else
@cw = width / 12
@ch = height / 8
end
self.ox = @cw / 2
self.oy = @ch
else
self.bitmap = Cache.character(@character_name)
sign = @character_name[/^[\!\$]./]
if sign && sign.include?("$")
@cw = bitmap.width / 3
@ch = bitmap.height / 4
else
@cw = bitmap.width / 12
@ch = bitmap.height / 8
end
self.ox = @cw / 2
self.oy = @ch
end
end
def update_src_rect
return if @tile_id != 0
index = @character.character_index
pattern = @character.pattern < 3 ? @character.pattern : 1
sx = (index % 4 * 3 + pattern) * @cw
if @character.direction % 2 == 1
sx += self.bitmap.width / 2 if @_8d
row = case @character.direction
when 1; 0
when 3; 2
when 7; 1
when 9; 3
end
sy = (index / 4 * 4 + row) * @ch
else
sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
end
self.src_rect.set(sx, sy, @cw, @ch)
end
end
复制代码
http://rpg.blue/forum.php?mod=viewthread&tid=242869 这是原帖,你可以去看看使用说明。我这个给他优化好了
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1