添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
  • Godot 支持哪些 3D 模型格式?
  • Godot 会支持【此处插入 FMOD、GameWorks 等闭源 SDK 的名字】吗?
  • 如何在我的系统上安装 Godot 编辑器(进行桌面集成)?
    • Windows
    • macOS
    • Linux
    • Godot 编辑器是绿色应用吗?
    • 为什么 Godot 使用 Vulkan/OpenGL 而不是 Direct3D?
    • 为什么 Godot 旨在保持其核心功能集较小?
    • 如果要适配多种分辨率和纵横比,资产应做哪些处理?
    • 如何扩展 Godot?
    • Godot 的下一个版本什么时候发布?
    • 我想要贡献! 该如何开始?
    • 我有个关于 Godot 的好主意,该如何分享它?
    • 是否能用 Godot 创建非游戏应用?
    • 是否能将 Godot 作为库使用?
    • Godot 使用的用户界面工具包是什么?
    • 为什么 Godot 不使用 STL(标准模板库)?
    • 为什么 Godot 不使用异常?
    • 为什么 Godot 不使用 RTTI?
    • 为什么 Godot 不强制用户实现 DoD(面向数据设计)?
    • 如何支持或参与 Godot 的发展?
    • 谁在为 Godot 工作?如何联系?
    • 我在编辑器或项目管理器里做的任何事都会延迟一帧显示。
    • 当我在编辑器中旋转 3D 相机时,栅格消失了,网格也变黑了。
    • 此编辑器或项目花了很长时间才启动。
    • 检查器和节点面板的编辑器工具提示出现后闪烁。
    • 点击系统控制台后,Godot 编辑器没有响应。
    • 在项目管理器和编辑器窗口的左上角出现“NO DC”之类的文本。
    • 项目窗口看起来很模糊,但编辑器没有模糊。
    • 运行项目时项目窗口没有居中显示。
    • 项目在编辑器中正常运行,但在导出后无法加载部分文件。
    • 2D 图形
    • 2D 工具
    • 3D 图形
    • 3D 工具
    • 3D 物理学
    • 窗口功能与操作系统整合
    • XR 支持(AR 和 VR)
    • GUI 系统
    • _process vs. _physics_process vs. *_input
    • _init vs. 初始化 vs. export
    • _ready vs. _enter_tree vs. NOTIFICATION_PARENTED
    • 数组、字典、对象
    • 枚举:整数 VS 字符串
    • AnimatedTexture vs. AnimatedSprite vs. AnimationPlayer vs. AnimationTree
    • 加载VS预加载
    • 大型关卡: 静态VS动态
    • 忽略具体文件夹
    • 大小写敏感
    • 版本控制系统
      • 官方 Git 插件
      • 从 VCS 中排除的文件
      • 在 Windows 上使用 Git
      • 现在您已经有了一个可以运行的游戏,您可能想要和别人分享您的成果。然而,让您的朋友只为了打开您的项目而下载 Godot 是不实际的。相反,您可以 导出 您的项目,将其转换为任何人都可以运行的“软件包”。

        你导出游戏的方式取决于你的目标平台是什么。在本教程中,你将学习如何为各种平台导出 Dodge the Creeps 游戏。首先,需要对游戏的工作方式进行一些更改。

        如果你还没有制作“Dodge the Creeps”,请在继续本教程之前阅读 您的第一个 2D 游戏

        准备项目

        Dodge the Creeps 中,我们使用键盘控制玩家角色移动。如果游戏是在 PC 平台上进行的就没问题,但在手机或平板电脑上,就需要支持触屏输入。其点击事件可以和触摸事件一样处理,所以会将游戏转换为点击移动的输入方式。

        默认情况下,Godot 会从触摸输入中模拟鼠标输入。这意味着,如果已经针对鼠标事件编写了代码,触摸时也会触发它。Godot 还可以从鼠标点击中模拟触摸输入,为了需要在切换到触摸输入后,能够继续在电脑上玩我们的游戏。

        项目>项目设置 Input Devices > Pointing (输入设备 > 触点)下,启用 Emulate Touch From Mouse (根据鼠标模拟触摸)。

        我们还想确保游戏在不同尺寸的屏幕上有一致的比例,所以在项目设置中进入 Display ,然后点击 Window 。在 Stretch 选项中,将 Mode 设置为 2d Aspect 设置为 keep

        由于我们已经在 Window 设置中,还应该在 Handheld (手持设备)下将 Orientation (方向)设置为 portrait (竖屏)。

        接下来,我们需要修改 Player.gd 脚本来改变输入方式。我们将移除键盘输入并使玩家移动到触摸(或点击)事件设置的“目标”。

        这是玩家的完整脚本,注释指出了我们做了哪些改变:

        extends Area2D
        signal hit
        export var speed = 400
        var screen_size
        # Add this variable to hold the clicked position.
        var target = Vector2()
        func _ready():
            hide()
            screen_size = get_viewport_rect().size
        func start(pos):
            position = pos
            # Initial target is the start position.
            target = pos
            show()
            $CollisionShape2D.disabled = false
        # Change the target whenever a touch event happens.
        func _input(event):
            if event is InputEventScreenTouch and event.pressed:
                target = event.position
        func _process(delta):
            var velocity = Vector2()
            # Move towards the target and stop when close.
            if position.distance_to(target) > 10:
                velocity = target - position
        # Remove keyboard controls.
        #    if Input.is_action_pressed("ui_right"):
        #       velocity.x += 1
        #    if Input.is_action_pressed("ui_left"):
        #        velocity.x -= 1
        #    if Input.is_action_pressed("ui_down"):
        #        velocity.y += 1
        #    if Input.is_action_pressed("ui_up"):
        #        velocity.y -= 1
            if velocity.length() > 0:
                velocity = velocity.normalized() * speed
                $AnimatedSprite.play()
            else:
                $AnimatedSprite.stop()
            position += velocity * delta
            # We still need to clamp the player's position here because on devices that don't
            # match your game's aspect ratio, Godot will try to maintain it as much as possible
            # by creating black borders, if necessary.
            # Without clamp(), the player would be able to move under those borders.
            position.x = clamp(position.x, 0, screen_size.x)
            position.y = clamp(position.y, 0, screen_size.y)
            if velocity.x != 0:
                $AnimatedSprite.animation = "walk"
                $AnimatedSprite.flip_v = false
                $AnimatedSprite.flip_h = velocity.x < 0
            elif velocity.y != 0:
                $AnimatedSprite.animation = "up"
                $AnimatedSprite.flip_v = velocity.y > 0
        func _on_Player_body_entered( body ):
            hide()
            emit_signal("hit")
            $CollisionShape2D.set_deferred("disabled", true)
        
  •