查看: 4095|回复: 9

[已经解决] 请问如何固定人物所在的画面视角?

[复制链接]
梦石
0
星屑
1290
在线时间
52 小时
注册时间
2017-2-2
回帖
25
发表于 2018-8-24 20:02:41 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 吉吉阿茶 于 2018-8-24 20:04 编辑

QQ截图20180824195559.png
QQ截图20180824195550.png
如图,游戏里的画面放大了200%,那个上层元件框起来的位置就代表着游戏画面实际上显示的范围,
但是地图大小实际上是有限制的,并不能做出这么小的地图,按照镜头默认玩家在最中间的话玩家走在小房间的边缘感觉就不是很好看了
所以想问一下,有没有什么脚本能固定视角移动的呢?譬如说xx号开关打开,视角不跟随主角移动什么的

另外视角上这里还有用一个弹性滚动地图的脚本
  1. #==============================================================================
  2. # ■ 弹性滚动地图 V 1.00 BY SLICK
  3. #------------------------------------------------------------------------------
  4. #  处理主角的类。事件启动的判定、以及地图的滚动等功能。
  5. # 本类的实例请参考 $game_player。
  6. # 我:。。。这个黄金版已经被改的面目全非了
  7. #==============================================================================
  8. class Game_Player < Game_Character

  9.   MOVESPEA = 0.70
  10.   OFF_SW = 1  # 打开这个开关就停用弹性滚动
  11.   
  12.   alias sny46_160817_update_scroll update_scroll
  13.   def update_scroll(last_real_x, last_real_y)
  14.     if $game_switches[OFF_SW]
  15.       return sny46_160817_update_scroll(last_real_x, last_real_y)
  16.     end
  17.     ax1 = $game_map.adjust_x(last_real_x)
  18.     ay1 = $game_map.adjust_y(last_real_y)
  19.     ax2 = $game_map.adjust_x(@real_x)
  20.     ay2 = $game_map.adjust_y(@real_y)
  21.     movespeb = (2 ** (@move_speed+1))*MOVESPEA
  22.     movesped = movespeb / Graphics.width
  23.     movespec = movespeb / Graphics.height
  24.     tmp=center_x-ax2
  25.     $game_map.scroll_left(movesped*tmp) if tmp>0
  26.     $game_map.scroll_right(-movesped*tmp) if tmp<0
  27.     tmp=center_y-ay2
  28.     $game_map.scroll_up(movespec*tmp) if tmp>0
  29.     $game_map.scroll_down(-movespec*tmp) if tmp<0   
  30.   end  
  31. end
复制代码
梦石
0
星屑
5037
在线时间
1780 小时
注册时间
2012-7-3
回帖
1749

开拓者

发表于 2018-8-24 20:40:00 | 显示全部楼层
最简单的,你把边缘留大点涂黑不就行了……
就像仙剑1的处理方式,为了节约空间把十几个室内场景拼在一起,中间用足够的黑色隔开
其实仙五前也这么处理的,把七八个3D屋子坐在一起,算是加快加载速度的小trick吧

点评

不一定要涂黑,留出足够的边界给默认的滚动算法其实就解决了  发表于 2018-8-24 20:53
打算做小房间的效果,边缘涂黑的话走在地图边缘时露出黑色的部分感觉效果不是很好看  发表于 2018-8-24 20:41
Project Ktr进行中:
   
------------------
→SRPG开发之六-天气与地形互动
→→围观
→→→去Lofter围观
------------------
离经叛道的扯淡者/伪独立游戏爱好者/Decade Studio(?)/造轮子真TM开心呀
回复

使用道具 举报

梦石
0
星屑
3372
在线时间
1123 小时
注册时间
2015-12-24
回帖
236
发表于 2018-8-24 20:57:11 | 显示全部楼层
试试看这个脚本?
指定开关开启时X轴/Y轴不跟着卷动

