查看: 3101|回复: 2

[已经过期] 关于地图缩放和视角固定的问题

[复制链接]
梦石
0
星屑
3794
在线时间
842 小时
注册时间
2017-12-13
回帖
248
发表于 2021-1-10 18:54:33 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 alt236679 于 2021-1-10 18:54 编辑

我现在的做法以及其原因跟→这位朋友一模一样……不过我的脚本没有报错
四楼说的没错,这样的确会变卡。但是我发现只要不让地图滚动,其实也没那么卡,而且也不怎么用得上给角色行走的那么大的地图
但是在论坛找了视角固定的脚本,报错是不报错,但是都没有效果,直接去Game_Player改第303行也没用……

watashi用到的脚本:
RGSS3 地图缩放 Ver1.02 by 星潟
[pre lang="ruby"]#==============================================================================
# ■ RGSS3 地图缩放 Ver1.02 by 星潟
#------------------------------------------------------------------------------
# 和标题一样,可以缩放地图。
# 注意,地图缩放状态会存储于存档数据文件中。
#==============================================================================
# 使用脚本:
#------------------------------------------------------------------------------
# map_zoom(150)
#
# 地图大小变为150%。
#------------------------------------------------------------------------------
# map_zoom(300)
#
# 地图大小变为300%。
#------------------------------------------------------------------------------
# map_zoom
#
# 地图大小重置。
#==============================================================================
# 缩放不能小于100%,也不能大于2000%。
# 因此、100为最小值、2000为最大值。
#==============================================================================
module ZoomFrequency
  
  #设定缩放图片更新频率。
  #设定多少帧更新一次图像。
  #数值越大,更新速度越慢。
  #1代表每帧都更新、为最大响应速度。
  
  Number = 3
  
end
class Game_System
  attr_accessor :zoom_mode
  #--------------------------------------------------------------------------
  # ズームモード
  #--------------------------------------------------------------------------
  def zoom_mode
    @zoom_mode ||= 100
  end
end
class Spriteset_Map
  #--------------------------------------------------------------------------
  # ビューポートの作成
  #--------------------------------------------------------------------------
  alias create_viewports_zoommap create_viewports
  def create_viewports
    create_viewports_zoommap
    @zoommap = ZoomMap.new(@viewport1,@viewport2)
  end
  #--------------------------------------------------------------------------
  # 更新処理
  #--------------------------------------------------------------------------
  alias update_zoommap update
  def update
    update_zoommap
    @zoommap.update
  end
  #--------------------------------------------------------------------------
  # 解放処理
  #--------------------------------------------------------------------------
  alias dispose_zoommap dispose
  def dispose
    @zoommap.dispose
    dispose_zoommap
  end
