Project1
标题:
怎样让两个事件之间保持一定的距离,移动的时候一起移...
[打印本页]
作者:
wgr273
时间:
2013-12-8 20:44
标题:
怎样让两个事件之间保持一定的距离,移动的时候一起移...
本帖最后由 wgr273 于 2013-12-9 14:46 编辑
怎样让两个事件之间保持一定的距离,移动的时候一起移动?
作者:
嫁衣
时间:
2013-12-9 14:36
b64w3h63645u35.jpg
(35.44 KB, 下载次数: 20)
下载附件
保存到相册
2013-12-9 14:36 上传
作者:
wgr273
时间:
2013-12-9 14:46
嫁衣 发表于 2013-12-9 14:36
我是要他们自动移动,不需要按按键哦!自动向左移动,自动向右移动!我已经自己解决了,只需要设置变量就可以了!谢谢你的回答!
作者:
domodomodomo
时间:
2013-12-9 16:22
或许你需要一个队友跟随的脚本
# rgss-lib
=begin
DQシステムスクリプト Train_Actor
Author:: yf30 at users.sourceforge.jp (http://sourceforge.jp/users/yf30/)
Date:: 2009/02/26
Copyright:: Copyright (C) 2004-2009 rgss-lib
URL:: http://sourceforge.jp/projects/rgss-lib/
=end
# dq
# train_actor
# Config.rb
#==============================================================================
# ■ Train_Actor::Config
#------------------------------------------------------------------------------
# マップ上でアクターを隊列移動させる
#==============================================================================
module Train_Actor
# ●透明状態用スイッチ設定
# true だとスイッチ制御を行う
#TRANSPARENT_SWITCH = true
TRANSPARENT_SWITCH = false
# ●透明状態用スイッチ番号
# TRANSPARENT_SWITCH が true で、この番号のスイッチがONだと透明になる
TRANSPARENT_SWITCHES_INDEX = 20
# ●アクターの最大数
# 将来的に多人数パーティが出来るようになったら…
TRAIN_ACTOR_SIZE_MAX = 4
# 死亡時のキャラクターグラフィック名
#DEAD_CHARACTER_NAME = "Coffin"
DEAD_CHARACTER_NAME = ""
# 定数
DOWN_LEFT = 1
DOWN_RIGHT = 3
UP_LEFT = 7
UP_RIGHT = 9
JUMP = 5
STOP = 0
end
# rgss
# Game_Event_Module.rb
# Game_Event_Module
# マップ上でアクターを隊列移動させる
# Author:: fukuyama
# Date:: 2006/03/05
# Copyright:: Copyright (C) 2005 fukuyama
module Train_Actor
module Game_Event_Module
# 通行可能判定
# x:: X 座標
# y:: Y 座標
# d:: 方向 (0,2,4,6,8) ※ 0 = 全方向通行不可の場合を判定 (ジャンプ用)
# return:: 通行不可 false 可能 true
def passable?(x, y, d)
result = super(x, y, d)
return result if @through
if result
# 新しい座標を求める
new_x = x + (d == 6 ? 1 : d == 4 ? -1 : 0)
new_y = y + (d == 2 ? 1 : d == 8 ? -1 : 0)
# トレインアクターのループ
for actor in $game_party.characters
# 表示されている場合
if (not actor.character_name.empty?) and (not actor.transparent)
# アクターの座標が移動先と一致した場合
if actor.x == new_x and actor.y == new_y
# 自分がイベントの場合
if self != $game_player
# 通行不可
return false
end
end
end
end
end
return result
end
end
end
class Game_Event
include Train_Actor::Game_Event_Module
end
# Game_Party_Module.rb
# Train_Actor::Game_Party_Module
# Game_Party用隊列歩行モジュール
# Author:: fukuyama
# Date:: 2007/12/31
# Copyright:: Copyright (C) 2005-2007 rgss-lib
module Train_Actor
module Game_Party_Module
attr_reader :characters
def dead_actor_include?
for actor in actors
if actor.dead?
return true
end
end
return false
end
def get_active_party_order
if not dead_actor_include?
return actors
end
alive_actors = []
dead_actors = []
for actor in actors
if actor.dead?
dead_actors.push actor
else
alive_actors.push actor
end
end
return alive_actors + dead_actors
end
def setup_actor_character_sprites
if @characters.nil?
@characters = []
for i in 1 ... TRAIN_ACTOR_SIZE_MAX
@characters.push(Game_Party_Actor.new(i - 1))
end
end
setup_actors = get_active_party_order
for i in 1 .. @characters.size
@characters[i - 1].setup(setup_actors[i])
end
if $scene.class.method_defined?('setup_actor_character_sprites')
$scene.setup_actor_character_sprites
end
end
def transparent_switch
if TRANSPARENT_SWITCH
unless $game_player.transparent
return $game_switches[TRANSPARENT_SWITCHES_INDEX]
end
end
return $game_player.transparent
end
def update_party_actors
setup_actor_character_sprites
transparent = transparent_switch
for character in @characters
character.transparent = transparent
character.update
end
end
#cob
def moveto_party_actors( x, y )
setup_actor_character_sprites
@move_list = []
move_list_setup
follow = true
for character in @characters
if follow
if $game_player.passable?(x, y, 10 - $game_player.direction)
case $game_player.direction
when 2
y -= 1
add_move_list(Input::DOWN)
when 4
x += 1
add_move_list(Input::LEFT)
when 6
x -= 1
add_move_list(Input::RIGHT)
when 8
y += 1
add_move_list(Input::UP)
end
else
follow = false
end
end
character.moveto(x, y)
end
end
def move_party_actors
if @move_list == nil
@move_list = []
move_list_setup
end
@move_list.each_index do |i|
if not @characters[i].nil?
@characters[i].add_move_list_element(@move_list[i])
end
end
end
#cob
def turn_left_party_actors
for character in @characters
character.turn_left
end
end
def initialize_location
for character in @characters
character.moveto($game_player.x, $game_player.y - 1)
character.turn_down
end
end
class Move_List_Element
def initialize(type,args)
@type = type
@args = args
end
def type() return @type end
def args() return @args end
end
def move_list_setup
for i in 0 .. TRAIN_ACTOR_SIZE_MAX
@move_list[i] = nil
end
end
def add_move_list(type,*args)
@move_list.unshift(Move_List_Element.new(type,args)).pop
end
def move_down_party_actors(turn_enabled = true)
move_party_actors
add_move_list(Input::DOWN,turn_enabled)
end
def move_left_party_actors(turn_enabled = true)
move_party_actors
add_move_list(Input::LEFT,turn_enabled)
end
def move_right_party_actors(turn_enabled = true)
move_party_actors
add_move_list(Input::RIGHT,turn_enabled)
end
def move_up_party_actors(turn_enabled = true)
move_party_actors
add_move_list(Input::UP,turn_enabled)
end
def move_lower_left_party_actors
move_party_actors
add_move_list(DOWN_LEFT)
end
def move_lower_right_party_actors
move_party_actors
add_move_list(DOWN_RIGHT)
end
def move_upper_left_party_actors
move_party_actors
add_move_list(UP_LEFT)
end
def move_upper_right_party_actors
move_party_actors
add_move_list(UP_RIGHT)
end
def jump_party_actors(x_plus, y_plus)
move_party_actors
add_move_list(JUMP,x_plus, y_plus)
move_stop_party_actors
end
def move_stop_party_actors
actors.each do |a|
move_party_actors
add_move_list(STOP)
end
end
end
end
class Game_Party
include Train_Actor::Game_Party_Module
# アクターを加える
# actor_id:: アクター ID
def add_actor(actor_id)
# アクターを取得
actor = $game_actors[actor_id]
# パーティ人数が 4 人未満で、このアクターがパーティにいない場合
if @actors.size < Train_Actor::TRAIN_ACTOR_SIZE_MAX and not @actors.include?(actor)
# アクターを追加
@actors.push(actor)
# プレイヤーをリフレッシュ
$game_player.refresh
end
end
end
# Game_Player_Module.rb
# Train_Actor::Game_Player_Module
# Game_Player用隊列歩行モジュール
# Author:: fukuyama
# Date:: 2007/12/31
# Copyright:: Copyright (C) 2005-2007 rgss-lib
module Train_Actor
module Game_Player_Module
attr_reader :move_speed
attr_reader :step_anime
attr_reader :direction_fix
def update_party_actors
if $game_party.actors.empty?
return
end
$game_party.update_party_actors
actor = $game_party.actors[0]
if not actor.dead?
if not @prev_dead.nil?
@character_name = actor.character_name
@character_hue = actor.character_hue
@prev_dead = nil
end
return
end
@prev_dead = true
$game_party.actors.each do |actor|
if not actor.dead?
@character_name = actor.character_name
@character_hue = actor.character_hue
break
end
end
end
def update
update_party_actors
super
end
def moveto( x, y )
$game_party.moveto_party_actors( x, y )
super( x, y )
end
def move_down(turn_enabled = true)
if passable?(@x, @y, Input::DOWN)
$game_party.move_down_party_actors(turn_enabled)
end
super(turn_enabled)
end
def move_left(turn_enabled = true)
if passable?(@x, @y, Input::LEFT)
$game_party.move_left_party_actors(turn_enabled)
end
super(turn_enabled)
end
def move_right(turn_enabled = true)
if passable?(@x, @y, Input::RIGHT)
$game_party.move_right_party_actors(turn_enabled)
end
super(turn_enabled)
end
def move_up(turn_enabled = true)
if passable?(@x, @y, Input::UP)
$game_party.move_up_party_actors(turn_enabled)
end
super(turn_enabled)
end
def move_lower_left
# 下→左、左→下 のどちらかのコースが通行可能な場合
if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
(passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
$game_party.move_lower_left_party_actors
end
super
end
def move_lower_right
# 下→右、右→下 のどちらかのコースが通行可能な場合
if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
(passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
$game_party.move_lower_right_party_actors
end
super
end
def move_upper_left
# 上→左、左→上 のどちらかのコースが通行可能な場合
if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
(passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
$game_party.move_upper_left_party_actors
end
super
end
def move_upper_right
# 上→右、右→上 のどちらかのコースが通行可能な場合
if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
(passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
$game_party.move_upper_right_party_actors
end
super
end
def jump(x_plus, y_plus)
# 新しい座標を計算
new_x = @x + x_plus
new_y = @y + y_plus
# 加算値が (0,0) の場合か、ジャンプ先が通行可能な場合
if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y, 0)
$game_party.jump_party_actors(x_plus, y_plus)
end
super(x_plus, y_plus)
end
end
end
class Game_Player
include Train_Actor::Game_Player_Module
end
# Scene_Map_Module.rb
# Train_Actor::Scene_Map_Module
# Scene_Map用隊列歩行モジュール
# Author:: fukuyama
# Date:: 2007/12/31
# Copyright:: Copyright (C) 2005-2007 rgss-lib
module Train_Actor
module Scene_Map_Module
def setup_actor_character_sprites
@spriteset.setup_actor_character_sprites
end
end
end
class Scene_Map
include Train_Actor::Scene_Map_Module
end
# Spriteset_Map_Module.rb
# Train_Actor::Spriteset_Map_Module
# Spriteset_Map用隊列歩行モジュール
# Author:: fukuyama
# Date:: 2007/12/31
# Copyright:: Copyright (C) 2005-2007 rgss-lib
module Train_Actor
module Spriteset_Map_Module
def setup_actor_character_sprites?
return @setup_actor_character_sprites_flag != nil
end
#cob
def setup_actor_character_sprites
return unless $game_party.characters
if not setup_actor_character_sprites?
for character in $game_party.characters.reverse
@character_sprites.unshift(Sprite_Character.new(@viewport1, character))
end
@setup_actor_character_sprites_flag = true
end
end
end
end
class Spriteset_Map
include Train_Actor::Spriteset_Map_Module
end
# Game_Party_Actor.rb
# Train_Actor::Game_Party_Actor
# マップ上のパーティ用キャラクター
# Author:: fukuyama
# Date:: 2007/12/31
# Copyright:: Copyright (C) 2005-2007 rgss-lib
module Train_Actor
class Game_Party_Actor < Game_Character
def initialize(character_index)
super()
@character_index = character_index
@character_wait = 0
@through = true
# 不透明度と合成方法を初期化
[url=home.php?mod=space&uid=316553]@opacity[/url] = 255
@blend_type = 0
@move_list = []
end
def setup(actor)
# キャラクターのファイル名と色相を設定
if actor.nil?
@character_name = ""
@character_hue = 0
elsif not actor.dead? # 死んでる場合とりあえず、消しとこ…
@character_name = actor.character_name
@character_hue = actor.character_hue
else
@character_name = DEAD_CHARACTER_NAME
@character_hue = 0
end
end
def update
@move_speed = $game_player.move_speed
@step_anime = $game_player.step_anime
@opacity = $game_player.opacity
@blend_type = $game_player.blend_type
@direction_fix = $game_player.direction_fix
if @direction_fix
@direction = $game_player.direction
end
update_move_list()
super
end
def screen_z(height = 0)
if $game_player.screen_z(height) == 999
return 998
end
if $game_player.x == @x and $game_player.y == @y
super(height) - 1
else
super(height)
end
end
def add_move_list_element(element)
@move_list.push(element)
if @move_list.size == 1
update_move_list()
end
end
def move_list_size
return @move_list.size
end
def update_move_list()
return if moving?
if @move_list.empty?
@direction = $game_player.direction unless @direction_fix
return
end
return if @move_list.empty?
if @move_list[0].type == STOP
if @character_index != 0
character = $game_party.characters[@character_index - 1]
if character.x == @x and character.y == @y and character.direction == @direction
@character_wait = 128 / (2 ** @move_speed) + 1
while character.move_list_size < @move_list.size and @move_list[0].type == STOP
@move_list.shift
end
end
end
else
@character_wait = 0
end
if @character_wait > 0
@character_wait -= 1
return
end
element = @move_list.shift
while element.type == STOP
element = @move_list.shift
end
case element.type
when Input::DOWN
move_down(element.args[0])
when Input::LEFT
move_left(element.args[0])
when Input::RIGHT
move_right(element.args[0])
when Input::UP
move_up(element.args[0])
when DOWN_LEFT
move_lower_left
when DOWN_RIGHT
move_lower_right
when UP_LEFT
move_upper_left
when UP_RIGHT
move_upper_right
when JUMP
jump(element.args[0],element.args[1])
end
end
#cob
def moveto( x, y )
@move_list.clear
straighten
@direction = $game_player.direction
super(x, y)
end
#--------------------------------------------------------------------------
# ● 下に移動
# turn_enabled : その場での向き変更を許可するフラグ
#--------------------------------------------------------------------------
def move_down(turn_enabled = true)
# 下を向く
if turn_enabled
turn_down
end
# 通行可能な場合
if passable?(@x, @y, Input::DOWN)
# 下を向く
turn_down
# 座標を更新
@y = (@y + 1 + $game_map.height) % ($game_map.height)
@real_y = (@y - 1) * 128
end
end
#--------------------------------------------------------------------------
# ● 左に移動
# turn_enabled : その場での向き変更を許可するフラグ
#--------------------------------------------------------------------------
def move_left(turn_enabled = true)
# 左を向く
if turn_enabled
turn_left
end
# 通行可能な場合
if passable?(@x, @y, Input::LEFT)
# 左を向く
turn_left
# 座標を更新
@x = (@x - 1 + $game_map.width) % ($game_map.width)
@real_x = (@x + 1) * 128
end
end
#--------------------------------------------------------------------------
# ● 右に移動
# turn_enabled : その場での向き変更を許可するフラグ
#--------------------------------------------------------------------------
def move_right(turn_enabled = true)
# 右を向く
if turn_enabled
turn_right
end
# 通行可能な場合
if passable?(@x, @y, Input::RIGHT)
# 右を向く
turn_right
# 座標を更新
@x = (@x + 1 + $game_map.width) % ($game_map.width)
@real_x = (@x - 1) * 128
end
end
#--------------------------------------------------------------------------
# ● 上に移動
# turn_enabled : その場での向き変更を許可するフラグ
#--------------------------------------------------------------------------
def move_up(turn_enabled = true)
# 上を向く
if turn_enabled
turn_up
end
# 通行可能な場合
if passable?(@x, @y, Input::UP)
# 上を向く
turn_up
# 座標を更新
@y = (@y - 1 + $game_map.height) % ($game_map.height)
@real_y = (@y + 1) * 128
end
end
end
end
复制代码
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1