赞 | 0 |
VIP | 0 |
好人卡 | 3 |
积分 | 1 |
经验 | 4293 |
最后登录 | 2014-8-3 |
在线时间 | 41 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 41 小时
- 注册时间
- 2010-7-10
- 帖子
- 111
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 zhangchi5 于 2012-4-8 17:24 编辑
地图居中没有出问题
里面有一部分是让事件可以在循环的地图里显示多个的,出了问题。
本来上面有一个,下面也有一个,结果只有一个了。。。
以解决。。。Event要Clone...
脚本:
- $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
- #--------------------------------------------------------------------------
- # ● 设置
- #--------------------------------------------------------------------------
- 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
- end
- #==============================================================================
- # ■ Spriteset_Map
- #------------------------------------------------------------------------------
- # 处理地图画面精灵和图块的类。本类在 Scene_Map 类的内部使用。
- #==============================================================================
- class Spriteset_Map
- #--------------------------------------------------------------------------
- # ● 生成显示端口
- #--------------------------------------------------------------------------
- def create_viewports
- x=(Graphics.width-$V_Width)/2
- y=(Graphics.height-$V_Height)/2
- @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)
- @sc.character.px=-$game_map.width*32
- @character_sprites.push(@sc)
-
- @sc=Sprite_Character.new(@viewport1, event)
- @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)
- @sc.character.py=-$game_map.height*32
- @character_sprites.push(@sc)
-
- @sc=Sprite_Character.new(@viewport1, event)
- @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)
- @sc.character.px=-$game_map.width*32
- @sc.character.py=-$game_map.height*32
- @character_sprites.push(@sc)
-
- @sc=Sprite_Character.new(@viewport1, event)
- @sc.character.px=$game_map.width*32
- @sc.character.py=-$game_map.height*32
- @character_sprites.push(@sc)
-
- @sc=Sprite_Character.new(@viewport1, event)
- @sc.character.px=-$game_map.width*32
- @sc.character.py=$game_map.height*32
- @character_sprites.push(@sc)
-
- @sc=Sprite_Character.new(@viewport1, event)
- @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
- 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
复制代码 |
|