查看: 1636|回复: 0

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

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

开拓者

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

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

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

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

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

[pre lang="ruby" line="1"]#==============================================================================
#  Parallax Horizon
#  Version 1.0
#  Author: modern algebra (rmrk.net)
#  Date: August 2, 2008
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Description:
#    This script allows you to set a speed for a parallax to scroll extra
#  when the player is moving. It will scroll in the opposite direction, to
#  give the illusion of a horizon.
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Instructions:
#    To make it so that the parallax will scroll, you must check the box in the
#  map settings for it to scroll, even if you do not want it to scroll
#  regularly. You can avoid it scrolling regularly by leaving the scroll value
#  at 0. For instructions on setting up the maps, see the CONFIGURABLE REGION
#  at line 49. You can also use this code:
#
#    $game_map.p_scroll_mod =
#
#    to set the speed manually in game. It will reset once you leave the map.
#==============================================================================
# ** Game_Map
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  Summary of Changes:
#    new public instance variable - p_scroll_mod
#    aliased method - update_parallax
#==============================================================================

class Game_Map
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variables
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_accessor :p_scroll_mod
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Update Parallax
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modalg_arclg_req_parallax_moving_response_53b6 update_parallax
  def update_parallax
    # IF player is moving and parallax stats not updated yet
    if $game_player.moving? && @old_parallax_sx == nil
      # Set variables to save the default values of parallax stats
      @old_parallax_sx = @parallax_sx
      @old_parallax_sy = @parallax_sy
      # Initialize scroll modifier
      if @p_scroll_mod == nil
        @p_scroll_mod = case map_id
        #\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
        #  CONFIGURABLE REGION
        #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        #  To configure this script, set up the lines below like this:
        #  
        #    when map_id then scroll_speed
        #
        #  So if you set:
        #    when 1 then 10
        #
        #  That means that the parallax on Map with ID 1 will scroll at
        #  speed 10 in the opposite direction when the player is moving.
        #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
        when 84 then 10
        #||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
        #  END CONFIGURABLE REGION   (height - 20) * 256 / 2
        #//////////////////////////////////////////////////////////////////
        else
          0
        end
      end
      # Modify the scrolling
      #if @display_y > (height - 20) * 256 / 3 or @display_y < (height - 20) * 256  / 6
      if @p_scroll_mod != 0
        # Adjust for dashing
        mod = $game_player.dash? ? @p_scroll_mod*2 : @p_scroll_mod
        # Adjust scroll in the direction the player is moving
        @parallax_sx -= mod if $game_player.x * 256 < $game_player.real_x if @display_x > 32 #and @display_x < @map.width * 32 + 768
        @parallax_sx += mod if $game_player.x * 256 > $game_player.real_x if @display_x > 32 #and @display_x < @map.width * 32 + 768
        @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
        @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
      end
    # Restore Parallax Scroll to default if not moving
    elsif @old_parallax_sx != nil
      @parallax_sx = @old_parallax_sx
      @parallax_sy = @old_parallax_sy
      @old_parallax_sx = nil
      @old_parallax_sy = nil
    end
    # Run Original Method
    modalg_arclg_req_parallax_moving_response_53b6
  end
end[/pre]
75到78行是我试图做的判定,但是失败了……OTL

点评

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

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

本版积分规则

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

在本版发帖返回顶部