Project1

标题: RPGMaker地圖縮放後跑掉 [打印本页]

作者: Chenchenyi    时间: 2022-10-12 16:36
标题: RPGMaker地圖縮放後跑掉
大家好,近期再用rpgmaker vx做遊戲
因為覺得預設的畫面太小了所以這邊有用腳本把它手動調大
腳本如下
============================================
#==============================================================================
# ■ 畫面大小更改
#------------------------------------------------------------------------------
# 畫面大小更改
#==============================================================================
Graphics.resize_screen(1080,750)
#Basic Window Resizer v1.1
#----------#
#Features: Allows you to resize the window to whatever size you like! (This is not
#            like Graphics.resize, this will scale to fit)
#
#Usage:   Script calls:
#           Window_Resize.r(width, height)     - Self-explanatory
#           Window_Resize.f                    - fits the game window to monitor size
#           Window_Resize.full                 - switches to full screen unless already fullscreened
#           Window_Resize.window               - same as full but opposite
#           Window_Resize.toggle               - toggles between full and window
#
#No Customization
#
#----------#
#-- Script by: V.M of D.T
#
#- Questions or comments can be:
#    posted on the thread for the script
#    given by email: [email protected]
#    provided on facebook: http://www.facebook.com/DaimoniousTailsGames
#    posed on site: daimonioustails.wordpress.com
#
#- Free to use in any project with credit given, donations always welcome!

SWPO = Win32API.new 'user32', 'SetWindowPos', ['l','i','i','i','i','i','p'], 'i'
WINX = Win32API.new 'user32', 'FindWindowEx', ['l','l','p','p'], 'i'
SMET = Win32API.new 'user32', 'GetSystemMetrics', ['i'], 'i'

module Window_Resize
  def self.r(width, height)
    resw = SMET.call(0)
    resh = SMET.call(1)
    window_loc = WINX.call(0,0,"RGSS Player",0)
    width += (SMET.call(5) + SMET.call(45)) * 2
    height += (SMET.call(6) + SMET.call(45)) * 2 + SMET.call(4)
    x = (resw - width) / 2; y = (resh - height) / 2
    y = 0 if y < 0;x = 0 if x < 0
    SWPO.call(window_loc,0,x,y,width,height,0)
  end
  def self.f
    resw = SMET.call(0)
    resh = SMET.call(1)
    window_loc = WINX.call(0,0,"RGSS Player",0)
    SWPO.call(window_loc,0,0,0,resw,resh,0)
  end
  def self.full
    resw = SMET.call(0)
    return unless resw > 640
    toggle
  end
  def self.window
    resw = SMET.call(0)
    return unless resw < 640
    toggle
  end
  def self.toggle
    keybd = Win32API.new 'user32.dll', 'keybd_event', ['i', 'i', 'l', 'l'], 'v'
    keybd.call 0xA4, 0, 0, 0
    keybd.call 13, 0, 0, 0
    keybd.call 13, 0, 2, 0
    keybd.call 0xA4, 0, 2, 0
  end
end
Window_Resize.r(1080,750)
=======================================================

出來的結果的確是放大了

但是卻有一個L型的邊框,設定事件點的時候也與遊戲執行時的位置不同
確定目前圖片的大小是有超過設定大小的
想問這樣要怎麼調整定位跟圖片邊框問題呢

作者: 张咚咚    时间: 2022-11-27 19:52
本帖最后由 张咚咚 于 2022-11-27 19:55 编辑

将下面这些脚本插入到你上面的脚本的下面。(不过推荐做法是建议将你的分辨率宽高改为32的整除数,然后将下面这段脚本里所有的 32.0 替换为 32)

  1. class Game_Map
  2.   def setup_scroll
  3.     @scroll_direction = 2
  4.     @scroll_rest = 0
  5.     @scroll_speed = 4
  6.     @margin_x = (width - (Graphics.width / 32.0)) * 256 / 2
  7.     @margin_y = (height - (Graphics.height / 32.0)) * 256 / 2
  8.   end
  9.   def scroll_down(distance)
  10.     if loop_vertical?
  11.       @display_y += distance
  12.       @display_y %= @map.height * 256
  13.       @parallax_y += distance
  14.     else
  15.       last_y = @display_y
  16.       @display_y = [@display_y + distance, (height - (Graphics.height / 32.0)) * 256].min
  17.       @parallax_y += @display_y - last_y
  18.     end
  19.   end
  20.   def scroll_right(distance)
  21.     if loop_horizontal?
  22.       @display_x += distance
  23.       @display_x %= @map.width * 256
  24.       @parallax_x += distance
  25.     else
  26.       last_x = @display_x
  27.       @display_x = [@display_x + distance, (width - (Graphics.width / 32.0)) * 256].min
  28.       @parallax_x += @display_x - last_x
  29.     end
  30.   end
  31. end
  32. class Game_Player < Game_Character
  33.   #--------------------------------------------------------------------------
  34.   # ● 常量
  35.   #--------------------------------------------------------------------------
  36.   CENTER_X = (Graphics.width / 2 - 16) * 8     # 画面中央 X 座标 * 8
  37.   CENTER_Y = (Graphics.height / 2 - 16) * 8     # 画面中央 Y 座标 * 8
  38.   def center(x, y)
  39.     display_x = x * 256 - CENTER_X                    # 计算座标
  40.     unless $game_map.loop_horizontal?                 # 非横向回圈的场合
  41.       max_x = ($game_map.width - (Graphics.width / 32.0)) * 256            # 计算最大值
  42.       display_x = [0, [display_x, max_x].min].max     # 校正座标
  43.     end
  44.     display_y = y * 256 - CENTER_Y                    # 计算座标
  45.     unless $game_map.loop_vertical?                   # 非横向回圈的场合
  46.       max_y = ($game_map.height - (Graphics.height / 32.0)) * 256           # 计算最大值
  47.       display_y = [0, [display_y, max_y].min].max     # 校正座标
  48.     end
  49.     $game_map.set_display_pos(display_x, display_y)   # 改变地图位置
  50.   end
  51. end

  52. class Spriteset_Map
  53.   def create_viewports
  54.     @viewport1 = Viewport.new(0, 0, Graphics.width, Graphics.height)
  55.     @viewport2 = Viewport.new(0, 0, Graphics.width, Graphics.height)
  56.     @viewport3 = Viewport.new(0, 0, Graphics.width, Graphics.height)
  57.     @viewport2.z = 50
  58.     @viewport3.z = 100
  59.   end
  60. end
复制代码





欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1