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

Project1

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

[RMVA发布] 调整分辨率后让地图永远居中/限制地图ViewPort

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
41 小时
注册时间
2010-7-10
帖子
111
跳转到指定楼层
1
发表于 2012-4-3 19:31:43 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

x
本帖最后由 zhangchi5 于 2012-4-4 18:07 编辑

$All_Width是限制的宽度(可设定为Graphics.width)
$All_Height是限制的高度(可设定为Graphics.height)

BUG修复:远景图可以在整个屏幕显示
运行范例工程时请把RGSS300.dll拷贝在System文件夹里。
范例工程: Project1.rar (310.47 KB, 下载次数: 11580)

修正了VA的BUG:
循环地图时如果地图分辨率小于窗口大小,只显示一个靠近主角的事件,而不在地图上显示2个(或8个)

有图有真相~
小于屏幕分辨率的地图:


横纵向循环:




Smaple:



  1. $V_Height=0
  2. $V_Width=0

  3. $All_Width=640
  4. $All_Height=480

  5. #==============================================================================
  6. # ■ Game_CharacterBase
  7. #------------------------------------------------------------------------------
  8. #  管理地图人物的基本类。是所有地图人物类的共通父类。拥有坐标、图片等基本信息。
  9. #==============================================================================

  10. class Game_CharacterBase
  11.   attr_accessor   :px                        # 地图 X 坐标偏移
  12.   attr_accessor   :py                        # 地图 Y 坐标偏移
  13.   
  14.   #--------------------------------------------------------------------------
  15.   # ● 初始化公有成员变量
  16.   #--------------------------------------------------------------------------
  17.   def init_public_members
  18.     @id = 0
  19.     @x = 0
  20.     @y = 0
  21.     @real_x = 0
  22.     @real_y = 0
  23.     @tile_id = 0
  24.     @character_name = ""
  25.     @character_index = 0
  26.     @move_speed = 4
  27.     @move_frequency = 6
  28.     @walk_anime = true
  29.     @step_anime = false
  30.     @direction_fix = false
  31.     @opacity = 255
  32.     @blend_type = 0
  33.     @direction = 2
  34.     @pattern = 1
  35.     @priority_type = 1
  36.     @through = false
  37.     @bush_depth = 0
  38.     @animation_id = 0
  39.     @balloon_id = 0
  40.     @transparent = false
  41.     @px = 0
  42.     @py = 0
  43.   end

  44.   #--------------------------------------------------------------------------
  45.   # ● 获取画面 X 坐标
  46.   #--------------------------------------------------------------------------
  47.   def screen_x
  48.     $game_map.adjust_x(@real_x) * 32 + 16 + @px
  49.   end
  50.   #--------------------------------------------------------------------------
  51.   # ● 获取画面 Y 坐标
  52.   #--------------------------------------------------------------------------
  53.   def screen_y
  54.     $game_map.adjust_y(@real_y) * 32 + 32 - shift_y - jump_height + @py
  55.   end
  56. end

  57. #==============================================================================
  58. # ■ Scene_Map
  59. #------------------------------------------------------------------------------
  60. #  地图画面
  61. #==============================================================================

  62. class Scene_Map < Scene_Base
  63.   #--------------------------------------------------------------------------
  64.   # ● 开始处理
  65.   #--------------------------------------------------------------------------
  66.   def start
  67.     super
  68.     SceneManager.clear
  69.     $game_player.straighten
  70.     $game_map.refresh
  71.     $game_message.visible = false
  72.     create_spriteset
  73.     create_all_windows
  74.     @menu_calling = false
  75.   end
  76.   #--------------------------------------------------------------------------
  77.   # ● 场所移动后的处理
  78.   #--------------------------------------------------------------------------
  79.   def post_transfer
  80.     @spriteset.refresh_viewports
  81.    
  82.     case $game_temp.fade_type
  83.     when 0
  84.       Graphics.wait(fadein_speed / 2)
  85.       fadein(fadein_speed)
  86.     when 1
  87.       Graphics.wait(fadein_speed / 2)
  88.       white_fadein(fadein_speed)
  89.     end
  90.     @map_name_window.open
  91.   end

  92. end

  93. #==============================================================================
  94. # ■ Game_Map
  95. #------------------------------------------------------------------------------
  96. #  管理地图的类。拥有卷动地图以及判断通行度的功能。
  97. #   本类的实例请参考 $game_map 。
  98. #==============================================================================

  99. class Game_Map
  100.   attr_reader   :scroll_rest
  101.   attr_reader   :Sdistancs
  102.   attr_reader   :Sdistance
  103.   #--------------------------------------------------------------------------
  104.   # ● 设置
  105.   #--------------------------------------------------------------------------
  106.   def setup(map_id)
  107.     @map_id = map_id
  108.     @map = load_data(sprintf("Data/Map%03d.rvdata2", @map_id))
  109.    
  110.     init_V
  111.    
  112.     @tileset_id = @map.tileset_id
  113.     @display_x = 0
  114.     @display_y = 0
  115.     referesh_vehicles
  116.     setup_events
  117.     setup_scroll
  118.     setup_parallax
  119.     setup_battleback
  120.     @need_refresh = false
  121.   end
  122.   #--------------------------------------------------------------------------
  123.   # ● 画面的横向图块数
  124.   #--------------------------------------------------------------------------
  125.   def screen_tile_x
  126.     $V_Width / 32
  127.   end
  128.   #--------------------------------------------------------------------------
  129.   # ● 画面的纵向图块数
  130.   #--------------------------------------------------------------------------
  131.   def screen_tile_y
  132.     $V_Height / 32
  133.   end
  134.   #--------------------------------------------------------------------------
  135.   # ● 刷新
  136.   #--------------------------------------------------------------------------
  137.   def refresh
  138.     @events.each_value {|event| event.refresh }
  139.     @common_events.each {|event| event.refresh }
  140.     refresh_tile_events
  141.     @need_refresh = false
  142.   end

  143.   
  144.   def init_V
  145.     $V_Width=width*32
  146.     $V_Height=height*32
  147.     if $V_Width>=$All_Width || loop_horizontal? then
  148.       $V_Width=$All_Width
  149.     end
  150.     if $V_Height>=$All_Height || loop_vertical? then
  151.       $V_Height=$All_Height
  152.     end
  153.   end

  154.   #--------------------------------------------------------------------------
  155.   # ● 计算显示坐标的剩余 X 坐标
  156.   #--------------------------------------------------------------------------
  157.   def adjust_x(x)
  158.     if $game_map.loop_horizontal? && x < @display_x - (width - screen_tile_x) / 2
  159.       x - @display_x + @map.width
  160.     else
  161.       x - @display_x
  162.     end
  163.   end
  164.   #--------------------------------------------------------------------------
  165.   # ● 计算显示坐标的剩余 Y 坐标
  166.   #--------------------------------------------------------------------------
  167.   def adjust_y(y)
  168.     if $game_map.loop_vertical? && y < @display_y - (height - screen_tile_y) / 2
  169.       y - @display_y + @map.height
  170.     else
  171.       y - @display_y
  172.     end
  173.   end
  174.   #--------------------------------------------------------------------------
  175.   # ● 更新卷动
  176.   #--------------------------------------------------------------------------
  177.   def update_scroll
  178.     @Sdistancs=5
  179.     @Sdistance=0
  180.     return unless scrolling?
  181.     last_x = @display_x
  182.     last_y = @display_y
  183.     do_scroll(@scroll_direction, scroll_distance)
  184.     @Sdistancs=scroll_direction
  185.     @Sdistance=scroll_distance*32
  186.     if @display_x == last_x && @display_y == last_y
  187.       @scroll_rest = 0
  188.     else
  189.       @scroll_rest -= scroll_distance
  190.     end
  191.   end
  192. #~   #--------------------------------------------------------------------------
  193. #~   # ● 计算远景图显示的原点 X 坐标
  194. #~   #--------------------------------------------------------------------------
  195. #~   def parallax_ox(bitmap)
  196. #~     if @parallax_loop_x
  197. #~       return @parallax_x * 16 + @Sdistance if @Sdistancs==6
  198. #~       return @parallax_x * 16 - @Sdistance if @Sdistancs==4
  199. #~       return @parallax_x * 16
  200. #~     else
  201. #~       w1 = [bitmap.width - Graphics.width, 0].max
  202. #~       w2 = [width * 32 - Graphics.width, 1].max
  203. #~       return @parallax_x * 16 * w1 / w2 + @Sdistance if @Sdistancs==6
  204. #~       return @parallax_x * 16 * w1 / w2 - @Sdistance if @Sdistancs==4
  205. #~       return @parallax_x * 16 * w1 / w2
  206. #~     end
  207. #~   end
  208. #~   #--------------------------------------------------------------------------
  209. #~   # ● 计算远景图显示的原点 Y 坐标
  210. #~   #--------------------------------------------------------------------------
  211. #~   def parallax_oy(bitmap)
  212. #~     if @parallax_loop_y
  213. #~       puts @Sdistancs
  214. #~       return @parallax_y * 16 + @Sdistance if @Sdistancs==2
  215. #~       return @parallax_y * 16 - @Sdistance if @Sdistancs==8
  216. #~       return @parallax_y * 16
  217. #~     else
  218. #~       h1 = [bitmap.height - Graphics.height, 0].max
  219. #~       h2 = [height * 32 - Graphics.height, 1].max
  220. #~       return @parallax_y * 16 * h1 / h2 + @Sdistance if @Sdistancs==2
  221. #~       return @parallax_y * 16 * h1 / h2 - @Sdistance if @Sdistancs==8
  222. #~       return @parallax_y * 16 * h1 / h2
  223. #~     end
  224. #~   end
  225.   
  226. end

  227. #==============================================================================
  228. # ■ Spriteset_Map
  229. #------------------------------------------------------------------------------
  230. #  处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。
  231. #==============================================================================

  232. class Spriteset_Map
  233.   #--------------------------------------------------------------------------
  234.   # ● 生成显示端口
  235.   #--------------------------------------------------------------------------
  236.   def create_viewports
  237.     x=(Graphics.width-$V_Width)/2
  238.     y=(Graphics.height-$V_Height)/2
  239.     @planeViewPort = Viewport.new(0,0,Graphics.width,Graphics.height)
  240.     @viewport1 = Viewport.new(x,y,$V_Width,$V_Height)
  241.     @viewport2 = Viewport.new(x,y,$V_Width,$V_Height)
  242.     @viewport3 = Viewport.new(x,y,$V_Width,$V_Height)
  243.     @viewport2.z = 50
  244.     @viewport3.z = 100
  245.    
  246.   end
  247.   
  248.   def refresh_viewports
  249.     x=(Graphics.width-$V_Width)/2
  250.     y=(Graphics.height-$V_Height)/2
  251.     @V_rect=Rect.new(x,y,$V_Width,$V_Height)
  252.     @viewport1.rect=@V_rect
  253.     @viewport2.rect=@V_rect
  254.     @viewport3.rect=@V_rect
  255.     @viewport2.z = 50
  256.     @viewport3.z = 100
  257.   end
  258.   
  259.   #--------------------------------------------------------------------------
  260.   # ● 生成人物精灵
  261.   #--------------------------------------------------------------------------
  262.   def create_characters
  263.     @character_sprites = []
  264.    
  265.     $game_map.events.values.each do |event|
  266.       if $game_map.width*32<$All_Width then
  267.         if $game_map.loop_horizontal? then
  268.           @sc=Sprite_Character.new(@viewport1, event.clone)
  269.           @sc.character.px=-$game_map.width*32
  270.           @character_sprites.push(@sc)
  271.          
  272.           @sc=Sprite_Character.new(@viewport1, event.clone)
  273.           @sc.character.px=$game_map.width*32
  274.           @character_sprites.push(@sc)
  275.         end
  276.       end
  277.       
  278.       if $game_map.height*32<$All_Height then
  279.         if $game_map.loop_vertical? then
  280.           @sc=Sprite_Character.new(@viewport1, event.clone)
  281.           @sc.character.py=-$game_map.height*32
  282.           @character_sprites.push(@sc)
  283.          
  284.           @sc=Sprite_Character.new(@viewport1, event.clone)
  285.           @sc.character.py=$game_map.height*32
  286.           @character_sprites.push(@sc)
  287.         end
  288.       end
  289.       
  290.       if $game_map.height*32<$All_Height || $game_map.width*32<$All_Width then
  291.         if $game_map.loop_horizontal? && $game_map.loop_vertical? then
  292.           @sc=Sprite_Character.new(@viewport1, event.clone)
  293.           @sc.character.px=-$game_map.width*32
  294.           @sc.character.py=-$game_map.height*32
  295.           @character_sprites.push(@sc)
  296.          
  297.           @sc=Sprite_Character.new(@viewport1, event.clone)
  298.           @sc.character.px=$game_map.width*32
  299.           @sc.character.py=-$game_map.height*32
  300.           @character_sprites.push(@sc)   
  301.          
  302.           @sc=Sprite_Character.new(@viewport1, event.clone)
  303.           @sc.character.px=-$game_map.width*32
  304.           @sc.character.py=$game_map.height*32
  305.           @character_sprites.push(@sc)
  306.          
  307.           @sc=Sprite_Character.new(@viewport1, event.clone)
  308.           @sc.character.px=$game_map.width*32
  309.           @sc.character.py=$game_map.height*32
  310.           @character_sprites.push(@sc)
  311.         end
  312.       end
  313.       @character_sprites.push(Sprite_Character.new(@viewport1, event))
  314.       
  315.     end
  316.     $game_map.vehicles.each do |vehicle|
  317.       @character_sprites.push(Sprite_Character.new(@viewport1, vehicle))
  318.     end
  319.     $game_player.followers.reverse_each do |follower|
  320.       @character_sprites.push(Sprite_Character.new(@viewport1, follower))
  321.     end
  322.     @character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
  323.     @map_id = $game_map.map_id
  324.   end
  325.   #--------------------------------------------------------------------------
  326.   # ● 生成远景图
  327.   #--------------------------------------------------------------------------
  328.   def create_parallax
  329.     @parallax = Plane.new(@planeViewPort)
  330.     @parallax.z = -100
  331.   end
  332.   #--------------------------------------------------------------------------
  333.   # ● 释放远景图
  334.   #--------------------------------------------------------------------------
  335.   def dispose_parallax
  336.     @parallax.bitmap.dispose if @parallax.bitmap
  337.     @parallax.dispose
  338.   end
  339.   #--------------------------------------------------------------------------
  340.   # ● 更新远景图
  341.   #--------------------------------------------------------------------------
  342.   def update_parallax
  343.     if @parallax_name != $game_map.parallax_name
  344.       @parallax_name = $game_map.parallax_name
  345.       @parallax.bitmap.dispose if @parallax.bitmap
  346.       @parallax.bitmap = Cache.parallax(@parallax_name)
  347.       Graphics.frame_reset
  348.     end
  349.     @parallax.ox = $game_map.parallax_ox(@parallax.bitmap)
  350.     @parallax.oy = $game_map.parallax_oy(@parallax.bitmap)
  351.   end
  352.   
  353. end

  354. #==============================================================================
  355. # ■ Game_Player
  356. #------------------------------------------------------------------------------
  357. #  处理玩家人物的类。拥有事件启动的判定、地图的卷动等功能。
  358. #   本类的实例请参考 $game_player 。
  359. #==============================================================================

  360. class Game_Player < Game_Character
  361.   #--------------------------------------------------------------------------
  362.   # ● 执行场所移动
  363.   #--------------------------------------------------------------------------
  364.   def perform_transfer
  365.     if transfer?
  366.       set_direction(@new_direction)
  367.       if @new_map_id != $game_map.map_id
  368.         $game_map.setup(@new_map_id)
  369.         $game_map.autoplay
  370.       end
  371.       moveto(@new_x, @new_y)
  372.       clear_transfer_info
  373.     end
  374.   end
  375.   #--------------------------------------------------------------------------
  376.   # ● 画面中央的 X 坐标
  377.   #--------------------------------------------------------------------------
  378.   def center_x
  379.     ($V_Width / 32 - 1) / 2.0
  380.   end
  381.   #--------------------------------------------------------------------------
  382.   # ● 画面中央的 Y 坐标
  383.   #--------------------------------------------------------------------------
  384.   def center_y
  385.     ($V_Height / 32 - 1) / 2.0
  386.   end
  387. end