end
class ZoomMap < Sprite_Base
  #--------------------------------------------------------------------------
  # 初期化
  #--------------------------------------------------------------------------
  def initialize(v1,v2)
    super(v2)
    @viewport_data = v1
    @zoom_rate = $game_system.zoom_mode
    @frequency = ZoomFrequency::Number - 1
  end
  #--------------------------------------------------------------------------
  # 解放
  #--------------------------------------------------------------------------
  def dispose
    self.bitmap.dispose if self.bitmap && !self.bitmap.disposed?
    super
  end
  #--------------------------------------------------------------------------
  # 更新処理
  #--------------------------------------------------------------------------
  def update
    self.visible = @zoom_rate != 100
    @frequency += 1
    flag1 = @frequency >= ZoomFrequency::Number
    @frequency = 0 if flag1
    flag2 = flag1 && self.bitmap && !self.bitmap.disposed?
    if flag2
      self.bitmap.dispose
      self.bitmap = nil
    end
    if $game_system.zoom_mode != 100 or @zoom_rate != 100
      if @zoom_rate != $game_system.zoom_mode
        d = (@zoom_rate - $game_system.zoom_mode).abs.to_i
        case d
        when 0..9;i = 2
        when 10..99;i = 4
        when 100..199;i = 8
        when 200..399;i = 16
        when 400..799;i = 32
        else; i = 64
        end
        flag3 = @zoom_rate < $game_system.zoom_mode
        @zoom_rate += (@zoom_rate < $game_system.zoom_mode) ? i : -i
        @zoom_rate = $game_system.zoom_mode if (flag3 ? @zoom_rate > $game_system.zoom_mode : @zoom_rate < $game_system.zoom_mode)
      end
      zm = @zoom_rate.to_f / 100
      @viewport_data.z += 10000000
      self.bitmap = Graphics.snap_to_bitmap if flag2 or !self.bitmap
      w = self.bitmap.width
      h = self.bitmap.height
      wd1 = ((w * zm / 2) - w / 2) / zm + (($game_player.screen_x - w / 2).to_f)
      wd2 = (w * zm - w) / zm
      hd1 = ((h * zm / 2) - h / 2) / zm + (($game_player.screen_y - 16 - h / 2).to_f)
      hd2 = (h * zm - h) / zm
      wd1 = 0 if wd1 < 0
      wd1 = wd2 if wd1 > wd2
      hd1 = 0 if hd1 < 0
      hd1 = hd2 if hd1 > hd2
      self.ox = wd1
      self.oy = hd1
      self.zoom_x = zm
      self.zoom_y = zm
      self.visible = true
      @viewport_data.z -= 10000000
    end
    super
  end
end
class Game_Interpreter
  #--------------------------------------------------------------------------
  # ズーム
  #--------------------------------------------------------------------------
  def map_zoom(rate = 100)
    $game_system.zoom_mode = rate
    $game_system.zoom_mode = 100 if rate < 100
    $game_system.zoom_mode = 2000 if rate > 2000
  end
end[/pre]


スクロール禁止 ver1.0 by USK
[pre lang="ruby"]
#==============================================================================
# ★スクロール禁止 ver1.0 by USK
#------------------------------------------------------------------------------
# ・特定のスイッチがオンのときスクロールを禁止します。
#==============================================================================
=begin
・21行目のFixDisplayFlagVで設定した番号のスイッチがオンのとき
  縦スクロールが禁止されます。
・22行目のFixDisplayFlagHで設定した番号のスイッチがオンのとき
  横スクロールが禁止されます。
=end

#==============================================================================
# ■ Game_Map
#==============================================================================

