查看: 1669|回复: 0

[已经解决] 请问在脚本里怎么判断地图是否滚动?

[复制链接]
梦石
0
星屑
618
在线时间
2656 小时
注册时间
2010-6-28
回帖
1227

开拓者

发表于 2013-5-9 07:43:16 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 我的米呀 于 2013-5-11 16:08 编辑

RT,需要说明的是,这里的滚动并不是事件中人为的滚动,而是随着主角行走时,画面会发生滚动,但是到接近边缘的时候画面就不会发生滚动。之前我先试着自己算了下display_x还有display_y,但是试出来的值只在一张地图上有用,换了个地图就不管用了。附上脚本吧,这个脚本是用来在角色发生移动的时候,远景向反方向移动,但我希望它在地图不发生滚动的时候能不移动……于是,拜托各位帮个忙,先谢过各位高手啦~

  1. #==============================================================================
  2. #  Parallax Horizon
  3. #  Version 1.0
  4. #  Author: modern algebra (rmrk.net)
  5. #  Date: August 2, 2008
  6. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  7. #  Description:
  8. #    This script allows you to set a speed for a parallax to scroll extra
  9. #  when the player is moving. It will scroll in the opposite direction, to
  10. #  give the illusion of a horizon.
  11. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  12. #  Instructions:
  13. #    To make it so that the parallax will scroll, you must check the box in the
  14. #  map settings for it to scroll, even if you do not want it to scroll
  15. #  regularly. You can avoid it scrolling regularly by leaving the scroll value
  16. #  at 0. For instructions on setting up the maps, see the CONFIGURABLE REGION
  17. #  at line 49. You can also use this code:
  18. #
  19. #    $game_map.p_scroll_mod =
  20. #
  21. #    to set the speed manually in game. It will reset once you leave the map.
  22. #==============================================================================
  23. # ** Game_Map
  24. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  25. #  Summary of Changes:
  26. #    new public instance variable - p_scroll_mod
  27. #    aliased method - update_parallax
  28. #==============================================================================

  29. class Game_Map
  30.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  31.   # * Public Instance Variables
  32.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  33.   attr_accessor :p_scroll_mod
  34.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  35.   # * Update Parallax
  36.   #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  37.   alias modalg_arclg_req_parallax_moving_response_53b6 update_parallax
  38.   def update_parallax
  39.     # IF player is moving and parallax stats not updated yet
  40.     if $game_player.moving? && @old_parallax_sx == nil
  41.       # Set variables to save the default values of parallax stats
  42.       @old_parallax_sx = @parallax_sx
  43.       @old_parallax_sy = @parallax_sy
  44.       # Initialize scroll modifier
  45.       if @p_scroll_mod == nil
  46.         @p_scroll_mod = case map_id
  47.         #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  48.         #  CONFIGURABLE REGION
  49.         #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  50.         #  To configure this script, set up the lines below like this:
  51.         #  
  52.         #    when map_id then scroll_speed
  53.         #
  54.         #  So if you set:
  55.         #    when 1 then 10
  56.         #
  57.         #  That means that the parallax on Map with ID 1 will scroll at
  58.         #  speed 10 in the opposite direction when the player is moving.
  59.         #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  60.         when 84 then 10
  61.         #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  62.         #  END CONFIGURABLE REGION   (height - 20) * 256 / 2
  63.         #//////////////////////////////////////////////////////////////////
  64.         else
  65.           0
  66.         end
  67.       end
  68.       # Modify the scrolling
  69.       #if @display_y > (height - 20) * 256 / 3 or @display_y < (height - 20) * 256  / 6
  70.       if @p_scroll_mod != 0
  71.         # Adjust for dashing
  72.         mod = $game_player.dash? ? @p_scroll_mod*2 : @p_scroll_mod
  73.         # Adjust scroll in the direction the player is moving
  74.         @parallax_sx -= mod if $game_player.x * 256 < $game_player.real_x if @display_x > 32 #and @display_x < @map.width * 32 + 768
  75.         @parallax_sx += mod if $game_player.x * 256 > $game_player.real_x if @display_x > 32 #and @display_x < @map.width * 32 + 768
  76.         @parallax_sy -= mod if $game_player.y * 256 < $game_player.real_y if @display_y > @map.height * 32 / 20 and @display_y < @map.height * 32 * 1.9#1216
  77.         @parallax_sy += mod if $game_player.y * 256 > $game_player.real_y if @display_y > @map.height * 32 / 20 and @display_y < @map.height * 32 * 1.9#1216
  78.       end
  79.     # Restore Parallax Scroll to default if not moving
  80.     elsif @old_parallax_sx != nil
  81.       @parallax_sx = @old_parallax_sx
  82.       @parallax_sy = @old_parallax_sy
  83.       @old_parallax_sx = nil
  84.       @old_parallax_sy = nil
  85.     end
  86.     # Run Original Method
  87.     modalg_arclg_req_parallax_moving_response_53b6
  88.   end
  89. end
复制代码

75到78行是我试图做的判定,但是失败了……OTL

点评

@protosssonny这个我是用在当远景有移动时的,会看到略有区别。  发表于 2013-5-9 18:25
怎么使用了你的脚本和不使用没有任何区别?  发表于 2013-5-9 09:49

                 无从有中来,有从无中生。
您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部