godot.bk:how to add map to the game

1.项目构建如下,map是我们点击start之后才渲染出来的 

mian.tscn --main.gd
--background(textureact)
--start(button) --button.gd
sourceFile
map.tscn
--tilemap --tileset

2.main.gd:注意main.gd并不定义信号,它只是接收信号而已

extends Control

# Called when the node enters the scene tree for the first time.
func _ready():
	$start.connect("game_start", self._on_start)
	pass # Replace with function body.

func _on_start():
	#var s = preload("res://map/map.tscn").instantiate()
	#add_child(s)
	get_tree().change_scene_to_file("res://map/map.tscn")

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
	pass

 用preload的方式会导致map和user界面重叠,两个都显示在一起了

3.start.gd

extends Button

signal game_start

# Called when the node enters the scene tree for the first time.
func _ready():
	connect("button_down", self._on_pressed);
	pass # Replace with function body.

func _on_pressed():
	emit_signal("game_start")

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
	pass

4.如何导入图片,导入图片的是tilemap下的tileset,tilemap是导入之后绘画的,不要搞错了

如图,右键点击【新建tileset 】之后,点击下面的【tileset1】把左边的图片拖过来,再点击右边的tilemap画图

相关推荐

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-06-06 07:28:04       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-06-06 07:28:04       106 阅读
  3. 在Django里面运行非项目文件

    2024-06-06 07:28:04       87 阅读
  4. Python语言-面向对象

    2024-06-06 07:28:04       96 阅读

热门阅读

  1. 入门级python编程题(12)洛谷(分类平均)

    2024-06-06 07:28:04       20 阅读
  2. Chatgpt-4o:人工智能领域的革新与未来展望

    2024-06-06 07:28:04       34 阅读
  3. 提交一个Bug需要哪些信息?

    2024-06-06 07:28:04       27 阅读
  4. PSOPT在Ubuntu22.04下的安装

    2024-06-06 07:28:04       29 阅读
  5. flask项目结构心得

    2024-06-06 07:28:04       24 阅读
  6. #职场发展#其他

    2024-06-06 07:28:04       27 阅读
  7. git命令

    2024-06-06 07:28:04       34 阅读