赞 | 0 |
VIP | 0 |
好人卡 | 3 |
积分 | 1 |
经验 | 4293 |
最后登录 | 2014-8-3 |
在线时间 | 41 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 41 小时
- 注册时间
- 2010-7-10
- 帖子
- 111
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
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:
- $V_Height=0
- $V_Width=0
- $All_Width=640
- $All_Height=480
- #==============================================================================
- # ■ Game_CharacterBase
- #------------------------------------------------------------------------------
- # 管理地图人物的基本类。是所有地图人物类的共通父类。拥有坐标、图片等基本信息。
- #==============================================================================
- class Game_CharacterBase
- attr_accessor :px # 地图 X 坐标偏移
- attr_accessor :py # 地图 Y 坐标偏移
-
- #--------------------------------------------------------------------------
- # ● 初始化公有成员变量
- #--------------------------------------------------------------------------
- def init_public_members
- @id = 0
- @x = 0
- @y = 0
- @real_x = 0
- @real_y = 0
- @tile_id = 0
- @character_name = ""
- @character_index = 0
- @move_speed = 4
- @move_frequency = 6
- @walk_anime = true
- @step_anime = false
- @direction_fix = false
- @opacity = 255
- @blend_type = 0
- @direction = 2
- @pattern = 1
- @priority_type = 1
- @through = false
- @bush_depth = 0
- @animation_id = 0
- @balloon_id = 0
- @transparent = false
- @px = 0
- @py = 0
- end
- #--------------------------------------------------------------------------
- # ● 获取画面 X 坐标
- #--------------------------------------------------------------------------
- def screen_x
- $game_map.adjust_x(@real_x) * 32 + 16 + @px
- end
- #--------------------------------------------------------------------------
- # ● 获取画面 Y 坐标
- #--------------------------------------------------------------------------
- def screen_y
- $game_map.adjust_y(@real_y) * 32 + 32 - shift_y - jump_height + @py
- end
- end
- #==============================================================================
- # ■ Scene_Map
- #------------------------------------------------------------------------------
- # 地图画面
- #==============================================================================
- class Scene_Map < Scene_Base
- #--------------------------------------------------------------------------
- # ● 开始处理
- #--------------------------------------------------------------------------
- def start
- super
- SceneManager.clear
- $game_player.straighten
- $game_map.refresh
- $game_message.visible = false
- create_spriteset
- create_all_windows
- @menu_calling = false
- end
- #--------------------------------------------------------------------------
- # ● 场所移动后的处理
- #--------------------------------------------------------------------------
- def post_transfer
- @spriteset.refresh_viewports
-
- case $game_temp.fade_type
- when 0
- Graphics.wait(fadein_speed / 2)
- fadein(fadein_speed)
- when 1
- Graphics.wait(fadein_speed / 2)
- white_fadein(fadein_speed)
- end
- @map_name_window.open
- end
- end
- #==============================================================================
- # ■ Game_Map
- #------------------------------------------------------------------------------
- # 管理地图的类。拥有卷动地图以及判断通行度的功能。
- # 本类的实例请参考 $game_map 。
- #==============================================================================
- class Game_Map
- attr_reader :scroll_rest
- attr_reader :Sdistancs
- attr_reader :Sdistance
- #--------------------------------------------------------------------------
- # ● 设置
- #--------------------------------------------------------------------------
- def setup(map_id)
- @map_id = map_id
- @map = load_data(sprintf("Data/Map%03d.rvdata2", @map_id))
-
- init_V
-
- @tileset_id = @map.tileset_id
- @display_x = 0
- @display_y = 0
- referesh_vehicles
- setup_events
- setup_scroll
- setup_parallax
- setup_battleback
- @need_refresh = false
- end
- #--------------------------------------------------------------------------
- # ● 画面的横向图块数
- #--------------------------------------------------------------------------
- def screen_tile_x
- $V_Width / 32
- end
- #--------------------------------------------------------------------------
- # ● 画面的纵向图块数
- #--------------------------------------------------------------------------
- def screen_tile_y
- $V_Height / 32
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- @events.each_value {|event| event.refresh }
- @common_events.each {|event| event.refresh }
- refresh_tile_events
- @need_refresh = false
- end
-
- def init_V
- $V_Width=width*32
- $V_Height=height*32
- if $V_Width>=$All_Width || loop_horizontal? then
- $V_Width=$All_Width
- end
- if $V_Height>=$All_Height || loop_vertical? then
- $V_Height=$All_Height
- end
- end
- #--------------------------------------------------------------------------
- # ● 计算显示坐标的剩余 X 坐标
- #--------------------------------------------------------------------------
- def adjust_x(x)
- if $game_map.loop_horizontal? && x < @display_x - (width - screen_tile_x) / 2
- x - @display_x + @map.width
- else
- x - @display_x
- end
- end
- #--------------------------------------------------------------------------
- # ● 计算显示坐标的剩余 Y 坐标
- #--------------------------------------------------------------------------
- def adjust_y(y)
- if $game_map.loop_vertical? && y < @display_y - (height - screen_tile_y) / 2
- y - @display_y + @map.height
- else
- y - @display_y
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新卷动
- #--------------------------------------------------------------------------
- def update_scroll
- @Sdistancs=5
- @Sdistance=0
- return unless scrolling?
- last_x = @display_x
- last_y = @display_y
- do_scroll(@scroll_direction, scroll_distance)
- @Sdistancs=scroll_direction
- @Sdistance=scroll_distance*32
- if @display_x == last_x && @display_y == last_y
- @scroll_rest = 0
- else
- @scroll_rest -= scroll_distance
- end
- end
- #~ #--------------------------------------------------------------------------
- #~ # ● 计算远景图显示的原点 X 坐标
- #~ #--------------------------------------------------------------------------
- #~ def parallax_ox(bitmap)
- #~ if @parallax_loop_x
- #~ return @parallax_x * 16 + @Sdistance if @Sdistancs==6
- #~ return @parallax_x * 16 - @Sdistance if @Sdistancs==4
- #~ return @parallax_x * 16
- #~ else
- #~ w1 = [bitmap.width - Graphics.width, 0].max
- #~ w2 = [width * 32 - Graphics.width, 1].max
- #~ return @parallax_x * 16 * w1 / w2 + @Sdistance if @Sdistancs==6
- #~ return @parallax_x * 16 * w1 / w2 - @Sdistance if @Sdistancs==4
- #~ return @parallax_x * 16 * w1 / w2
- #~ end
- #~ end
- #~ #--------------------------------------------------------------------------
- #~ # ● 计算远景图显示的原点 Y 坐标
- #~ #--------------------------------------------------------------------------
- #~ def parallax_oy(bitmap)
- #~ if @parallax_loop_y
- #~ puts @Sdistancs
- #~ return @parallax_y * 16 + @Sdistance if @Sdistancs==2
- #~ return @parallax_y * 16 - @Sdistance if @Sdistancs==8
- #~ return @parallax_y * 16
- #~ else
- #~ h1 = [bitmap.height - Graphics.height, 0].max
- #~ h2 = [height * 32 - Graphics.height, 1].max
- #~ return @parallax_y * 16 * h1 / h2 + @Sdistance if @Sdistancs==2
- #~ return @parallax_y * 16 * h1 / h2 - @Sdistance if @Sdistancs==8
- #~ return @parallax_y * 16 * h1 / h2
- #~ end
- #~ end
-
- end
- #==============================================================================
- # ■ Spriteset_Map
- #------------------------------------------------------------------------------
- # 处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。
- #==============================================================================
- class Spriteset_Map
- #--------------------------------------------------------------------------
- # ● 生成显示端口
- #--------------------------------------------------------------------------
- def create_viewports
- x=(Graphics.width-$V_Width)/2
- y=(Graphics.height-$V_Height)/2
- @planeViewPort = Viewport.new(0,0,Graphics.width,Graphics.height)
- @viewport1 = Viewport.new(x,y,$V_Width,$V_Height)
- @viewport2 = Viewport.new(x,y,$V_Width,$V_Height)
- @viewport3 = Viewport.new(x,y,$V_Width,$V_Height)
- @viewport2.z = 50
- @viewport3.z = 100
-
- end
-
- def refresh_viewports
- x=(Graphics.width-$V_Width)/2
- y=(Graphics.height-$V_Height)/2
- @V_rect=Rect.new(x,y,$V_Width,$V_Height)
- @viewport1.rect=@V_rect
- @viewport2.rect=@V_rect
- @viewport3.rect=@V_rect
- @viewport2.z = 50
- @viewport3.z = 100
- end
-
- #--------------------------------------------------------------------------
- # ● 生成人物精灵
- #--------------------------------------------------------------------------
- def create_characters
- @character_sprites = []
-
- $game_map.events.values.each do |event|
- if $game_map.width*32<$All_Width then
- if $game_map.loop_horizontal? then
- @sc=Sprite_Character.new(@viewport1, event.clone)
- @sc.character.px=-$game_map.width*32
- @character_sprites.push(@sc)
-
- @sc=Sprite_Character.new(@viewport1, event.clone)
- @sc.character.px=$game_map.width*32
- @character_sprites.push(@sc)
- end
- end
-
- if $game_map.height*32<$All_Height then
- if $game_map.loop_vertical? then
- @sc=Sprite_Character.new(@viewport1, event.clone)
- @sc.character.py=-$game_map.height*32
- @character_sprites.push(@sc)
-
- @sc=Sprite_Character.new(@viewport1, event.clone)
- @sc.character.py=$game_map.height*32
- @character_sprites.push(@sc)
- end
- end
-
- if $game_map.height*32<$All_Height || $game_map.width*32<$All_Width then
- if $game_map.loop_horizontal? && $game_map.loop_vertical? then
- @sc=Sprite_Character.new(@viewport1, event.clone)
- @sc.character.px=-$game_map.width*32
- @sc.character.py=-$game_map.height*32
- @character_sprites.push(@sc)
-
- @sc=Sprite_Character.new(@viewport1, event.clone)
- @sc.character.px=$game_map.width*32
- @sc.character.py=-$game_map.height*32
- @character_sprites.push(@sc)
-
- @sc=Sprite_Character.new(@viewport1, event.clone)
- @sc.character.px=-$game_map.width*32
- @sc.character.py=$game_map.height*32
- @character_sprites.push(@sc)
-
- @sc=Sprite_Character.new(@viewport1, event.clone)
- @sc.character.px=$game_map.width*32
- @sc.character.py=$game_map.height*32
- @character_sprites.push(@sc)
- end
- end
- @character_sprites.push(Sprite_Character.new(@viewport1, event))
-
- end
- $game_map.vehicles.each do |vehicle|
- @character_sprites.push(Sprite_Character.new(@viewport1, vehicle))
- end
- $game_player.followers.reverse_each do |follower|
- @character_sprites.push(Sprite_Character.new(@viewport1, follower))
- end
- @character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
- @map_id = $game_map.map_id
- end
- #--------------------------------------------------------------------------
- # ● 生成远景图
- #--------------------------------------------------------------------------
- def create_parallax
- @parallax = Plane.new(@planeViewPort)
- @parallax.z = -100
- end
- #--------------------------------------------------------------------------
- # ● 释放远景图
- #--------------------------------------------------------------------------
- def dispose_parallax
- @parallax.bitmap.dispose if @parallax.bitmap
- @parallax.dispose
- end
- #--------------------------------------------------------------------------
- # ● 更新远景图
- #--------------------------------------------------------------------------
- def update_parallax
- if @parallax_name != $game_map.parallax_name
- @parallax_name = $game_map.parallax_name
- @parallax.bitmap.dispose if @parallax.bitmap
- @parallax.bitmap = Cache.parallax(@parallax_name)
- Graphics.frame_reset
- end
- @parallax.ox = $game_map.parallax_ox(@parallax.bitmap)
- @parallax.oy = $game_map.parallax_oy(@parallax.bitmap)
- end
-
- end
- #==============================================================================
- # ■ Game_Player
- #------------------------------------------------------------------------------
- # 处理玩家人物的类。拥有事件启动的判定、地图的卷动等功能。
- # 本类的实例请参考 $game_player 。
- #==============================================================================
- class Game_Player < Game_Character
- #--------------------------------------------------------------------------
- # ● 执行场所移动
- #--------------------------------------------------------------------------
- def perform_transfer
- if transfer?
- set_direction(@new_direction)
- if @new_map_id != $game_map.map_id
- $game_map.setup(@new_map_id)
- $game_map.autoplay
- end
- moveto(@new_x, @new_y)
- clear_transfer_info
- end
- end
- #--------------------------------------------------------------------------
- # ● 画面中央的 X 坐标
- #--------------------------------------------------------------------------
- def center_x
- ($V_Width / 32 - 1) / 2.0
- end
- #--------------------------------------------------------------------------
- # ● 画面中央的 Y 坐标
- #--------------------------------------------------------------------------
- def center_y
- ($V_Height / 32 - 1) / 2.0
- end
- end
复制代码 |
评分
-
查看全部评分
|