设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 2017|回复: 5
打印 上一主题 下一主题

[已经解决] 全方向行走

[复制链接]

Lv3.寻梦者

梦石
0
星屑
3526
在线时间
1887 小时
注册时间
2010-6-19
帖子
1210
跳转到指定楼层
1
发表于 2014-8-7 08:43:16 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有帐号?注册会员

x
帮忙把下面这个全方向行走脚本的鼠标系统给去掉

全方向行走脚本.rar

2.37 MB, 下载次数: 62

评分

参与人数 1星屑 +35 收起 理由
RyanBern + 35 手动认可奖励

查看全部评分

Lv2.观梦者

梦石
0
星屑
380
在线时间
602 小时
注册时间
2014-5-8
帖子
699
2
发表于 2014-8-7 08:49:57 | 只看该作者
全方向行走脚本.rar (2.37 MB, 下载次数: 27)
这样可以不?

评分

参与人数 1星屑 +150 收起 理由
RyanBern + 150 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

Lv1.梦旅人

薄凉看客

梦石
0
星屑
50
在线时间
1269 小时
注册时间
2010-6-20
帖子
1316
3
发表于 2014-8-7 09:01:10 | 只看该作者
大概就这样

全方向行走脚本.rar

2.31 MB, 下载次数: 34

点评

发现个问题,和NPC对话的时候,对话框还在角色还可以移动。  发表于 2014-8-7 09:40
可以了  发表于 2014-8-7 09:33

评分

参与人数 1星屑 +150 收起 理由
RyanBern + 150 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

Lv3.寻梦者

梦石
0
星屑
3526
在线时间
1887 小时
注册时间
2010-6-19
帖子
1210
4
 楼主| 发表于 2014-8-7 09:34:08 | 只看该作者
恐惧剑刃 发表于 2014-8-7 09:01
大概就这样

