获得OS.window_size 虽然是实际窗口的尺寸,但不是游戏内设计坐标系的尺寸 如果在Control组件下,并充满屏幕可以读取rect_size 在任意gd代码下使用get_viewport_rect().size可获得设计尺寸 大家有兴趣可以试试下面代码,这是用ColorRect绘制了一个屏幕中心的坐标,使用OS.window_size和get_viewport_rect().size两种方法...
export var maxSize : int = 10 # 房间最大尺寸,乘以瓦片尺寸 export(float, 0.0, 1.0) var cullTolerance : float = 0.4 # 剔除部分房间,系数 onready var _roomContainer := $RoomContainer onready var _camera := $Camera2D onready var _windowSize : Vector2 = self.get_viewport_rect().size ...
_boundary.minY = - rect.position.y * scale.y _boundary.maxX = ProjectSettings.get('display/window/size/width') - (rect.position.x + rect.size.x) * scale.x _boundary.maxY = ProjectSettings.get('display/window/size/height') - (rect.position.y + rect.size.y) * scale.y func _proce...
func _ready(): #获取初始化的参数 p = get_popup() ps = p.size a = DisplayServer.window_get_size() func _process(delta): #修改PopupMenu的大小和缩放比例 b = DisplayServer.window_get_size() c = min(b.x/a.x,b.y/a.y) p.size = ps*c #修改大小 p.content_scale_factor = c #...
很简单,代码如下: void beep(uint64_t times) { io_out8(0x43, 182&0xff); io_out...
_boundary.maxY=ProjectSettings.get('display/window/size/height')-(rect.position.y+rect.size.y)*scale.y func_process(delta):# 根据玩家键盘输入设置玩家的移动方向和速度varhDir=int(Input.is_action_pressed('right'))-int(Input.is_action_pressed('left'))varvDir=int(Input.is_action_pressed('down...
onready var _windowSize : Vector2 = self.get_viewport_rect().size var _isWorking := false # 是否正在进行生成中 var _astarPath : AStar = null # AStar算法实例 var _zoom : Vector2 = Vector2.ONE # 相机缩放 var _offset : Vector2 = Vector2.ZERO # 相机偏移 ...
export (NodePath) onready var player = get_node(player) onready var game_size := Vector2(1024, 768) onready var window_scale := (OS.window_size / game_size).x onready var actual_cam_pos := global_position func _process(delta): #_global.viewport 就是当前使用的viewport #首先...
window_get_size() if saved_size != size: saved_size = size root_node.scale = Vector2(size.y / desired_height, size.y / desired_height)Note, you will need to adjust other game values to be multiplied by this scale value as well (Such as speeds, gravity, velocities) ...
var screen_size # Size of the game window.这在var前加了一个export的作用是可以把声明的变量展示到界面面板上 2楼2019-02-13 20:46 回复 冰蓝圣雪 核心会员 7 该楼层疑似违规已被系统折叠 查看此楼 3楼2019-02-27 16:46 回复(3)