class Game_Map
  #--------------------------------------------------------------------------
  # ● 設定
  #--------------------------------------------------------------------------
  FixDisplayFlag = 4
  #--------------------------------------------------------------------------
  # ●
  #--------------------------------------------------------------------------
  alias :fix_display_scroll_down  :scroll_down
  alias :fix_display_scroll_left  :scroll_left
  alias :fix_display_scroll_right :scroll_right
  alias :fix_display_scroll_up    :scroll_up
  alias :fix_display_refresh      :refresh
  alias :fix_display_valid?       :valid?
  #--------------------------------------------------------------------------
  # ●
  #--------------------------------------------------------------------------
  def fix_display?
    $game_switches[FixDisplayFlag] #|| $game_switches[FixDisplayFlag]
  end
  #--------------------------------------------------------------------------
  # ●
  #--------------------------------------------------------------------------
  def need_centering?
    ret = !fix_display? &&
          SceneManager.scene.is_a?(Scene_Map) &&
          @on_fix_display
    @on_fix_display = fix_display?
    ret
  end
  #--------------------------------------------------------------------------
  # ●
  #--------------------------------------------------------------------------
  def centering
    div = 20
    x = @display_x
    dx = $game_player.x - (Graphics.width / 32 - 1) / 2.0 - x
    dx /= div
    y = @display_y
    dy = $game_player.y - (Graphics.height / 32 - 1) / 2.0 - y
    dy /= div
    div.times do
      set_display_pos(x, y)
      x += dx
      y += dy
      scene = SceneManager.scene
      scene.update_basic
      scene.instance_variable_get(:@spriteset).update
    end
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    centering if need_centering?
    fix_display_refresh
  end
  #--------------------------------------------------------------------------
  # ● 下にスクロール
  #--------------------------------------------------------------------------
  def scroll_down(distance)
    fix_display_scroll_down(distance) unless $game_switches[FixDisplayFlag]
  end
  #--------------------------------------------------------------------------
  # ● 左にスクロール
  #--------------------------------------------------------------------------
  def scroll_left(distance)
    fix_display_scroll_left(distance) unless $game_switches[FixDisplayFlag]
  end
  #--------------------------------------------------------------------------
  # ● 右にスクロール
  #--------------------------------------------------------------------------
  def scroll_right(distance)
    fix_display_scroll_right(distance) unless $game_switches[FixDisplayFlag]
  end
  #--------------------------------------------------------------------------
  # ● 上にスクロール
  #--------------------------------------------------------------------------
  def scroll_up(distance)
    fix_display_scroll_up(distance) unless $game_switches[FixDisplayFlag]
  end
  #--------------------------------------------------------------------------
  # ● 有効座標判定
  #--------------------------------------------------------------------------
  def valid?(x, y)
    ret = fix_display_valid?(x, y)
    if $game_switches[FixDisplayFlag]
      ret &&= y >= @display_y && y < @display_y + (Graphics.height >> 5)
    end
    if $game_switches[FixDisplayFlag]
      ret &&= x >= @display_x && x < @display_x + (Graphics.width >> 5)
    end
    ret
  end
end
[/pre]

[pre lang="ruby"]
# 在这里设置 ,现在是默认,打开1号开关的时候,屏幕不滚动。
module KRST
SWI_1 = 4 #这个开关打开时,采用默认的滚屏方式
SWI_2 = 4 #这个开关打开时,不滚屏
end

#==============================================================================
# ■ 弹性滚动地图 V 1.00 BY SLICK
#------------------------------------------------------------------------------
#  处理主角的类。事件启动的判定、以及地图的滚动等功能。
# 本类的实例请参考 $game_player。
#==============================================================================

class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # ● 更新画面
  #--------------------------------------------------------------------------
  def update
    last_real_x = @real_x
    last_real_y = @real_y
    last_moving = moving?
    move_by_input
    super
    if $game_switches[KRST::SWI_1]
      update_scroll(last_real_x, last_real_y)  unless  $game_switches[KRST::SWI_2]
    else
      update_scroll2(last_real_x, last_real_y)
    end
    update_vehicle
    update_nonmoving(last_moving) unless moving?
    @followers.update
  end
  #--------------------------------------------------------------------------
  # ● 更新卷动(弹性
  #--------------------------------------------------------------------------
  def update_scroll2(last_real_x, last_real_y)
    ax1 = $game_map.adjust_x(last_real_x)
    ay1 = $game_map.adjust_y(last_real_y)
    ax2 = $game_map.adjust_x(@real_x)
    ay2 = $game_map.adjust_y(@real_y)
    basicspd = 2 ** real_move_speed / 1024.0
    slowmove = basicspd * 2
    fastmove = basicspd * 3
    if ax2 < center_x - 1
      if ax2 < center_x - 3
        $game_map.scroll_left(fastmove)
      else
        $game_map.scroll_left(slowmove)
      end
    elsif ax2 > center_x + 1
      if ax2 > center_x + 3
        $game_map.scroll_right(fastmove)
      else
        $game_map.scroll_right(slowmove)
      end
    end
    if ay2 < center_y - 1
      if ay2 < center_y - 3
        $game_map.scroll_up(fastmove)
      else
        $game_map.scroll_up(slowmove)
      end
    elsif ay2 > center_y + 1
      if ay2 > center_y + 3
        $game_map.scroll_down(fastmove)
      else
        $game_map.scroll_down(slowmove)
      end
    end
  end  