帮我看看,这个人物跟随脚本放进去怎么没效果了。
  1. module Train_Actor


  2. #是否使用停止跟随的方法,也就是说,这里false改为true的时候,如果TRANSPARENT_SWITCHES_INDEX

  3. #开关打开,跟随的人物就消失了(其实只是变成透明而已)

  4. TRANSPARENT_SWITCH = true

  5. TRANSPARENT_SWITCHES_INDEX = 100

  6. #举例:第一个为true,第二个为100,则打开100号开关,后面的人都没了。

  7. #跟随人数的最大数目,可以更改为2、3什么的。

  8. TRAIN_ACTOR_SIZE_MAX = 4





  9. # 跟随距离,例如0为紧贴,1为分开一个身位

  10. TRAIN_ACTOR_DISTANCE = 0
  11. # 定数
  12. #Input::DOWN = 2
  13. #Input::LEFT = 4
  14. #Input::RIGHT = 6
  15. #Input::UP = 8
  16. DOWN_LEFT = 1
  17. DOWN_RIGHT = 3
  18. UP_LEFT = 7
  19. UP_RIGHT = 9
  20. JUMP = 5


  21.   
  22. # 叶子到此一游

  23. # 插入空角色,造成分开一段距离跟随的假象

  24. TRAIN_ACTOR_SIZE_MAX = TRAIN_ACTOR_SIZE_MAX * (TRAIN_ACTOR_DISTANCE+1) + 1

  25. class Game_Party_Actor < Game_Character
  26. attr_reader  :name
  27. def initialize

  28. super()

  29. @through = true

  30. end

  31. def setup(actor)
  32.   
  33. # キャラクターのファイル名と色相を設定

  34. if actor != nil
  35.   @name = actor.name + ",3我勒个去"
  36.   if $game_player.moving?
  37.     @character_name = actor.character_name
  38.   else
  39.     if actor.id < 50    #ID小于50的角色可以显示待机动画
  40.       @character_name = actor.character_name + "_W"
  41.     else
  42.       @character_name = actor.character_name
  43.     end
  44.   end
  45.   @character_hue = actor.character_hue
  46.   @tempneme = actor.name
  47. else
  48.   @name = ","

  49. @character_name = ""

  50. @character_hue = 0

  51. end

  52. # 不透明度と合成方法を初期化
  53. @opacity = 255
  54. @blend_type = 0
  55. end
  56. def screen_z(height = 0)
  57. if $game_player.x == @x and $game_player.y == @y
  58. return $game_player.screen_z(height) - 1
  59. end
  60. super(height)
  61. end
  62. #--------------------------------------------------------------------------
  63. # ● 下に移動
  64. # turn_enabled : その場での向き変更を許可するフラグ
  65. #--------------------------------------------------------------------------
  66. def move_down(turn_enabled = true)
  67. # 下を向く
  68. if turn_enabled
  69. turn_down
  70. end
  71. # 通行可能な場合
  72. if passable?(@x, @y, Input::DOWN)
  73. # 下を向く
  74. turn_down
  75. # 座標を更新
  76. @y += 1
  77. end
  78. end
  79. #--------------------------------------------------------------------------
  80. # ● 左に移動
  81. # turn_enabled : その場での向き変更を許可するフラグ
  82. #--------------------------------------------------------------------------
  83. def move_left(turn_enabled = true)
  84. # 左を向く
  85. if turn_enabled
  86. turn_left
  87. end
  88. # 通行可能な場合
  89. if passable?(@x, @y, Input::LEFT)
  90. # 左を向く
  91. turn_left
  92. # 座標を更新
  93. @x -= 1
  94. end
  95. end
  96. #--------------------------------------------------------------------------
  97. # ● 右に移動
  98. # turn_enabled : その場での向き変更を許可するフラグ
  99. #--------------------------------------------------------------------------
  100. def move_right(turn_enabled = true)
  101. # 右を向く
  102. if turn_enabled
  103. turn_right
  104. end
  105. # 通行可能な場合
  106. if passable?(@x, @y, Input::RIGHT)
  107. # 右を向く
  108. turn_right
  109. # 座標を更新
  110. @x += 1
  111. end
  112. end
  113. #--------------------------------------------------------------------------
  114. # ● 上に移動
  115. # turn_enabled : その場での向き変更を許可するフラグ
  116. #--------------------------------------------------------------------------
  117. def move_up(turn_enabled = true)
  118. # 上を向く
  119. if turn_enabled
  120. turn_up
  121. end
  122. # 通行可能な場合
  123. if passable?(@x, @y, Input::UP)
  124. # 上を向く
  125. turn_up
  126. # 座標を更新
  127. @y -= 1
  128. end
  129. end
  130. #--------------------------------------------------------------------------
  131. # ● 左下に移動
  132. #--------------------------------------------------------------------------
  133. def move_lower_left
  134. # 向き固定でない場合
  135. unless @direction_fix
  136. # 右向きだった場合は左を、上向きだった場合は下を向く
  137. @direction = 3#(@direction == Input::RIGHT ? Input::LEFT : @direction == Input::UP ? Input::DOWN : @direction)
  138. end
  139. # 下→左、左→下 のどちらかのコースが通行可能な場合
  140. if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
  141. (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
  142. # 座標を更新
  143. @x -= 1
  144. @y += 1
  145. end
  146. end
  147. #--------------------------------------------------------------------------
  148. # ● 右下に移動
  149. #--------------------------------------------------------------------------
  150. def move_lower_right
  151. # 向き固定でない場合
  152. unless @direction_fix
  153. # 左向きだった場合は右を、上向きだった場合は下を向く
  154. @direction = 9#(@direction == Input::LEFT ? Input::RIGHT : @direction == Input::UP ? Input::DOWN : @direction)
  155. end
  156. # 下→右、右→下 のどちらかのコースが通行可能な場合
  157. if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
  158. (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
  159. # 座標を更新
  160. @x += 1
  161. @y += 1
  162. end
  163. end
  164. #--------------------------------------------------------------------------
  165. # ● 左上に移動
  166. #--------------------------------------------------------------------------
  167. def move_upper_left
  168. # 向き固定でない場合
  169. unless @direction_fix
  170. # 右向きだった場合は左を、下向きだった場合は上を向く
  171. @direction = 7#(@direction == Input::RIGHT ? Input::LEFT : @direction == Input::DOWN ? Input::UP : @direction)
  172. end
  173. # 上→左、左→上 のどちらかのコースが通行可能な場合
  174. if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
  175. (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
  176. # 座標を更新
  177. @x -= 1
  178. @y -= 1
  179. end
  180. end
  181. #--------------------------------------------------------------------------
  182. # ● 右上に移動
  183. #--------------------------------------------------------------------------
  184. def move_upper_right
  185. # 向き固定でない場合
  186. unless @direction_fix
  187. # 左向きだった場合は右を、下向きだった場合は上を向く
  188. @direction = 1#(@direction == Input::LEFT ? Input::RIGHT : @direction == Input::DOWN ? Input::UP : @direction)
  189. end
  190. # 上→右、右→上 のどちらかのコースが通行可能な場合
  191. if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
  192. (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
  193. # 座標を更新
  194. @x += 1
  195. @y -= 1
  196. end
  197. end
  198. attr_writer :move_speed
  199. attr_writer :step_anime
  200. end
  201. module Spriteset_Map_Module
  202. def setup_actor_character_sprites?
  203. return @setup_actor_character_sprites_flag != nil
  204. end
  205. def setup_actor_character_sprites(characters)
  206. if !setup_actor_character_sprites?
  207. index_game_player = 0
  208. @character_sprites.each_index do |i|
  209. if @character_sprites[i].character.instance_of?(Game_Player)
  210. index_game_player = i
  211. break
  212. end
  213. end
  214. for character in characters.reverse
  215. @character_sprites.unshift(
  216. Sprite_Character.new(@viewport1, character)
  217. )
  218. end
  219. @setup_actor_character_sprites_flag = true
  220. end
  221. end
  222. end
  223. module Scene_Map_Module
  224. def setup_actor_character_sprites(characters)
  225. @spriteset.setup_actor_character_sprites(characters)
  226. end
  227. end
  228. module Game_Party_Module
  229. def set_transparent_actors(transparent)

  230. @transparent = transparent

  231. end

  232. def setup_actor_character_sprites
  233. if @characters == nil
  234.   
  235. # 叶子到此一游

  236. @characters = []

  237. for i in 1 ... TRAIN_ACTOR_SIZE_MAX

  238. @characters.push(Game_Party_Actor.new)

  239. end

  240. end

  241. for i in 1 ... TRAIN_ACTOR_SIZE_MAX

  242. # 叶子到此一游

  243. #  for i in 1 ... TRAIN_ACTOR_SIZE_MAX
  244. #    @characters[i - 1].setup(actors[i])
  245. if i % (TRAIN_ACTOR_DISTANCE+1) == 0

  246. @characters[i-1].setup(actors[i/(TRAIN_ACTOR_DISTANCE+1)])

  247. end

  248. end
  249. #=============================================
  250. if $scene.class.method_defined?('setup_actor_character_sprites')
  251. $scene.setup_actor_character_sprites(@characters)
  252. end
  253. end
  254. def update_party_actors
  255. setup_actor_character_sprites
  256. transparent = $game_player.transparent
  257. if transparent == false
  258. if TRANSPARENT_SWITCH
  259. transparent = $game_switches[TRANSPARENT_SWITCHES_INDEX]
  260. end
  261. end
  262. for character in @characters
  263. character.transparent = transparent
  264. character.move_speed = $game_player.move_speed
  265. character.step_anime = character.step_anime = true#$game_player.step_anime
  266. character.update
  267. end
  268. end
  269. def moveto_party_actors( x, y )
  270. setup_actor_character_sprites
  271. for character in @characters
  272. character.moveto( x, y )
  273. end
  274. if @move_list == nil
  275. @move_list = []
  276. end
  277. move_list_setup
  278. end
  279. def move_party_actors
  280. if @move_list == nil
  281. @move_list = []
  282. move_list_setup
  283. end
  284. @move_list.each_index do |i|
  285. if @characters[i] != nil
  286. case @move_list[i].type
  287. when Input::DOWN
  288. @characters[i].move_down(@move_list[i].args[0])
  289. when Input::LEFT
  290. @characters[i].move_left(@move_list[i].args[0])
  291. when Input::RIGHT
  292. @characters[i].move_right(@move_list[i].args[0])
  293. when Input::UP
  294. @characters[i].move_up(@move_list[i].args[0])
  295. when DOWN_LEFT
  296. @characters[i].move_lower_left
  297. when DOWN_RIGHT
  298. @characters[i].move_lower_right
  299. when UP_LEFT
  300. @characters[i].move_upper_left
  301. when UP_RIGHT
  302. @characters[i].move_upper_right
  303. when JUMP
  304. @characters[i].jump(@move_list[i].args[0],@move_list[i].args[1])
  305. end
  306. end
  307. end
  308. end
  309. class Move_List_Element
  310. def initialize(type,args)
  311. @type = type
  312. @args = args
  313. end
  314. def type() return @type end
  315. def args() return @args end
  316. end
  317. def move_list_setup
  318. for i in 0 .. TRAIN_ACTOR_SIZE_MAX
  319. @move_list[i] = nil
  320. end
  321. end
  322. def add_move_list(type,*args)
  323. @move_list.unshift(Move_List_Element.new(type,args)).pop
  324. end
  325. def move_down_party_actors(turn_enabled = true)
  326. move_party_actors
  327. add_move_list(Input::DOWN,turn_enabled)
  328. end
  329. def move_left_party_actors(turn_enabled = true)
  330. move_party_actors
  331. add_move_list(Input::LEFT,turn_enabled)
  332. end
  333. def move_right_party_actors(turn_enabled = true)
  334. move_party_actors
  335. add_move_list(Input::RIGHT,turn_enabled)
  336. end
  337. def move_up_party_actors(turn_enabled = true)
  338. move_party_actors
  339. add_move_list(Input::UP,turn_enabled)
  340. end
  341. def move_lower_left_party_actors
  342. move_party_actors
  343. add_move_list(DOWN_LEFT)
  344. end
  345. def move_lower_right_party_actors
  346. move_party_actors
  347. add_move_list(DOWN_RIGHT)
  348. end
  349. def move_upper_left_party_actors
  350. move_party_actors
  351. add_move_list(UP_LEFT)
  352. end
  353. def move_upper_right_party_actors
  354. move_party_actors
  355. add_move_list(UP_RIGHT)
  356. end
  357. def jump_party_actors(x_plus, y_plus)
  358. move_party_actors
  359. add_move_list(JUMP,x_plus, y_plus)
  360. end
  361. end
  362. module Game_Player_Module
  363. def update
  364. $game_party.update_party_actors
  365. super
  366. end
  367. def moveto( x, y )
  368. $game_party.moveto_party_actors( x, y )
  369. super( x, y )
  370. end
  371. def move_down(turn_enabled = true)
  372. if passable?(@x, @y, Input::DOWN)
  373. $game_party.move_down_party_actors(turn_enabled)
  374. end
  375. super(turn_enabled)
  376. end
  377. def move_left(turn_enabled = true)
  378. if passable?(@x, @y, Input::LEFT)
  379. $game_party.move_left_party_actors(turn_enabled)
  380. end
  381. super(turn_enabled)
  382. end
  383. def move_right(turn_enabled = true)
  384. if passable?(@x, @y, Input::RIGHT)
  385. $game_party.move_right_party_actors(turn_enabled)
  386. end
  387. super(turn_enabled)
  388. end
  389. def move_up(turn_enabled = true)
  390. if passable?(@x, @y, Input::UP)
  391. $game_party.move_up_party_actors(turn_enabled)
  392. end
  393. super(turn_enabled)
  394. end
  395. def move_lower_left
  396. # 下→左、左→下 のどちらかのコースが通行可能な場合
  397. if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::LEFT)) or
  398. (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::DOWN))
  399. $game_party.move_lower_left_party_actors
  400. end
  401. super
  402. end
  403. def move_lower_right
  404. # 下→右、右→下 のどちらかのコースが通行可能な場合
  405. if (passable?(@x, @y, Input::DOWN) and passable?(@x, @y + 1, Input::RIGHT)) or
  406. (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::DOWN))
  407. $game_party.move_lower_right_party_actors
  408. end
  409. super
  410. end
  411. def move_upper_left
  412. # 上→左、左→上 のどちらかのコースが通行可能な場合
  413. if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::LEFT)) or
  414. (passable?(@x, @y, Input::LEFT) and passable?(@x - 1, @y, Input::UP))
  415. $game_party.move_upper_left_party_actors
  416. end
  417. super
  418. end
  419. def move_upper_right
  420. # 上→右、右→上 のどちらかのコースが通行可能な場合
  421. if (passable?(@x, @y, Input::UP) and passable?(@x, @y - 1, Input::RIGHT)) or
  422. (passable?(@x, @y, Input::RIGHT) and passable?(@x + 1, @y, Input::UP))
  423. $game_party.move_upper_right_party_actors
  424. end
  425. super
  426. end
  427. def jump(x_plus, y_plus)
  428. # 新しい座標を計算
  429. new_x = @x + x_plus
  430. new_y = @y + y_plus
  431. # 加算値が (0,0) の場合か、ジャンプ先が通行可能な場合
  432. if (x_plus == 0 and y_plus == 0) or passable?(new_x, new_y, 0)
  433. $game_party.jump_party_actors(x_plus, y_plus)
  434. end
  435. super(x_plus, y_plus)
  436. end
  437. attr_reader :move_speed
  438. attr_reader :step_anime
  439. end
  440. end # module Train_Actor
  441. class Game_Party
  442. include Train_Actor::Game_Party_Module
  443. end
  444. class Game_Player
  445. include Train_Actor::Game_Player_Module
  446. end
  447. class Spriteset_Map
  448. include Train_Actor::Spriteset_Map_Module
  449. end
  450. class Scene_Map
  451. include Train_Actor::Scene_Map_Module
  452. end

  453. #==============================================================================
  454. # 本脚本来自www.66RPG.com,使用和转载请保留此信息
  455. #==============================================================================
复制代码

点评

可以把这个脚本的90行到225行全部删除(未测试)  发表于 2014-8-7 11:01
回复 支持 反对

使用道具 举报

Lv4.逐梦者

梦石
10
星屑
319
在线时间
1406 小时
注册时间
2010-12-8
帖子
2805

贵宾

5
发表于 2014-8-7 09:42:06 | 只看该作者
注意脚本的排列
回复 支持 反对

使用道具 举报

Lv1.梦旅人

薄凉看客

梦石
0
星屑
50
在线时间
1269 小时
注册时间
2010-6-20
帖子
1316
6
发表于 2014-8-7 10:11:26 | 只看该作者
换了个跟随脚本 并 修正了去鼠标遗留物

全方向行走脚本.rar

2.31 MB, 下载次数: 28

点评

貌似走起来感觉怪怪的,还有如果跟随的人物碰到不能通行的地方,就会和队长拉开一段距离。  发表于 2014-8-7 10:22
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-9-21 22:30

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表