【问题标题】:screen scaling in small basic :( (litdev)小基本屏幕缩放:( (litdev)
【发布时间】:2022-06-22 07:03:34
【问题描述】:
GraphicsWindow.Width = 1080
GraphicsWindow.Height = 607.5

gw = 1080
gh = 607.5
GraphicsWindow.Left = 0
GraphicsWindow.Top = 0

dw = Desktop.Width
dh = Desktop.Height

WidthMod = dw / gw
HeightMod = dh / gh

newWidth = 1080 * WidthMod
newHeight = 607.5 * HeightMod

distanceWidth = newWidth - gw
distanceHeight = newHeight - gh

 LDGraphicsWindow.Reposition(WidthMod, HeightMod, distanceWidth / 2, distanceHeight / 1.3, 0)

重新定位命令的语法为:reposition(scaleX, scaleY, panX, panY, angle) 我不明白为什么将 distanceWidth(这是旧屏幕和新屏幕大小之间的差异)除以 2 或将 distanceHeight 除以 1.3 会将游戏平移到我需要它的最上角。我想平移它,以便该游戏具有相同的视图,仅取决于 16:9 的比例。

请帮忙 OMG PLESAE :(((((

【问题讨论】:

    标签: smallbasic


    【解决方案1】:

    LDGraphicsWindow.Reposition 实际上根本不移动或缩放窗口,它只是移动窗口内的所有形状。这可能不是您想要的。

    如果您只是想为给定的纵横比创建最大的 GraphicsWindow 并将其居中,则可以使用非常标准的代码轻松完成:

    textRatio = "16:9"
    
    ratioArr = LDText.Split(textRatio, ":")
    
    ratio = ratioArr[1] / ratioArr[2] ' Get the numerical ratio from the text
    curRatio = Desktop.Width/Desktop.Height ' Get the current ratio
    
    GraphicsWindow.Show()
    
    If curRatio > ratio Then 'Screen is too wide
      GraphicsWindow.Width = Desktop.Height * ratio
      GraphicsWindow.Height = Desktop.Height
    ElseIf curRatio < ratio Then 'Screen is too tall
      GraphicsWindow.Height = Desktop.Width / ratio
      GraphicsWindow.Width = Desktop.Width
    EndIf
    
    'Center the window
    GraphicsWindow.Left = (Desktop.Width/2)-(GraphicsWindow.Width/2)
    GraphicsWindow.Top = (Desktop.Height/2)-(GraphicsWindow.Height/2)
    

    【讨论】:

    • 但我想使用重新定位来缩放形状以获得新尺寸,没有 ldgraphicswindow.reposition,这在小型基础中是否可行?
    • 比如说 600x600 的房间中有一个 100x100 的房间。视图应该是相同的,即更大的屏幕是不利的。我是一个新手,所以如果我的问题难以理解,我很抱歉,但如果你明白我的意思,如何在小的基础上进行扩展?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-07-16
    • 2021-07-26
    • 2023-03-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多