end[/pre]


另一个视角固定→弹性滚动地图 V 1.00 BY SLICK
[pre lang="ruby"]# 在这里设置 ,现在是默认,打开1号开关的时候,屏幕不滚动。
module KRST
SWI_1 = 4 #这个开关打开时,采用默认的滚屏方式
SWI_2 = 4 #这个开关打开时,不滚屏
end

#==============================================================================
# ■ 弹性滚动地图 V 1.00 BY SLICK
#------------------------------------------------------------------------------
#  处理主角的类。事件启动的判定、以及地图的滚动等功能。
# 本类的实例请参考 $game_player。
#==============================================================================

class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  # ● 更新画面
  #--------------------------------------------------------------------------
  def update
    last_real_x = @real_x
    last_real_y = @real_y
    last_moving = moving?
    move_by_input
    super
    if $game_switches[KRST::SWI_1]
      update_scroll(last_real_x, last_real_y)  unless  $game_switches[KRST::SWI_2]
    else
      update_scroll2(last_real_x, last_real_y)
    end
    update_vehicle
    update_nonmoving(last_moving) unless moving?
    @followers.update
  end
  #--------------------------------------------------------------------------
  # ● 更新卷动(弹性
  #--------------------------------------------------------------------------
  def update_scroll2(last_real_x, last_real_y)
    ax1 = $game_map.adjust_x(last_real_x)
    ay1 = $game_map.adjust_y(last_real_y)
    ax2 = $game_map.adjust_x(@real_x)
    ay2 = $game_map.adjust_y(@real_y)
    basicspd = 2 ** real_move_speed / 1024.0
    slowmove = basicspd * 2
    fastmove = basicspd * 3
    if ax2 < center_x - 1
      if ax2 < center_x - 3
        $game_map.scroll_left(fastmove)
      else
        $game_map.scroll_left(slowmove)
      end
    elsif ax2 > center_x + 1
      if ax2 > center_x + 3
        $game_map.scroll_right(fastmove)
      else
        $game_map.scroll_right(slowmove)
      end
    end
    if ay2 < center_y - 1
      if ay2 < center_y - 3
        $game_map.scroll_up(fastmove)
      else
        $game_map.scroll_up(slowmove)
      end
    elsif ay2 > center_y + 1
      if ay2 > center_y + 3
        $game_map.scroll_down(fastmove)
      else
        $game_map.scroll_down(slowmove)
      end
    end
  end  
end[/pre]


已经排查过了,不存在跟其他脚本冲突的问题
想知道有没有解决方法或者可以替换的脚本>< 如果没有甚至完全不切实际的话,大佬们就可以来骂我的这个做法蠢了(。)
不过好在我还活着。
我挺过来了。
如果没有你,我是不会走到今天的。
所以……谢谢你。衷心谢谢你。
希望未来更加光明。
这里是士官生泰勒,原属瓦里亚号,通话结束。

【连接结束】
梦石
0
星屑
3794
在线时间
842 小时
注册时间
2017-12-13
回帖
248
 楼主| 发表于 2021-1-11 21:43:07 | 显示全部楼层
没有人(残念)
还有一个小问题虽然也没必要问……我现在换了新电脑,系统显示开的125%缩放,不然看不清,结果rm编辑器和游戏测试画面就变得很糊,也不知道变得有多糊,但是就是变糊了(?)
Snipaste_2021-01-11_21-40-13.png 这样子对比起来就很明显了
其它软件也有部分是这种情况

点评

对着启动软件右键-属性-兼容性-更改高DPI设置,勾选“替代高DPI缩放行为”,点确定,再启动就不会糊了(但是看上去会小)  发表于 2021-1-12 21:10
不过好在我还活着。
我挺过来了。
如果没有你,我是不会走到今天的。
所以……谢谢你。衷心谢谢你。
希望未来更加光明。
这里是士官生泰勒,原属瓦里亚号,通话结束。

【连接结束】
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部