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

Project1

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

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

[复制链接]

Lv2.观梦者

梦石
0
星屑
653
在线时间
2658 小时
注册时间
2010-6-28
帖子
1361

开拓者

跳转到指定楼层
1
发表于 2013-5-9 07:43:16 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

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

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

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

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

点评

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

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

本版积分规则

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

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

GMT+8, 2024-12-23 01:06

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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