点击展开/收起

  1. #==============================================================================
  2. # ★スクロール禁止 ver1.0 by USK
  3. #------------------------------------------------------------------------------
  4. # ・特定のスイッチがオンのときスクロールを禁止します。
  5. #==============================================================================
  6. =begin
  7. ・21行目のFixDisplayFlagVで設定した番号のスイッチがオンのとき
  8.   縦スクロールが禁止されます。
  9. ・22行目のFixDisplayFlagHで設定した番号のスイッチがオンのとき
  10.   横スクロールが禁止されます。
  11. =end

  12. #==============================================================================
  13. # ■ Game_Map
  14. #==============================================================================

  15. class Game_Map
  16.   #--------------------------------------------------------------------------
  17.   # ● 設定
  18.   #--------------------------------------------------------------------------
  19.   FixDisplayFlagV = 3 #禁止Y轴卷动的开关编号
  20.   FixDisplayFlagH = 4 #禁止X轴卷动的开关编号
  21.   #--------------------------------------------------------------------------
  22.   # ●
  23.   #--------------------------------------------------------------------------
  24.   alias :fix_display_scroll_down  :scroll_down
  25.   alias :fix_display_scroll_left  :scroll_left
  26.   alias :fix_display_scroll_right :scroll_right
  27.   alias :fix_display_scroll_up    :scroll_up
  28.   alias :fix_display_refresh      :refresh
  29.   alias :fix_display_valid?       :valid?
  30.   #--------------------------------------------------------------------------
  31.   # ●
  32.   #--------------------------------------------------------------------------
  33.   def fix_display?
  34.     $game_switches[FixDisplayFlagV] || $game_switches[FixDisplayFlagH]
  35.   end
  36.   #--------------------------------------------------------------------------
  37.   # ●
  38.   #--------------------------------------------------------------------------
  39.   def need_centering?
  40.     ret = !fix_display? &&
  41.           SceneManager.scene.is_a?(Scene_Map) &&
  42.           @on_fix_display
  43.     @on_fix_display = fix_display?
  44.     ret
  45.   end
  46.   #--------------------------------------------------------------------------
  47.   # ●
  48.   #--------------------------------------------------------------------------
  49.   def centering
  50.     div = 20
  51.     x = @display_x
  52.     dx = $game_player.x - (Graphics.width / 32 - 1) / 2.0 - x
  53.     dx /= div
  54.     y = @display_y
  55.     dy = $game_player.y - (Graphics.height / 32 - 1) / 2.0 - y
  56.     dy /= div
  57.     div.times do
  58.       set_display_pos(x, y)
  59.       x += dx
  60.       y += dy
  61.       scene = SceneManager.scene
  62.       scene.update_basic
  63.       scene.instance_variable_get(:@spriteset).update
  64.     end
  65.   end
  66.   #--------------------------------------------------------------------------
  67.   # ● リフレッシュ
  68.   #--------------------------------------------------------------------------
  69.   def refresh
  70.     centering if need_centering?
  71.     fix_display_refresh
  72.   end
  73.   #--------------------------------------------------------------------------
  74.   # ● 下にスクロール
  75.   #--------------------------------------------------------------------------
  76.   def scroll_down(distance)
  77.     fix_display_scroll_down(distance) unless $game_switches[FixDisplayFlagV]
  78.   end
  79.   #--------------------------------------------------------------------------
  80.   # ● 左にスクロール
  81.   #--------------------------------------------------------------------------
  82.   def scroll_left(distance)
  83.     fix_display_scroll_left(distance) unless $game_switches[FixDisplayFlagH]
  84.   end
  85.   #--------------------------------------------------------------------------
  86.   # ● 右にスクロール
  87.   #--------------------------------------------------------------------------
  88.   def scroll_right(distance)
  89.     fix_display_scroll_right(distance) unless $game_switches[FixDisplayFlagH]
  90.   end
  91.   #--------------------------------------------------------------------------
  92.   # ● 上にスクロール
  93.   #--------------------------------------------------------------------------
  94.   def scroll_up(distance)
  95.     fix_display_scroll_up(distance) unless $game_switches[FixDisplayFlagV]
  96.   end
  97.   #--------------------------------------------------------------------------
  98.   # ● 有効座標判定
  99.   #--------------------------------------------------------------------------
  100.   def valid?(x, y)
  101.     ret = fix_display_valid?(x, y)
  102.     if $game_switches[FixDisplayFlagV]
  103.       ret &&= y >= @display_y && y < @display_y + (Graphics.height >> 5)
  104.     end
  105.     if $game_switches[FixDisplayFlagH]
  106.       ret &&= x >= @display_x && x < @display_x + (Graphics.width >> 5)
  107.     end
  108.     ret
  109.   end
  110. end
