本帖最后由 a0936459772 于 2013-7-28 10:21 编辑
无能菌 发表于 2013-7-27 00:32
嗯..那就只好这样了..还有一个问题就是经常看到的...就你发的例子来看 如何做到'让玩家在缺口前面对缺口 ...
一个开关、一个变量、一个公共事件、两段代码搞定
先在Game_Event的144行貼上两段代码
#-------------------------------------------------------------------------- # ● 判定事件是否與玩家相鄰 #這是新增部分 非預設內容 #-------------------------------------------------------------------------- def contact_the_player? sx = distance_x_from($game_player.x).abs sy = distance_y_from($game_player.y).abs sx + sy == 1 end
#--------------------------------------------------------------------------
# ● 判定事件是否與玩家相鄰 #這是新增部分 非預設內容
#--------------------------------------------------------------------------
def contact_the_player?
sx = distance_x_from($game_player.x).abs
sy = distance_y_from($game_player.y).abs
sx + sy == 1
end
#-------------------------------------------------------------------------- # ● 判定玩家是否朝向事件 #這是新增部分 非預設內容 #-------------------------------------------------------------------------- def face_the_event? sx = distance_x_from($game_player.x) sy = distance_y_from($game_player.y) return true if (sy > 0 && $game_player.direction == 2) return true if (sx < 0 && $game_player.direction == 4) return true if (sx > 0 && $game_player.direction == 6) return true if (sy < 0 && $game_player.direction == 8) end
#--------------------------------------------------------------------------
# ● 判定玩家是否朝向事件 #這是新增部分 非預設內容
#--------------------------------------------------------------------------
def face_the_event?
sx = distance_x_from($game_player.x)
sy = distance_y_from($game_player.y)
return true if (sy > 0 && $game_player.direction == 2)
return true if (sx < 0 && $game_player.direction == 4)
return true if (sx > 0 && $game_player.direction == 6)
return true if (sy < 0 && $game_player.direction == 8)
end
设定公共事件
$game_map.events[1].contact_the_player? 判定玩家是否與事件1相鄰
$game_map.events[1].face_the_event? 判定玩家是否朝向事件1
[]括號裡面的數字為事件ID
数据库中定义物品
最后附上范例工程!
Data.rar
(190.72 KB, 下载次数: 92)
|