复制代码

评分

参与人数 1星屑 +600 收起 理由
Kimu + 600 发布奖励

查看全部评分

Lv1.梦旅人

梦石
0
星屑
50
在线时间
1281 小时
注册时间
2006-8-27
帖子
590
2
发表于 2012-4-3 19:38:26 | 只看该作者
我写过
http://rpg.blue/forum.php?mod=re ... 674&pid=1817414
不知是否和我一样
当地图小于分辨率后 让地图居中

点评

孩子,ComeIn  发表于 2012-4-3 19:42
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
41 小时
注册时间
2010-7-10
帖子
111
3
 楼主| 发表于 2012-4-3 19:41:58 | 只看该作者
wbsy8241 发表于 2012-4-3 19:38
我写过
http://rpg.blue/forum.php?mod=redirect&goto=findpost&ptid=216674&pid=1817414
不知是否和 ...

我有一个功能,是事件可以重复显示。。。
你来八卦一下吧~~
刚才没发完
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
1281 小时
注册时间
2006-8-27
帖子
590
4
发表于 2012-4-3 19:47:36 | 只看该作者
本帖最后由 wbsy8241 于 2012-4-3 19:56 编辑
zhangchi5 发表于 2012-4-3 19:41
我有一个功能,是事件可以重复显示。。。
你来八卦一下吧~~
刚才没发完 ...


附件下不动...

是可以重复显示但
还有事件会顺移

具体BUG是 场所移动结果还是本地图

还有1个问题 你的远景也被限制在 视窗里了  外面也是黑的

点评

远景的问题会修复的。另外好像还有1个BUG。当屏幕上不止有一个地图时,循环时只会显示8个事件。  发表于 2012-4-4 17:20
RMVA的模式是当人物越过地图后把事件移到另外一个位置,所以可以用。其他的Sprite“只能看,  发表于 2012-4-4 17:18
不能用”  发表于 2012-4-4 17:17
回复 支持 反对

使用道具 举报

Lv2.观梦者


  • 更新完成啦

梦石
0
星屑
769
在线时间
6267 小时
注册时间
2006-6-7
帖子
8462
5
发表于 2012-4-4 16:12:11 | 只看该作者
mark一下,我感觉这样会有很多冲突

点评

孩子。。。我真的。。。对ALIAS无语。这已经和我以前干的脚本冲突了。。。  发表于 2012-4-4 17:27
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
55
在线时间
10 小时
注册时间
2009-4-22
帖子
22
6
发表于 2012-4-11 12:29:42 | 只看该作者
用了 就一定要支持
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-5-5 08:47

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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