复制代码

点评

我刚才用首楼的脚本并用测试可以正常运作,如果是和其他脚本冲突的话先试着找和哪个脚本冲突吧  发表于 2018-8-24 21:16
不知道是不是和什么脚本冲突了,用了并没有用555  发表于 2018-8-24 21:10
回复

使用道具 举报

花匠

梦石
64
星屑
16654
在线时间
4220 小时
注册时间
2016-6-17
回帖
1012

极短26获奖极短24参与开拓者

发表于 2018-8-25 20:24:15 | 显示全部楼层
回复

使用道具 举报

梦石
0
星屑
3557
在线时间
2337 小时
注册时间
2015-8-25
回帖
928

开拓者

发表于 2018-8-25 21:14:28 | 显示全部楼层
本帖最后由 七重 于 2018-8-25 21:18 编辑

你这弹性移动是在哪里拿的。。
和原来的那个还差蛮大的。

我改写了一下。
楼主把下面这个弹性移动脚本换了你自己原来的那个吧。


改过的弹性移动脚本

  1. # 在这里设置 ,现在是默认,打开1号开关的时候,屏幕不滚动。
  2. module KRST
  3. SWI_1 = 1 #这个开关打开时,采用默认的滚屏方式
  4. SWI_2 = 1 #这个开关打开时,不滚屏
  5. end

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

  12. class Game_Player < Game_Character
  13.   #--------------------------------------------------------------------------
  14.   # ● 更新画面
  15.   #--------------------------------------------------------------------------
  16.   def update
  17.     last_real_x = @real_x
  18.     last_real_y = @real_y
  19.     last_moving = moving?
  20.     move_by_input
  21.     super
  22.     if $game_switches[KRST::SWI_1]
  23.       update_scroll(last_real_x, last_real_y)  unless  $game_switches[KRST::SWI_2]
  24.     else
  25.       update_scroll2(last_real_x, last_real_y)
  26.     end
  27.     update_vehicle
  28.     update_nonmoving(last_moving) unless moving?
  29.     @followers.update
  30.   end
  31.   #--------------------------------------------------------------------------
  32.   # ● 更新卷动(弹性
  33.   #--------------------------------------------------------------------------
  34.   def update_scroll2(last_real_x, last_real_y)
  35.     ax1 = $game_map.adjust_x(last_real_x)
  36.     ay1 = $game_map.adjust_y(last_real_y)
  37.     ax2 = $game_map.adjust_x(@real_x)
  38.     ay2 = $game_map.adjust_y(@real_y)
  39.     basicspd = 2 ** real_move_speed / 1024.0
  40.     slowmove = basicspd * 2
  41.     fastmove = basicspd * 3
  42.     if ax2 < center_x - 1
  43.       if ax2 < center_x - 3
  44.         $game_map.scroll_left(fastmove)
  45.       else
  46.         $game_map.scroll_left(slowmove)
  47.       end
  48.     elsif ax2 > center_x + 1
  49.       if ax2 > center_x + 3
  50.         $game_map.scroll_right(fastmove)
  51.       else
  52.         $game_map.scroll_right(slowmove)
  53.       end
  54.     end
  55.     if ay2 < center_y - 1
  56.       if ay2 < center_y - 3
  57.         $game_map.scroll_up(fastmove)
  58.       else
  59.         $game_map.scroll_up(slowmove)
  60.       end
  61.     elsif ay2 > center_y + 1
  62.       if ay2 > center_y + 3
  63.         $game_map.scroll_down(fastmove)
  64.       else
  65.         $game_map.scroll_down(slowmove)
  66.       end
  67.     end
  68.   end  
  69. end

复制代码


惹!论坛居然还会吞掉代码,又要窝打一次。

点评

那个弹性移动我也想不起来是从哪里拿来的了,在废弃工程里躺了很久了,试了一下脚本,真的非常感谢!完美解决掉了!  发表于 2018-8-26 00:36

评分

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

查看全部评分

回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部