update godot start demo to 4.x
|
@ -0,0 +1 @@
|
||||||
|
<svg height="128" width="128" xmlns="http://www.w3.org/2000/svg"><rect x="2" y="2" width="124" height="124" rx="14" fill="#363d52" stroke="#212532" stroke-width="4"/><g transform="scale(.101) translate(122 122)"><g fill="#fff"><path d="M105 673v33q407 354 814 0v-33z"/><path fill="#478cbf" d="m105 673 152 14q12 1 15 14l4 67 132 10 8-61q2-11 15-15h162q13 4 15 15l8 61 132-10 4-67q3-13 15-14l152-14V427q30-39 56-81-35-59-83-108-43 20-82 47-40-37-88-64 7-51 8-102-59-28-123-42-26 43-46 89-49-7-98 0-20-46-46-89-64 14-123 42 1 51 8 102-48 27-88 64-39-27-82-47-48 49-83 108 26 42 56 81zm0 33v39c0 276 813 276 813 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H447l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z"/><path d="M483 600c3 34 55 34 58 0v-86c-3-34-55-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></g></svg>
|
After Width: | Height: | Size: 950 B |
|
@ -0,0 +1,37 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://dwduwy3y2vipi"
|
||||||
|
path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://icon.svg"
|
||||||
|
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
|
svg/scale=1.0
|
||||||
|
editor/scale_with_editor_scale=false
|
||||||
|
editor/convert_colors_with_editor_theme=false
|
|
@ -0,0 +1,42 @@
|
||||||
|
; Engine configuration file.
|
||||||
|
; It's best edited using the editor UI and not directly,
|
||||||
|
; since the parameters that go here are not all obvious.
|
||||||
|
;
|
||||||
|
; Format:
|
||||||
|
; [section] ; section goes between []
|
||||||
|
; param=value ; assign values to parameters
|
||||||
|
|
||||||
|
config_version=5
|
||||||
|
|
||||||
|
[application]
|
||||||
|
|
||||||
|
config/name="godot-start"
|
||||||
|
config/features=PackedStringArray("4.2", "Forward Plus")
|
||||||
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
|
[input]
|
||||||
|
|
||||||
|
move_right={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"echo":false,"script":null)
|
||||||
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
move_left={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"echo":false,"script":null)
|
||||||
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194319,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
move_down={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"echo":false,"script":null)
|
||||||
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194322,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
move_up={
|
||||||
|
"deadzone": 0.5,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"echo":false,"script":null)
|
||||||
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194320,"key_label":0,"unicode":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
[gd_scene load_steps=2 format=3 uid="uid://xl6nmhnrybxt"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scene/demo01_hello/script/CustomNode.gd" id="1_eg1cy"]
|
||||||
|
|
||||||
|
[node name="CustomNode" type="Node2D"]
|
||||||
|
script = ExtResource("1_eg1cy")
|
|
@ -0,0 +1,13 @@
|
||||||
|
[gd_scene load_steps=2 format=3 uid="uid://dip07sfdhauy3"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scene/demo01_hello/script/HelloWorld.gd" id="1_2stq7"]
|
||||||
|
|
||||||
|
[node name="Node2D" type="Node2D"]
|
||||||
|
script = ExtResource("1_2stq7")
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="."]
|
||||||
|
offset_left = 284.0
|
||||||
|
offset_top = 138.0
|
||||||
|
offset_right = 534.0
|
||||||
|
offset_bottom = 248.0
|
||||||
|
text = "Hello World!!!"
|
|
@ -0,0 +1,16 @@
|
||||||
|
[gd_scene load_steps=3 format=3 uid="uid://bfwao1wrksjvi"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dwduwy3y2vipi" path="res://icon.svg" id="1_rf4v3"]
|
||||||
|
[ext_resource type="Script" path="res://scene/demo01_hello/script/NodeTest.gd" id="2_bus8m"]
|
||||||
|
|
||||||
|
[node name="NodeTest" type="Node2D"]
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
process_thread_group = 2
|
||||||
|
process_thread_group_order = 0
|
||||||
|
process_thread_messages = 0
|
||||||
|
position = Vector2(314, 176)
|
||||||
|
texture = ExtResource("1_rf4v3")
|
||||||
|
script = ExtResource("2_bus8m")
|
||||||
|
|
||||||
|
[node name="NodeChild" type="Node2D" parent="Sprite2D"]
|
|
@ -0,0 +1,12 @@
|
||||||
|
@icon("res://icon.svg")
|
||||||
|
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
class_name MyNode
|
||||||
|
|
||||||
|
@export var a: int = 1
|
||||||
|
@export var b: String
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
print("my custom node")
|
||||||
|
pass
|
|
@ -0,0 +1,7 @@
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready():
|
||||||
|
print("Hello World")
|
||||||
|
pass
|
|
@ -0,0 +1,34 @@
|
||||||
|
extends Sprite2D
|
||||||
|
|
||||||
|
var speed: int = 400
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
print("node test")
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
func _process(delta):
|
||||||
|
var velocity = Vector2.ZERO # The player's movement vector.
|
||||||
|
if Input.is_action_pressed("move_right"):
|
||||||
|
velocity.x += 1
|
||||||
|
if Input.is_action_pressed("move_left"):
|
||||||
|
velocity.x -= 1
|
||||||
|
if Input.is_action_pressed("move_down"):
|
||||||
|
velocity.y += 1
|
||||||
|
if Input.is_action_pressed("move_up"):
|
||||||
|
velocity.y -= 1
|
||||||
|
|
||||||
|
if velocity.length() <= 0:
|
||||||
|
return
|
||||||
|
|
||||||
|
velocity = velocity.normalized() * speed
|
||||||
|
position += velocity * delta
|
||||||
|
#$NodeChild.position = Vector2.ZERO
|
||||||
|
#get_parent().position = Vector2.ZERO
|
||||||
|
#self.call_deferred("myCall")
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
func myCall():
|
||||||
|
get_parent().position = Vector2.ZERO
|
||||||
|
pass
|
|
@ -0,0 +1,6 @@
|
||||||
|
[gd_scene load_steps=2 format=3 uid="uid://b7s0egg33pq5j"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scene/demo02_base/script/base1.gd" id="1_l5s6b"]
|
||||||
|
|
||||||
|
[node name="Base1" type="Node2D"]
|
||||||
|
script = ExtResource("1_l5s6b")
|
|
@ -0,0 +1,6 @@
|
||||||
|
[gd_scene load_steps=2 format=3 uid="uid://2p8k7qtylahq"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scene/demo02_base/script/base2.gd" id="1_itqfs"]
|
||||||
|
|
||||||
|
[node name="Base2" type="Node2D"]
|
||||||
|
script = ExtResource("1_itqfs")
|
|
@ -0,0 +1,6 @@
|
||||||
|
[gd_scene load_steps=2 format=3 uid="uid://bkluu2gprqnkl"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scene/demo02_base/script/base3.gd" id="1_bxk7m"]
|
||||||
|
|
||||||
|
[node name="Base3" type="Node2D"]
|
||||||
|
script = ExtResource("1_bxk7m")
|
|
@ -0,0 +1,6 @@
|
||||||
|
[gd_scene load_steps=2 format=3 uid="uid://dtb4spakfebfu"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scene/demo02_base/script/base4.gd" id="1_usodk"]
|
||||||
|
|
||||||
|
[node name="Base4" type="Node2D"]
|
||||||
|
script = ExtResource("1_usodk")
|
|
@ -0,0 +1,4 @@
|
||||||
|
extends RefCounted
|
||||||
|
|
||||||
|
# 表示B对象
|
||||||
|
var b
|
|
@ -0,0 +1,4 @@
|
||||||
|
extends RefCounted
|
||||||
|
|
||||||
|
# 表示A对象
|
||||||
|
var a
|
|
@ -0,0 +1,4 @@
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
func _to_string():
|
||||||
|
print("This is C Node2!")
|
|
@ -0,0 +1,5 @@
|
||||||
|
# 如果没有继承任何类,则默认继承RefCounted
|
||||||
|
extends RefCounted
|
||||||
|
|
||||||
|
func _to_string():
|
||||||
|
print("This is C Reference Counted!")
|
|
@ -0,0 +1,185 @@
|
||||||
|
@icon("res://icon.svg")
|
||||||
|
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
# (optional) class definition with a custom icon
|
||||||
|
class_name MyClass
|
||||||
|
|
||||||
|
const StringUtils = preload("res://zfoo/util/StringUtils.gd")
|
||||||
|
|
||||||
|
# Member variables
|
||||||
|
# gds有5种基础类型,Boolean,Integer(Java long),Float(Java double),String,Null
|
||||||
|
|
||||||
|
# &&=and ||=or !=not
|
||||||
|
var a = (true or false) && true
|
||||||
|
var b = 9223372036854775807
|
||||||
|
var c = 1.5
|
||||||
|
var s = "Hello"
|
||||||
|
var arr = [1, 2, 3]
|
||||||
|
var dict = {
|
||||||
|
2: 3,
|
||||||
|
"key": "字符串作为key",
|
||||||
|
arr: "数组作为key"
|
||||||
|
}
|
||||||
|
var typed_var: int
|
||||||
|
var typed_var_float: float
|
||||||
|
var typed_var_bool: bool
|
||||||
|
var inferred_type: String = "String"
|
||||||
|
|
||||||
|
# Constants
|
||||||
|
const ANSWER = 42
|
||||||
|
const THE_NAME = "Charly"
|
||||||
|
# Static filed
|
||||||
|
static var my_static_field = 42
|
||||||
|
|
||||||
|
# Enums
|
||||||
|
|
||||||
|
enum {LEFT, RRIGHT, FRONT, BACK}
|
||||||
|
# 等价于
|
||||||
|
# const LEFT = 0
|
||||||
|
# const RIGHT = 1
|
||||||
|
# const FRONT = 2
|
||||||
|
# const BACK = 3
|
||||||
|
enum FOOD {GOOD, NORMAL, BAD = -1}
|
||||||
|
|
||||||
|
# Built-in vector types
|
||||||
|
|
||||||
|
var v2 = Vector2(1, 2)
|
||||||
|
var v3 = Vector3(1, 2, 3)
|
||||||
|
|
||||||
|
func _init():
|
||||||
|
print("调用了_init()构造器方法")
|
||||||
|
pass
|
||||||
|
|
||||||
|
static func getAnswer():
|
||||||
|
return ANSWER
|
||||||
|
|
||||||
|
func typeInfo():
|
||||||
|
var template = "[Variant:{}] [type:{}] [value:{}]"
|
||||||
|
print(StringUtils.format(template, [TYPE_BOOL, typeof(a), a]))
|
||||||
|
print(StringUtils.format(template, [TYPE_INT, typeof(b), b]))
|
||||||
|
print(StringUtils.format(template, [TYPE_INT, typeof(c), c]))
|
||||||
|
print(StringUtils.format(template, [TYPE_STRING, typeof(s), s]))
|
||||||
|
# print(StringUtils.format(template, [TYPE_ARRAY, typeof(arr), arr]))
|
||||||
|
print(StringUtils.format(template, [TYPE_DICTIONARY, typeof(dict), dict]))
|
||||||
|
print(StringUtils.format(template, [TYPE_DICTIONARY, typeof(FOOD), FOOD]))
|
||||||
|
print(StringUtils.format(template, [TYPE_DICTIONARY, typeof(FOOD.GOOD), FOOD.GOOD]))
|
||||||
|
# 在java中类似于this
|
||||||
|
print(self is Node)
|
||||||
|
print(a is Dog) # 类似于instanceof
|
||||||
|
pass
|
||||||
|
|
||||||
|
func if_function(param1, param2):
|
||||||
|
if param1 < param2:
|
||||||
|
print(param1)
|
||||||
|
elif param2 > 5:
|
||||||
|
print(param2)
|
||||||
|
else:
|
||||||
|
print("Fail!")
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
func switch_function():
|
||||||
|
var local_var = 5
|
||||||
|
|
||||||
|
match local_var:
|
||||||
|
1:
|
||||||
|
print("match1")
|
||||||
|
2:
|
||||||
|
print("match2")
|
||||||
|
5:
|
||||||
|
print("match5")
|
||||||
|
# continue
|
||||||
|
6:
|
||||||
|
print("match6")
|
||||||
|
_:
|
||||||
|
print("match_")
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
func loop_function():
|
||||||
|
for i in range(20):
|
||||||
|
print(i)
|
||||||
|
var param = 10
|
||||||
|
while param != 0:
|
||||||
|
param -= 1
|
||||||
|
return param
|
||||||
|
|
||||||
|
# Function
|
||||||
|
func arrayIterator():
|
||||||
|
# range等价于for(int i = 0; i < 20; i++)
|
||||||
|
print("数组遍历方法1:")
|
||||||
|
for i in range(3):
|
||||||
|
print(i)
|
||||||
|
print("数组遍历方法2:")
|
||||||
|
for ele in arr:
|
||||||
|
print(ele)
|
||||||
|
print("数组遍历方法3:")
|
||||||
|
for index in range(arr.size()):
|
||||||
|
print(arr[index])
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
func dictionaryIterator():
|
||||||
|
print("字典遍历方法1:")
|
||||||
|
for key in dict:
|
||||||
|
print("key:" + str(key))
|
||||||
|
print("value:" + str(dict[key]))
|
||||||
|
|
||||||
|
print("字典遍历方法2:")
|
||||||
|
for key in dict.keys():
|
||||||
|
print("key:" + str(key))
|
||||||
|
print("value:" + str(dict[key]))
|
||||||
|
|
||||||
|
print("字典遍历方法3:")
|
||||||
|
for value in dict.values():
|
||||||
|
print("value:" + str(value))
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func innerClassTest():
|
||||||
|
var dog = Dog.new(1)
|
||||||
|
dog.move()
|
||||||
|
|
||||||
|
dog.info()
|
||||||
|
dog.height = 2
|
||||||
|
dog.info()
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Inner class,默认继承Object
|
||||||
|
class Animal:
|
||||||
|
extends Object # 如果不指定继承的类,默认基础Object
|
||||||
|
const STATIC_FIELD = "静态变量"
|
||||||
|
# 属性
|
||||||
|
var height: int
|
||||||
|
|
||||||
|
func _init():
|
||||||
|
print("Animal 构造方法")
|
||||||
|
|
||||||
|
func move():
|
||||||
|
print("animal,移动")
|
||||||
|
|
||||||
|
static func staticFuction():
|
||||||
|
pass
|
||||||
|
|
||||||
|
class Dog:
|
||||||
|
extends Animal
|
||||||
|
|
||||||
|
# Constructor
|
||||||
|
func _init(_height):
|
||||||
|
self.height = _height
|
||||||
|
print("Dog 构造方法")
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Functions override functions with the same name on the base/parent class.
|
||||||
|
func move():
|
||||||
|
print("dog,用4个脚跑")
|
||||||
|
# If you still want to call them, use '.' (like 'super' in other languages).
|
||||||
|
super.move()
|
||||||
|
pass
|
||||||
|
|
||||||
|
func info(_parm = 100):
|
||||||
|
print("height:" + str(height))
|
||||||
|
pass
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
|
||||||
|
# 导出一个数字
|
||||||
|
@export var a = 1
|
||||||
|
# 导出一个节点路径
|
||||||
|
@export var b:NodePath
|
||||||
|
# 导出一个文件路径
|
||||||
|
@export_file var sound_effect_path: String
|
||||||
|
# 导出一个文件路径,以txt结尾
|
||||||
|
@export_file("*.txt") var notes_path: String
|
||||||
|
|
||||||
|
|
||||||
|
func _init():
|
||||||
|
print("init")
|
||||||
|
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready():
|
||||||
|
print("ready")
|
||||||
|
print("new一个对象--------------------------------")
|
||||||
|
var myClass = MyClass.new()
|
||||||
|
print(myClass.to_string())
|
||||||
|
|
||||||
|
print("数据类型信息--------------------------------")
|
||||||
|
myClass.typeInfo()
|
||||||
|
|
||||||
|
print("基础语法if else--------------------------------")
|
||||||
|
myClass.if_function(1, 2)
|
||||||
|
|
||||||
|
print("基础语法switch--------------------------------")
|
||||||
|
myClass.switch_function()
|
||||||
|
|
||||||
|
print("基础语法while for--------------------------------")
|
||||||
|
myClass.loop_function()
|
||||||
|
|
||||||
|
print("数组遍历--------------------------------")
|
||||||
|
myClass.arrayIterator()
|
||||||
|
|
||||||
|
print("字典遍历--------------------------------")
|
||||||
|
myClass.dictionaryIterator()
|
||||||
|
|
||||||
|
print("访问常量--------------------------------")
|
||||||
|
var answer = MyClass.ANSWER
|
||||||
|
print("访问const变量,类似于static变量:" + str(answer))
|
||||||
|
print("访问静态变量--------------------------------")
|
||||||
|
print("访问static变量,类似于static变量:" + str(MyClass.my_static_field))
|
||||||
|
print("调用静态方法--------------------------------")
|
||||||
|
print("调用静态方法:" + str(MyClass.getAnswer()))
|
||||||
|
|
||||||
|
print("内部类测试--------------------------------")
|
||||||
|
myClass.innerClassTest()
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
const CNode = preload("res://scene/demo02_base/script/CNode.gd")
|
||||||
|
const CReference = preload("res://scene/demo02_base/script/CReference.gd")
|
||||||
|
|
||||||
|
# monitor初探
|
||||||
|
func _ready():
|
||||||
|
#nodeTest()
|
||||||
|
#nodeFreeTest()
|
||||||
|
#nodeQueueFreeTest()
|
||||||
|
#referenceTest()
|
||||||
|
#referenceFreeTest()
|
||||||
|
referencUnreferenceTest()
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
func nodeTest():
|
||||||
|
for i in range(10000):
|
||||||
|
var _instance = CNode.new()
|
||||||
|
|
||||||
|
|
||||||
|
func nodeFreeTest():
|
||||||
|
for i in range(10000):
|
||||||
|
var instance = CNode.new()
|
||||||
|
instance.free()
|
||||||
|
|
||||||
|
# queue_free效率更高
|
||||||
|
func nodeQueueFreeTest():
|
||||||
|
for i in range(10000):
|
||||||
|
var instance = CNode.new()
|
||||||
|
instance.queue_free()
|
||||||
|
|
||||||
|
func referenceTest():
|
||||||
|
for i in range(10000):
|
||||||
|
var _instance = CReference.new()
|
||||||
|
|
||||||
|
|
||||||
|
func referenceFreeTest():
|
||||||
|
for i in range(10000):
|
||||||
|
var instance = CReference.new()
|
||||||
|
instance.free()
|
||||||
|
|
||||||
|
# 4.x主动调用unreference会导致没有被回收对象
|
||||||
|
func referencUnreferenceTest():
|
||||||
|
for i in range(10000):
|
||||||
|
var instance = CReference.new()
|
||||||
|
instance.reference()
|
||||||
|
instance.unreference()
|
|
@ -0,0 +1,38 @@
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
const A = preload("res://scene/demo02_base/script/A.gd")
|
||||||
|
const B = preload("res://scene/demo02_base/script/B.gd")
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
#referenceTest()
|
||||||
|
#referenceCycleTest()
|
||||||
|
#referenceUnreference1Test()
|
||||||
|
#referenceUnreference2Test()
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
func referenceTest():
|
||||||
|
var a = A.new()
|
||||||
|
var b = B.new()
|
||||||
|
|
||||||
|
func referenceCycleTest():
|
||||||
|
var a = A.new()
|
||||||
|
var b = B.new()
|
||||||
|
a.b = b
|
||||||
|
b.a = a
|
||||||
|
|
||||||
|
|
||||||
|
func referenceUnreference1Test():
|
||||||
|
var a = A.new()
|
||||||
|
var b = B.new()
|
||||||
|
a.b = b
|
||||||
|
b.a = a
|
||||||
|
a.unreference()
|
||||||
|
|
||||||
|
func referenceUnreference2Test():
|
||||||
|
var a = A.new()
|
||||||
|
var b = B.new()
|
||||||
|
a.b = b
|
||||||
|
b.a = a
|
||||||
|
a.unreference()
|
||||||
|
b.unreference()
|
|
@ -0,0 +1,27 @@
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
# new一个Sprite节点
|
||||||
|
var sprite = Sprite2D.new()
|
||||||
|
# 设置图片
|
||||||
|
var icon = preload("res://icon.svg")
|
||||||
|
sprite.set_texture(icon)
|
||||||
|
|
||||||
|
# 修改名称
|
||||||
|
sprite.name = "mynode"
|
||||||
|
|
||||||
|
# 修改坐标居中
|
||||||
|
sprite.position.x = 200
|
||||||
|
sprite.position.y = 200
|
||||||
|
|
||||||
|
# 添加到当前的场景中
|
||||||
|
add_child(sprite)
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func _process(delta):
|
||||||
|
var sprite: Sprite2D = $mynode
|
||||||
|
sprite.rotate(0.1)
|
||||||
|
pass
|
|
@ -0,0 +1,21 @@
|
||||||
|
[gd_scene load_steps=4 format=3 uid="uid://bnqtr1vlp0npl"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scene/demo03_lifecycle/script/parent.gd" id="1_pcyfp"]
|
||||||
|
[ext_resource type="Script" path="res://scene/demo03_lifecycle/script/sub_node1.gd" id="2_51utr"]
|
||||||
|
[ext_resource type="Script" path="res://scene/demo03_lifecycle/script/sub_node2.gd" id="3_8nf4e"]
|
||||||
|
|
||||||
|
[node name="Node2D" type="Node2D"]
|
||||||
|
script = ExtResource("1_pcyfp")
|
||||||
|
|
||||||
|
[node name="SubNode1" type="Node2D" parent="."]
|
||||||
|
script = ExtResource("2_51utr")
|
||||||
|
|
||||||
|
[node name="SubNode2" type="Node" parent="SubNode1"]
|
||||||
|
script = ExtResource("3_8nf4e")
|
||||||
|
|
||||||
|
[node name="DeleteButton" type="Button" parent="."]
|
||||||
|
offset_left = 595.0
|
||||||
|
offset_top = 258.0
|
||||||
|
offset_right = 742.0
|
||||||
|
offset_bottom = 307.0
|
||||||
|
text = "Delete SubNode1"
|
|
@ -0,0 +1,41 @@
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
const NodeUtils = preload("res://zfoo/util/NodeUtils.gd")
|
||||||
|
|
||||||
|
func _enter_tree():
|
||||||
|
# When the node enters the Scene Tree, it becomes active
|
||||||
|
# and this function is called. Children nodes have not entered
|
||||||
|
# the active scene yet. In general, it's better to use _ready()
|
||||||
|
# for most cases.
|
||||||
|
print("parent _enter_tree")
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
# This function is called after _enter_tree, but it ensures
|
||||||
|
# that all children nodes have also entered the Scene Tree,
|
||||||
|
# and became active.
|
||||||
|
print("parent _ready")
|
||||||
|
$DeleteButton.connect("pressed", Callable(self, "deleteSubNode1"))
|
||||||
|
|
||||||
|
func _exit_tree():
|
||||||
|
# When the node exits the Scene Tree, this function is called.
|
||||||
|
# Children nodes have all exited the Scene Tree at this point
|
||||||
|
# and all became inactive.
|
||||||
|
print("parent _exit_tree")
|
||||||
|
|
||||||
|
|
||||||
|
func deleteSubNode1():
|
||||||
|
var root = get_tree().root
|
||||||
|
root.remove_child(self)
|
||||||
|
|
||||||
|
#注意monitor监视窗口的object变化,和node变化,由于组合一个节点可能包含多个对象
|
||||||
|
#self.queue_free()
|
||||||
|
|
||||||
|
#remove_child只能移除子节点,无法移除子节点的子节点
|
||||||
|
#get_tree().root.remove_child(self)
|
||||||
|
#remove_child($SubNode1)
|
||||||
|
|
||||||
|
#先增加再删除
|
||||||
|
#root.add_child(self)
|
||||||
|
|
||||||
|
#为了简单,可以使用统一的封装方法,门面模式
|
||||||
|
#NodeUtils.removeNode(self)
|
|
@ -0,0 +1,48 @@
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
|
||||||
|
func _enter_tree():
|
||||||
|
# When the node enters the Scene Tree, it becomes active
|
||||||
|
# and this function is called. Children nodes have not entered
|
||||||
|
# the active scene yet. In general, it's better to use _ready()
|
||||||
|
# for most cases.
|
||||||
|
print("sub node1 _enter_tree")
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
# This function is called after _enter_tree, but it ensures
|
||||||
|
# that all children nodes have also entered the Scene Tree,
|
||||||
|
# and became active.
|
||||||
|
print("sub node1 _ready")
|
||||||
|
#nodeUsage()
|
||||||
|
|
||||||
|
func _exit_tree():
|
||||||
|
# When the node exits the Scene Tree, this function is called.
|
||||||
|
# Children nodes have all exited the Scene Tree at this point
|
||||||
|
# and all became inactive.
|
||||||
|
print("sub node1 _exit_tree")
|
||||||
|
|
||||||
|
|
||||||
|
# 申明和存储节点,等价于在_ready()下赋值
|
||||||
|
@onready var readySubNode = $SubNode2
|
||||||
|
|
||||||
|
func nodeUsage():
|
||||||
|
# 获取当前节点
|
||||||
|
var currentNode1 = $"."
|
||||||
|
var currentNode2 = self
|
||||||
|
# 获取父节点
|
||||||
|
var parentNode1 = get_parent()
|
||||||
|
var parentNode2 = $"../"
|
||||||
|
# 获取子节点
|
||||||
|
var subNode1 = $SubNode2
|
||||||
|
var subNode2 = $"SubNode2"
|
||||||
|
var subNode3 = get_node("SubNode2")
|
||||||
|
# 根节点查找法,会返回节点树从上到下找到的第一个节点
|
||||||
|
var subNode4 = get_tree().root.find_node("SubNode2", true, false)
|
||||||
|
print(currentNode1.name)
|
||||||
|
print(currentNode2.name)
|
||||||
|
print(parentNode1.name)
|
||||||
|
print(parentNode2.name)
|
||||||
|
print(subNode1.name)
|
||||||
|
print(subNode2.name)
|
||||||
|
print(subNode3.name)
|
||||||
|
print(subNode4.name)
|
|
@ -0,0 +1,23 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
|
||||||
|
func _enter_tree():
|
||||||
|
# When the node enters the Scene Tree, it becomes active
|
||||||
|
# and this function is called. Children nodes have not entered
|
||||||
|
# the active scene yet. In general, it's better to use _ready()
|
||||||
|
# for most cases.
|
||||||
|
print("sub node2 _enter_tree")
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
# This function is called after _enter_tree, but it ensures
|
||||||
|
# that all children nodes have also entered the Scene Tree,
|
||||||
|
# and became active.
|
||||||
|
print("sub node2 _ready")
|
||||||
|
|
||||||
|
func _exit_tree():
|
||||||
|
# When the node exits the Scene Tree, this function is called.
|
||||||
|
# Children nodes have all exited the Scene Tree at this point
|
||||||
|
# and all became inactive.
|
||||||
|
print("sub node2 _exit_tree")
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
extends Button
|
||||||
|
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
self.connect("pressed", Callable(self, "onButton"))
|
||||||
|
|
||||||
|
func onButton():
|
||||||
|
var yieldResult1 = await doSomething1()
|
||||||
|
|
||||||
|
var yieldResult2 = await doSomething2()
|
||||||
|
# 等待yieldResult2执行完毕
|
||||||
|
print("end")
|
||||||
|
|
||||||
|
|
||||||
|
func doSomething1():
|
||||||
|
await print("doSomething")
|
||||||
|
|
||||||
|
func doSomething2():
|
||||||
|
print(1)
|
||||||
|
await get_tree().create_timer(1).timeout
|
||||||
|
print(2)
|
||||||
|
await get_tree().create_timer(1).timeout
|
||||||
|
print(3)
|
||||||
|
await get_tree().create_timer(1).timeout
|
||||||
|
pass
|
|
@ -0,0 +1,22 @@
|
||||||
|
extends Button
|
||||||
|
|
||||||
|
|
||||||
|
# 自定义信号
|
||||||
|
signal mySignal(a, b)
|
||||||
|
|
||||||
|
# 发送信号
|
||||||
|
# emit_signal("mySignal", 1, 2)
|
||||||
|
# disconnect("mySignal", 1, 2)
|
||||||
|
|
||||||
|
# 类似于设计模式中的观察者
|
||||||
|
func _ready():
|
||||||
|
self.connect("mySignal", Callable(self, "onMySingalCallback"))
|
||||||
|
self.connect("pressed", Callable(self, "onButton"))
|
||||||
|
|
||||||
|
|
||||||
|
func onMySingalCallback(a, b):
|
||||||
|
print("a:" + str(a))
|
||||||
|
print("b:" + str(b))
|
||||||
|
|
||||||
|
func onButton():
|
||||||
|
emit_signal("mySignal", 1, 2)
|
|
@ -0,0 +1,16 @@
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
|
||||||
|
# 第一种信号接受方法,通过在场景中配置信号的接收方法
|
||||||
|
func _on_button_1_pressed():
|
||||||
|
print("hello button1")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# 第二种信号接受方法,通过代码控制信号的接受,更加的灵活,比较推荐方式
|
||||||
|
func _ready():
|
||||||
|
$Button2.connect("pressed", Callable(self, "onButton2"))
|
||||||
|
|
||||||
|
func onButton2():
|
||||||
|
print("button2 pressed")
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
[gd_scene load_steps=5 format=3 uid="uid://dbxj3ocgvec8"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scene/demo04_signal/script/signal.gd" id="1_dadg8"]
|
||||||
|
[ext_resource type="Script" path="res://scene/demo04_signal/script/mySignal.gd" id="2_lvqsi"]
|
||||||
|
[ext_resource type="Script" path="res://scene/demo04_signal/script/await.gd" id="3_4hptw"]
|
||||||
|
[ext_resource type="Script" path="res://scene/demo04_signal/thread.gd" id="4_r6xio"]
|
||||||
|
|
||||||
|
[node name="Node2D" type="Node2D"]
|
||||||
|
script = ExtResource("1_dadg8")
|
||||||
|
|
||||||
|
[node name="Button1" type="Button" parent="."]
|
||||||
|
offset_left = 126.0
|
||||||
|
offset_top = 62.0
|
||||||
|
offset_right = 240.0
|
||||||
|
offset_bottom = 109.0
|
||||||
|
text = "button1"
|
||||||
|
|
||||||
|
[node name="Button2" type="Button" parent="."]
|
||||||
|
offset_left = 394.0
|
||||||
|
offset_top = 62.0
|
||||||
|
offset_right = 485.0
|
||||||
|
offset_bottom = 111.0
|
||||||
|
text = "button2"
|
||||||
|
|
||||||
|
[node name="MySignal" type="Button" parent="."]
|
||||||
|
offset_left = 141.0
|
||||||
|
offset_top = 222.0
|
||||||
|
offset_right = 245.0
|
||||||
|
offset_bottom = 271.0
|
||||||
|
text = "mySignal"
|
||||||
|
script = ExtResource("2_lvqsi")
|
||||||
|
|
||||||
|
[node name="Await" type="Button" parent="."]
|
||||||
|
offset_left = 132.0
|
||||||
|
offset_top = 354.0
|
||||||
|
offset_right = 225.0
|
||||||
|
offset_bottom = 398.0
|
||||||
|
text = "await"
|
||||||
|
script = ExtResource("3_4hptw")
|
||||||
|
|
||||||
|
[node name="Thread" type="Button" parent="."]
|
||||||
|
offset_left = 141.0
|
||||||
|
offset_top = 497.0
|
||||||
|
offset_right = 235.0
|
||||||
|
offset_bottom = 545.0
|
||||||
|
text = "thread"
|
||||||
|
script = ExtResource("4_r6xio")
|
||||||
|
|
||||||
|
[connection signal="pressed" from="Button1" to="." method="_on_button_1_pressed"]
|
|
@ -0,0 +1,29 @@
|
||||||
|
extends Button
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
self.connect("pressed", Callable(self, "onButton2"))
|
||||||
|
|
||||||
|
func onButton2():
|
||||||
|
var myThread = Thread.new()
|
||||||
|
|
||||||
|
print("Create Thread Id: ", myThread)
|
||||||
|
print("Thread Active: ", myThread.is_alive())
|
||||||
|
|
||||||
|
myThread.start(Callable(self, "threadTest"))
|
||||||
|
|
||||||
|
print()
|
||||||
|
print("Thread Active: ", myThread.is_alive())
|
||||||
|
|
||||||
|
var waitForThread = myThread.wait_to_finish() # wait for our thread to finish before moving on
|
||||||
|
|
||||||
|
print()
|
||||||
|
print("Thread is Finished with result: ", waitForThread)
|
||||||
|
print("Thread Active: ", myThread.is_alive())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# 使用thread运行的函数必须有一个参数,要不然无法运行
|
||||||
|
func threadTest():
|
||||||
|
print("thread test start")
|
||||||
|
return 999
|
|
@ -0,0 +1,12 @@
|
||||||
|
[gd_scene load_steps=3 format=3 uid="uid://12um7dx1w0gp"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scene/demo05_scene_node/script/hero.gd" id="1_cqv88"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dwduwy3y2vipi" path="res://icon.svg" id="1_xf37n"]
|
||||||
|
|
||||||
|
[node name="Node2D" type="Node2D"]
|
||||||
|
position = Vector2(100, 100)
|
||||||
|
|
||||||
|
[node name="Hero" type="Sprite2D" parent="."]
|
||||||
|
position = Vector2(400, 200)
|
||||||
|
texture = ExtResource("1_xf37n")
|
||||||
|
script = ExtResource("1_cqv88")
|
|
@ -0,0 +1,87 @@
|
||||||
|
extends Sprite2D
|
||||||
|
|
||||||
|
const StringUtils = preload("res://zfoo/util/StringUtils.gd")
|
||||||
|
|
||||||
|
|
||||||
|
var gameWidth: int
|
||||||
|
var gameHeight: int
|
||||||
|
var spriteWidth: int
|
||||||
|
var spriteHeight: int
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func _enter_tree():
|
||||||
|
windowPositionTest()
|
||||||
|
#positionTest()
|
||||||
|
#textureTest()
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
func _physics_process(delta):
|
||||||
|
setupGameWindow()
|
||||||
|
setupSprite()
|
||||||
|
positionTopCenter()
|
||||||
|
pass
|
||||||
|
|
||||||
|
# 屏幕坐标系
|
||||||
|
func windowPositionTest():
|
||||||
|
# 设置游戏屏幕的位置
|
||||||
|
# DisplayServer.window_set_size(Vector2(100, 100))
|
||||||
|
# DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
|
||||||
|
print(StringUtils.format("屏幕大小[{}]", [DisplayServer.window_get_size()]))
|
||||||
|
print(StringUtils.format("屏幕位置[{}]", [DisplayServer.window_get_position()]))
|
||||||
|
pass
|
||||||
|
|
||||||
|
# 坐标点测试用例
|
||||||
|
func positionTest():
|
||||||
|
print(position)
|
||||||
|
print(global_position)
|
||||||
|
print(to_global(position))
|
||||||
|
print(to_local(global_position))
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
func setupGameWindow():
|
||||||
|
gameWidth = DisplayServer.window_get_size().x
|
||||||
|
gameHeight = DisplayServer.window_get_size().y
|
||||||
|
|
||||||
|
func setupSprite():
|
||||||
|
spriteWidth = texture.get_width()
|
||||||
|
spriteHeight = texture.get_height()
|
||||||
|
|
||||||
|
|
||||||
|
func positionTopCenter() -> void:
|
||||||
|
#get_parent().position.x = 0
|
||||||
|
#get_parent().position.y = 0
|
||||||
|
#self.global_position
|
||||||
|
self.position.x = gameWidth / 2
|
||||||
|
self.position.y = spriteHeight / 2
|
||||||
|
|
||||||
|
func positionCenter() -> void:
|
||||||
|
self.global_position.x = gameWidth / 2
|
||||||
|
self.global_position.y = gameHeight / 2
|
||||||
|
|
||||||
|
func positionBottomCenter() -> void:
|
||||||
|
self.global_position.x = gameWidth / 2
|
||||||
|
self.global_position.y = gameHeight - spriteHeight / 2
|
||||||
|
|
||||||
|
func positionLeftCenter() -> void:
|
||||||
|
self.global_position.x = spriteWidth / 2
|
||||||
|
self.global_position.y = gameHeight / 2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# 纹理测试用例
|
||||||
|
func textureTest():
|
||||||
|
var texture = get_texture()
|
||||||
|
var image = texture.get_image()
|
||||||
|
print(offset)
|
||||||
|
print("texture type: ", texture)
|
||||||
|
print("height: ", texture.get_height())
|
||||||
|
print("width: ", texture.get_width())
|
||||||
|
|
||||||
|
# 无法直接编辑图片
|
||||||
|
image.shrink_x2()
|
||||||
|
#这样做会破坏项目的资源,使资源变得混乱
|
||||||
|
image.save_png("D:\\newImage.png")
|
||||||
|
pass
|
|
@ -0,0 +1,11 @@
|
||||||
|
[gd_scene load_steps=3 format=3 uid="uid://c8r1o5j3f8r80"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dwduwy3y2vipi" path="res://icon.svg" id="1_qmgyw"]
|
||||||
|
[ext_resource type="Script" path="res://scene/demo06_move/script/move.gd" id="2_uwquj"]
|
||||||
|
|
||||||
|
[node name="Node2D" type="Node2D"]
|
||||||
|
|
||||||
|
[node name="HeroMove" type="Sprite2D" parent="."]
|
||||||
|
position = Vector2(375, 221)
|
||||||
|
texture = ExtResource("1_qmgyw")
|
||||||
|
script = ExtResource("2_uwquj")
|
|
@ -0,0 +1,31 @@
|
||||||
|
extends Sprite2D
|
||||||
|
|
||||||
|
|
||||||
|
# How fast the player will move (pixels/sec).
|
||||||
|
@export var speed = 400
|
||||||
|
# Size of the game window.
|
||||||
|
var screen_size
|
||||||
|
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
screen_size = get_viewport_rect().size
|
||||||
|
|
||||||
|
|
||||||
|
func _process(delta):
|
||||||
|
var velocity = Vector2.ZERO # The player's movement vector.
|
||||||
|
if Input.is_action_pressed("move_right"):
|
||||||
|
velocity.x += 1
|
||||||
|
if Input.is_action_pressed("move_left"):
|
||||||
|
velocity.x -= 1
|
||||||
|
if Input.is_action_pressed("move_down"):
|
||||||
|
velocity.y += 1
|
||||||
|
if Input.is_action_pressed("move_up"):
|
||||||
|
velocity.y -= 1
|
||||||
|
|
||||||
|
if velocity.length() <= 0:
|
||||||
|
return
|
||||||
|
|
||||||
|
velocity = velocity.normalized() * speed
|
||||||
|
position += velocity * delta
|
||||||
|
position.x = clamp(position.x, 0, screen_size.x)
|
||||||
|
position.y = clamp(position.y, 0, screen_size.y)
|
|
@ -0,0 +1,42 @@
|
||||||
|
[gd_scene load_steps=5 format=3 uid="uid://c31rpyh5mxyn2"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dwduwy3y2vipi" path="res://icon.svg" id="1_dr3sv"]
|
||||||
|
[ext_resource type="Script" path="res://scene/demo07_collision/script/characterBody2D.gd" id="2_dhi5g"]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_o1364"]
|
||||||
|
size = Vector2(128, 128)
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_a33y2"]
|
||||||
|
size = Vector2(130, 126)
|
||||||
|
|
||||||
|
[node name="Node2D" type="Node2D"]
|
||||||
|
|
||||||
|
[node name="RigidBody2D" type="RigidBody2D" parent="."]
|
||||||
|
position = Vector2(775, 89)
|
||||||
|
metadata/_edit_group_ = true
|
||||||
|
|
||||||
|
[node name="Sprite" type="Sprite2D" parent="RigidBody2D"]
|
||||||
|
texture = ExtResource("1_dr3sv")
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D"]
|
||||||
|
shape = SubResource("RectangleShape2D_o1364")
|
||||||
|
|
||||||
|
[node name="CharacterBody2D" type="CharacterBody2D" parent="."]
|
||||||
|
position = Vector2(417, 201)
|
||||||
|
script = ExtResource("2_dhi5g")
|
||||||
|
metadata/_edit_group_ = true
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="CharacterBody2D"]
|
||||||
|
texture = ExtResource("1_dr3sv")
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="CharacterBody2D"]
|
||||||
|
shape = SubResource("RectangleShape2D_a33y2")
|
||||||
|
|
||||||
|
[node name="StaticBody2D" type="StaticBody2D" parent="."]
|
||||||
|
|
||||||
|
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="StaticBody2D"]
|
||||||
|
polygon = PackedVector2Array(61, 268, 60, 607, 1043, 615, 1051, 216, 995, 220, 691, 547, 133, 542, 137, 270)
|
||||||
|
|
||||||
|
[node name="Polygon2D" type="Polygon2D" parent="StaticBody2D"]
|
||||||
|
color = Color(0.972549, 0.843137, 0.85098, 1)
|
||||||
|
polygon = PackedVector2Array(62, 269, 58, 606, 1041, 614, 1050, 214, 992, 220, 688, 549, 132, 541, 134, 269)
|
|
@ -0,0 +1,30 @@
|
||||||
|
extends CharacterBody2D
|
||||||
|
|
||||||
|
|
||||||
|
# How fast the player will move (pixels/sec).
|
||||||
|
@export var speed = 400
|
||||||
|
# Size of the game window.
|
||||||
|
var screen_size
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
screen_size = get_viewport_rect().size
|
||||||
|
|
||||||
|
func _physics_process(delta):
|
||||||
|
var velocity = Vector2.ZERO # The player's movement vector.
|
||||||
|
if Input.is_action_pressed("move_right"):
|
||||||
|
velocity.x += 1
|
||||||
|
if Input.is_action_pressed("move_left"):
|
||||||
|
velocity.x -= 1
|
||||||
|
if Input.is_action_pressed("move_down"):
|
||||||
|
velocity.y += 1
|
||||||
|
if Input.is_action_pressed("move_up"):
|
||||||
|
velocity.y -= 1
|
||||||
|
|
||||||
|
if velocity.length() <= 0:
|
||||||
|
return
|
||||||
|
|
||||||
|
velocity = velocity.normalized() * speed
|
||||||
|
# false这个选项参数看意思是把无限惯性关了,这个关了之后就不会向碰撞的刚体施加作用力,需要你自己去写
|
||||||
|
var info: KinematicCollision2D = move_and_collide(velocity * delta)
|
||||||
|
if info != null:
|
||||||
|
print(info.get_collider())
|
After Width: | Height: | Size: 116 KiB |
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://b2kiyycgqh3yv"
|
||||||
|
path="res://.godot/imported/Grasslands.png-0a6ab77180659e2e9d9a66e9712b5531.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://scene/demo08_path/image/Grasslands.png"
|
||||||
|
dest_files=["res://.godot/imported/Grasslands.png-0a6ab77180659e2e9d9a66e9712b5531.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
After Width: | Height: | Size: 74 KiB |
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://cdn4iyiywnm2f"
|
||||||
|
path="res://.godot/imported/Robi.png-6434141f148b69577a114e3ae4050d96.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://scene/demo08_path/image/Robi.png"
|
||||||
|
dest_files=["res://.godot/imported/Robi.png-6434141f148b69577a114e3ae4050d96.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
|
@ -0,0 +1,30 @@
|
||||||
|
[gd_scene load_steps=5 format=3 uid="uid://dbh46yr5q0cve"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dwduwy3y2vipi" path="res://icon.svg" id="2_316ts"]
|
||||||
|
[ext_resource type="Script" path="res://scene/demo08_path/script/pathFollow2D.gd" id="3_pk2oc"]
|
||||||
|
[ext_resource type="Script" path="res://scene/demo08_path/script/player.gd" id="3_t2423"]
|
||||||
|
|
||||||
|
[sub_resource type="Curve2D" id="Curve2D_tde6t"]
|
||||||
|
_data = {
|
||||||
|
"points": PackedVector2Array(0, 0, 0, 0, 54, 290, 0, 0, 0, 0, 185, 163, 0, 0, 0, 0, 365, 341, 0, 0, 0, 0, 486, 147, 0, 0, 0, 0, 554, 404, 0, 0, 0, 0, 598, 561, 0, 0, 0, 0, 711, 599, 0, 0, 0, 0, 785, 259, 0, 0, 0, 0, 961, 55, 0, 0, 0, 0, 1016, 257, 0, 0, 0, 0, 961, 370, 0, 0, 0, 0, 1014, 563)
|
||||||
|
}
|
||||||
|
point_count = 12
|
||||||
|
|
||||||
|
[node name="Node2D" type="Node2D"]
|
||||||
|
|
||||||
|
[node name="Player" type="Sprite2D" parent="."]
|
||||||
|
position = Vector2(54, 290)
|
||||||
|
rotation = -0.769896
|
||||||
|
texture = ExtResource("2_316ts")
|
||||||
|
script = ExtResource("3_t2423")
|
||||||
|
|
||||||
|
[node name="Path2D" type="Path2D" parent="."]
|
||||||
|
curve = SubResource("Curve2D_tde6t")
|
||||||
|
|
||||||
|
[node name="PathFollow2D" type="PathFollow2D" parent="Path2D"]
|
||||||
|
position = Vector2(54, 290)
|
||||||
|
rotation = -0.769896
|
||||||
|
script = ExtResource("3_pk2oc")
|
||||||
|
|
||||||
|
[node name="RemoteTransform2D" type="RemoteTransform2D" parent="Path2D/PathFollow2D"]
|
||||||
|
remote_path = NodePath("../../../Player")
|
|
@ -0,0 +1,22 @@
|
||||||
|
[gd_scene load_steps=5 format=3 uid="uid://3ewt17t0c0sv"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scene/demo08_path/script/line2D.gd" id="1_mascd"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dwduwy3y2vipi" path="res://icon.svg" id="2_28vki"]
|
||||||
|
[ext_resource type="Script" path="res://scene/demo08_path/script/player.gd" id="3_xgm4i"]
|
||||||
|
|
||||||
|
[sub_resource type="Curve" id="Curve_y6lw1"]
|
||||||
|
_data = [Vector2(0.00985222, 0.0242664), 0.0, 0.0, 0, 0, Vector2(0.342365, 0.500296), 0.0, 0.0, 0, 0, Vector2(0.635468, 0.669426), 0.0, 0.0, 0, 0, Vector2(0.775862, 0.857776), 0.0, 0.0, 0, 0, Vector2(0.997537, 1), 0.0, 0.0, 0, 0]
|
||||||
|
point_count = 5
|
||||||
|
|
||||||
|
[node name="Node2D" type="Node2D"]
|
||||||
|
|
||||||
|
[node name="Line2D" type="Line2D" parent="."]
|
||||||
|
width = 100.0
|
||||||
|
width_curve = SubResource("Curve_y6lw1")
|
||||||
|
default_color = Color(1, 1, 0.0627451, 1)
|
||||||
|
script = ExtResource("1_mascd")
|
||||||
|
|
||||||
|
[node name="Player" type="Sprite2D" parent="."]
|
||||||
|
position = Vector2(205, 110)
|
||||||
|
texture = ExtResource("2_28vki")
|
||||||
|
script = ExtResource("3_xgm4i")
|
|
@ -0,0 +1,24 @@
|
||||||
|
extends Line2D
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
#add_point(Vector2(100, 100))
|
||||||
|
#add_point(Vector2(100, 200))
|
||||||
|
#add_point(Vector2(200, 200))
|
||||||
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(delta):
|
||||||
|
var player = get_parent().find_child("Player")
|
||||||
|
var position = player.position
|
||||||
|
add_point(position)
|
||||||
|
if (get_point_count() >= 20):
|
||||||
|
remove_point(0)
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
func pointTest():
|
||||||
|
add_point(Vector2(100, 100))
|
||||||
|
add_point(Vector2(100, 200))
|
||||||
|
add_point(Vector2(200, 200))
|
||||||
|
pass
|
|
@ -0,0 +1,5 @@
|
||||||
|
extends PathFollow2D
|
||||||
|
|
||||||
|
|
||||||
|
func _process(delta):
|
||||||
|
progress += 8
|
|
@ -0,0 +1,31 @@
|
||||||
|
extends Sprite2D
|
||||||
|
|
||||||
|
|
||||||
|
# How fast the player will move (pixels/sec).
|
||||||
|
@export var speed = 400
|
||||||
|
# Size of the game window.
|
||||||
|
var screen_size
|
||||||
|
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
screen_size = get_viewport_rect().size
|
||||||
|
|
||||||
|
|
||||||
|
func _process(delta):
|
||||||
|
var velocity = Vector2.ZERO # The player's movement vector.
|
||||||
|
if Input.is_action_pressed("move_right"):
|
||||||
|
velocity.x += 1
|
||||||
|
if Input.is_action_pressed("move_left"):
|
||||||
|
velocity.x -= 1
|
||||||
|
if Input.is_action_pressed("move_down"):
|
||||||
|
velocity.y += 1
|
||||||
|
if Input.is_action_pressed("move_up"):
|
||||||
|
velocity.y -= 1
|
||||||
|
|
||||||
|
if velocity.length() <= 0:
|
||||||
|
return
|
||||||
|
|
||||||
|
velocity = velocity.normalized() * speed
|
||||||
|
position += velocity * delta
|
||||||
|
position.x = clamp(position.x, 0, screen_size.x)
|
||||||
|
position.y = clamp(position.y, 0, screen_size.y)
|
|
@ -0,0 +1,31 @@
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
|
||||||
|
@onready var nav_2d : NavigationAgent2D = $Player/NavigationAgent2D
|
||||||
|
@onready var player : CharacterBody2D = $Player
|
||||||
|
@onready var line2D : Line2D = $Line2D
|
||||||
|
|
||||||
|
var speed = 250
|
||||||
|
|
||||||
|
func _physics_process(delta):
|
||||||
|
if nav_2d.is_navigation_finished() || nav_2d.get_final_position() == Vector2.ZERO:
|
||||||
|
return
|
||||||
|
|
||||||
|
var next_location = nav_2d.get_next_path_position()
|
||||||
|
var direction = player.global_position.direction_to(next_location)
|
||||||
|
|
||||||
|
nav_2d.set_velocity(direction * speed)
|
||||||
|
player.velocity = direction * speed
|
||||||
|
player.move_and_slide()
|
||||||
|
|
||||||
|
func _unhandled_input(event: InputEvent) -> void:
|
||||||
|
if not event is InputEventMouseButton:
|
||||||
|
return
|
||||||
|
|
||||||
|
var playerPosition = player.get_global_position()
|
||||||
|
var mousePosition = event.get_global_position()
|
||||||
|
nav_2d.set_target_position(mousePosition)
|
||||||
|
nav_2d.get_next_path_position()
|
||||||
|
var navPath = nav_2d.get_current_navigation_path()
|
||||||
|
line2D.points = navPath
|
||||||
|
|
|
@ -0,0 +1,149 @@
|
||||||
|
[gd_scene load_steps=9 format=3 uid="uid://b0dm0cogxc3y6"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scene/demo08_path/script/tile.gd" id="1_6iolp"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://b2kiyycgqh3yv" path="res://scene/demo08_path/image/Grasslands.png" id="2_4p2ab"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://cdn4iyiywnm2f" path="res://scene/demo08_path/image/Robi.png" id="3_3q3se"]
|
||||||
|
|
||||||
|
[sub_resource type="NavigationPolygon" id="NavigationPolygon_5gwiy"]
|
||||||
|
vertices = PackedVector2Array(40, 40, -40, 40, -40, -40, 40, -40)
|
||||||
|
polygons = Array[PackedInt32Array]([PackedInt32Array(0, 1, 2, 3)])
|
||||||
|
outlines = Array[PackedVector2Array]([PackedVector2Array(-40, -40, 40, -40, 40, 40, -40, 40)])
|
||||||
|
source_geometry_group_name = &"navigation_polygon_source_group"
|
||||||
|
agent_radius = 0.0
|
||||||
|
|
||||||
|
[sub_resource type="NavigationPolygon" id="NavigationPolygon_3ksr3"]
|
||||||
|
vertices = PackedVector2Array(40, 40, -40, 40, -40, -40, 40, -40)
|
||||||
|
polygons = Array[PackedInt32Array]([PackedInt32Array(0, 1, 2, 3)])
|
||||||
|
outlines = Array[PackedVector2Array]([PackedVector2Array(-40, -40, 40, -40, 40, 40, -40, 40)])
|
||||||
|
source_geometry_group_name = &"navigation_polygon_source_group"
|
||||||
|
agent_radius = 0.0
|
||||||
|
|
||||||
|
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_0pcpq"]
|
||||||
|
texture = ExtResource("2_4p2ab")
|
||||||
|
texture_region_size = Vector2i(80, 80)
|
||||||
|
0:0/0 = 0
|
||||||
|
0:0/0/physics_layer_0/linear_velocity = Vector2(0, 0)
|
||||||
|
0:0/0/physics_layer_0/angular_velocity = 0.0
|
||||||
|
0:0/0/navigation_layer_0/polygon = SubResource("NavigationPolygon_5gwiy")
|
||||||
|
1:0/0 = 0
|
||||||
|
1:0/0/physics_layer_0/linear_velocity = Vector2(0, 0)
|
||||||
|
1:0/0/physics_layer_0/angular_velocity = 0.0
|
||||||
|
1:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-40, -40, 40, -40, 40, 40, -40, 40)
|
||||||
|
2:0/0 = 0
|
||||||
|
2:0/0/physics_layer_0/linear_velocity = Vector2(0, 0)
|
||||||
|
2:0/0/physics_layer_0/angular_velocity = 0.0
|
||||||
|
2:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-40, -40, 40, -40, 40, 40, -40, 40)
|
||||||
|
3:0/0 = 0
|
||||||
|
3:0/0/physics_layer_0/linear_velocity = Vector2(0, 0)
|
||||||
|
3:0/0/physics_layer_0/angular_velocity = 0.0
|
||||||
|
3:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-40, -40, 40, -40, 40, 40, -40, 40)
|
||||||
|
4:0/0 = 0
|
||||||
|
4:0/0/physics_layer_0/linear_velocity = Vector2(0, 0)
|
||||||
|
4:0/0/physics_layer_0/angular_velocity = 0.0
|
||||||
|
4:0/0/physics_layer_0/polygon_0/points = PackedVector2Array(-40, -40, 40, -40, 40, 40, -40, 40)
|
||||||
|
0:1/0 = 0
|
||||||
|
0:1/0/physics_layer_0/linear_velocity = Vector2(0, 0)
|
||||||
|
0:1/0/physics_layer_0/angular_velocity = 0.0
|
||||||
|
0:1/0/navigation_layer_0/polygon = SubResource("NavigationPolygon_5gwiy")
|
||||||
|
1:1/0 = 0
|
||||||
|
1:1/0/physics_layer_0/linear_velocity = Vector2(0, 0)
|
||||||
|
1:1/0/physics_layer_0/angular_velocity = 0.0
|
||||||
|
1:1/0/navigation_layer_0/polygon = SubResource("NavigationPolygon_5gwiy")
|
||||||
|
2:1/0 = 0
|
||||||
|
2:1/0/physics_layer_0/linear_velocity = Vector2(0, 0)
|
||||||
|
2:1/0/physics_layer_0/angular_velocity = 0.0
|
||||||
|
2:1/0/navigation_layer_0/polygon = SubResource("NavigationPolygon_5gwiy")
|
||||||
|
3:1/0 = 0
|
||||||
|
3:1/0/physics_layer_0/linear_velocity = Vector2(0, 0)
|
||||||
|
3:1/0/physics_layer_0/angular_velocity = 0.0
|
||||||
|
3:1/0/navigation_layer_0/polygon = SubResource("NavigationPolygon_5gwiy")
|
||||||
|
4:1/0 = 0
|
||||||
|
4:1/0/physics_layer_0/linear_velocity = Vector2(0, 0)
|
||||||
|
4:1/0/physics_layer_0/angular_velocity = 0.0
|
||||||
|
4:1/0/navigation_layer_0/polygon = SubResource("NavigationPolygon_5gwiy")
|
||||||
|
5:1/0 = 0
|
||||||
|
5:1/0/physics_layer_0/linear_velocity = Vector2(0, 0)
|
||||||
|
5:1/0/physics_layer_0/angular_velocity = 0.0
|
||||||
|
5:1/0/navigation_layer_0/polygon = SubResource("NavigationPolygon_5gwiy")
|
||||||
|
6:1/0 = 0
|
||||||
|
6:1/0/physics_layer_0/linear_velocity = Vector2(0, 0)
|
||||||
|
6:1/0/physics_layer_0/angular_velocity = 0.0
|
||||||
|
6:1/0/navigation_layer_0/polygon = SubResource("NavigationPolygon_5gwiy")
|
||||||
|
0:2/0 = 0
|
||||||
|
0:2/0/physics_layer_0/linear_velocity = Vector2(0, 0)
|
||||||
|
0:2/0/physics_layer_0/angular_velocity = 0.0
|
||||||
|
0:2/0/navigation_layer_0/polygon = SubResource("NavigationPolygon_3ksr3")
|
||||||
|
1:2/0 = 0
|
||||||
|
1:2/0/physics_layer_0/linear_velocity = Vector2(0, 0)
|
||||||
|
1:2/0/physics_layer_0/angular_velocity = 0.0
|
||||||
|
1:2/0/navigation_layer_0/polygon = SubResource("NavigationPolygon_3ksr3")
|
||||||
|
2:2/0 = 0
|
||||||
|
2:2/0/physics_layer_0/linear_velocity = Vector2(0, 0)
|
||||||
|
2:2/0/physics_layer_0/angular_velocity = 0.0
|
||||||
|
2:2/0/navigation_layer_0/polygon = SubResource("NavigationPolygon_3ksr3")
|
||||||
|
3:2/0 = 0
|
||||||
|
3:2/0/physics_layer_0/linear_velocity = Vector2(0, 0)
|
||||||
|
3:2/0/physics_layer_0/angular_velocity = 0.0
|
||||||
|
3:2/0/navigation_layer_0/polygon = SubResource("NavigationPolygon_3ksr3")
|
||||||
|
4:2/0 = 0
|
||||||
|
4:2/0/physics_layer_0/linear_velocity = Vector2(0, 0)
|
||||||
|
4:2/0/physics_layer_0/angular_velocity = 0.0
|
||||||
|
4:2/0/navigation_layer_0/polygon = SubResource("NavigationPolygon_3ksr3")
|
||||||
|
5:2/0 = 0
|
||||||
|
5:2/0/physics_layer_0/linear_velocity = Vector2(0, 0)
|
||||||
|
5:2/0/physics_layer_0/angular_velocity = 0.0
|
||||||
|
5:2/0/navigation_layer_0/polygon = SubResource("NavigationPolygon_3ksr3")
|
||||||
|
0:3/0 = 0
|
||||||
|
0:3/0/physics_layer_0/linear_velocity = Vector2(0, 0)
|
||||||
|
0:3/0/physics_layer_0/angular_velocity = 0.0
|
||||||
|
0:3/0/navigation_layer_0/polygon = SubResource("NavigationPolygon_3ksr3")
|
||||||
|
1:3/0 = 0
|
||||||
|
1:3/0/physics_layer_0/linear_velocity = Vector2(0, 0)
|
||||||
|
1:3/0/physics_layer_0/angular_velocity = 0.0
|
||||||
|
1:3/0/navigation_layer_0/polygon = SubResource("NavigationPolygon_3ksr3")
|
||||||
|
2:3/0 = 0
|
||||||
|
2:3/0/physics_layer_0/linear_velocity = Vector2(0, 0)
|
||||||
|
2:3/0/physics_layer_0/angular_velocity = 0.0
|
||||||
|
2:3/0/navigation_layer_0/polygon = SubResource("NavigationPolygon_3ksr3")
|
||||||
|
3:3/0 = 0
|
||||||
|
3:3/0/physics_layer_0/linear_velocity = Vector2(0, 0)
|
||||||
|
3:3/0/physics_layer_0/angular_velocity = 0.0
|
||||||
|
3:3/0/navigation_layer_0/polygon = SubResource("NavigationPolygon_3ksr3")
|
||||||
|
4:3/0 = 0
|
||||||
|
4:3/0/physics_layer_0/linear_velocity = Vector2(0, 0)
|
||||||
|
4:3/0/physics_layer_0/angular_velocity = 0.0
|
||||||
|
4:3/0/navigation_layer_0/polygon = SubResource("NavigationPolygon_3ksr3")
|
||||||
|
5:3/0 = 0
|
||||||
|
5:3/0/physics_layer_0/linear_velocity = Vector2(0, 0)
|
||||||
|
5:3/0/physics_layer_0/angular_velocity = 0.0
|
||||||
|
5:3/0/navigation_layer_0/polygon = SubResource("NavigationPolygon_3ksr3")
|
||||||
|
|
||||||
|
[sub_resource type="TileSet" id="TileSet_0evj0"]
|
||||||
|
tile_size = Vector2i(80, 80)
|
||||||
|
physics_layer_0/collision_layer = 1
|
||||||
|
navigation_layer_0/layers = 1
|
||||||
|
sources/0 = SubResource("TileSetAtlasSource_0pcpq")
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_82yhd"]
|
||||||
|
size = Vector2(18, 16)
|
||||||
|
|
||||||
|
[node name="Node2D" type="Node2D"]
|
||||||
|
script = ExtResource("1_6iolp")
|
||||||
|
|
||||||
|
[node name="TileMap" type="TileMap" parent="."]
|
||||||
|
tile_set = SubResource("TileSet_0evj0")
|
||||||
|
format = 2
|
||||||
|
layer_0/tile_data = PackedInt32Array(0, 0, 0, 1, 0, 0, 2, 0, 0, 65537, 0, 0, 65538, 0, 0, 131074, 0, 0, 131075, 65536, 0, 3, 65536, 0, 4, 0, 0, 65540, 0, 0, 5, 0, 0, 65541, 0, 0, 131077, 0, 0, 131078, 0, 0, 6, 0, 0, 65542, 0, 0, 131079, 0, 0, 196609, 0, 0, 196610, 0, 0, 196611, 65536, 0, 196612, 0, 0, 196613, 0, 0, 262149, 0, 0, 262150, 131072, 0, 327686, 131072, 0, 327681, 0, 0, 327682, 0, 0, 393218, 0, 0, 393219, 0, 0, 458755, 0, 0, 458756, 0, 0, 327684, 0, 0, 327685, 0, 0, 393222, 131072, 0, 393223, 0, 0, 458760, 0, 0, 196615, 0, 0, 262152, 0, 0, 327689, 196608, 0, 393226, 0, 0, 458763, 262144, 0, 65536, 0, 0, 131072, 0, 0, 196608, 0, 0, 262144, 0, 0, 327680, 0, 0, 393216, 0, 0, 458752, 0, 0, 524288, 0, 0, 131073, 0, 0, 262145, 0, 0, 393217, 0, 0, 458753, 0, 0, 524289, 0, 0, 262146, 0, 0, 458754, 0, 0, 524290, 0, 0, 65539, 65536, 0, 262147, 65536, 0, 327683, 65536, 0, 524291, 0, 0, 131076, 0, 0, 262148, 0, 0, 393220, 0, 0, 524292, 0, 0, 393221, 0, 0, 458757, 0, 0, 524293, 0, 0, 196614, 131072, 0, 458758, 131072, 0, 524294, 131072, 0, 7, 0, 0, 65543, 0, 0, 262151, 0, 0, 327687, 0, 0, 458759, 0, 0, 524295, 0, 0, 8, 0, 0, 65544, 0, 0, 131080, 0, 0, 196616, 0, 0, 327688, 0, 0, 393224, 0, 0, 524296, 0, 0, 9, 196608, 0, 65545, 196608, 0, 131081, 196608, 0, 196617, 196608, 0, 262153, 196608, 0, 393225, 0, 0, 458761, 0, 0, 524297, 0, 0, 10, 0, 0, 65546, 0, 0, 131082, 0, 0, 196618, 0, 0, 262154, 0, 0, 327690, 0, 0, 458762, 0, 0, 524298, 0, 0, 11, 0, 0, 65547, 0, 0, 131083, 0, 0, 196619, 262144, 0, 262155, 65536, 2, 327691, 65536, 2, 393227, 65536, 2, 524299, 0, 0, 12, 0, 0, 65548, 0, 0, 131084, 0, 0, 196620, 262144, 0, 262156, 65536, 2, 327692, 65536, 2, 393228, 65536, 2, 458764, 262144, 0, 524300, 0, 0, 13, 0, 0, 65549, 0, 0, 131085, 0, 0, 196621, 262144, 0, 262157, 65536, 2, 327693, 65536, 2, 393229, 65536, 2, 458765, 262144, 0, 524301, 0, 0, 14, 0, 0, 65550, 0, 0, 131086, 0, 0, 196622, 262144, 0, 262158, 65536, 2, 327694, 65536, 2, 393230, 65536, 2, 458766, 262144, 0, 524302, 0, 0)
|
||||||
|
|
||||||
|
[node name="Line2D" type="Line2D" parent="."]
|
||||||
|
|
||||||
|
[node name="Player" type="CharacterBody2D" parent="."]
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="Player"]
|
||||||
|
scale = Vector2(0.205279, 0.205279)
|
||||||
|
texture = ExtResource("3_3q3se")
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Player"]
|
||||||
|
shape = SubResource("RectangleShape2D_82yhd")
|
||||||
|
|
||||||
|
[node name="NavigationAgent2D" type="NavigationAgent2D" parent="Player"]
|
|
@ -0,0 +1,33 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="font_data_dynamic"
|
||||||
|
type="FontFile"
|
||||||
|
uid="uid://dy4h5b6wj8n5o"
|
||||||
|
path="res://.godot/imported/BarlowCondensed-Bold.ttf-c54c973ad70fe2834c825f6140d0601a.fontdata"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://scene/demo09_canvas/BarlowCondensed-Bold.ttf"
|
||||||
|
dest_files=["res://.godot/imported/BarlowCondensed-Bold.ttf-c54c973ad70fe2834c825f6140d0601a.fontdata"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
Rendering=null
|
||||||
|
antialiasing=1
|
||||||
|
generate_mipmaps=false
|
||||||
|
multichannel_signed_distance_field=false
|
||||||
|
msdf_pixel_range=8
|
||||||
|
msdf_size=48
|
||||||
|
allow_system_fallback=true
|
||||||
|
force_autohinter=false
|
||||||
|
hinting=1
|
||||||
|
subpixel_positioning=1
|
||||||
|
oversampling=0.0
|
||||||
|
Fallbacks=null
|
||||||
|
fallbacks=[]
|
||||||
|
Compress=null
|
||||||
|
compress=true
|
||||||
|
preload=[]
|
||||||
|
language_support={}
|
||||||
|
script_support={}
|
||||||
|
opentype_features={}
|
|
@ -0,0 +1,6 @@
|
||||||
|
[gd_scene load_steps=2 format=3 uid="uid://bf4xggr34p3fc"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scene/demo09_canvas/script/canvas.gd" id="1_h0p4c"]
|
||||||
|
|
||||||
|
[node name="Node2D" type="Node2D"]
|
||||||
|
script = ExtResource("1_h0p4c")
|
|
@ -0,0 +1,49 @@
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
|
||||||
|
var whiteColor: Color = Color(1,1,1,1)
|
||||||
|
|
||||||
|
# For Draw_Circle
|
||||||
|
var circleRadius: float = 10
|
||||||
|
|
||||||
|
# For Draw_Multiline
|
||||||
|
var array: Array = [Vector2(200,300),Vector2(300,400),Vector2(300,400),Vector2(400,300)]
|
||||||
|
|
||||||
|
var multiLine: PackedVector2Array = PackedVector2Array(array)
|
||||||
|
|
||||||
|
# For Draw_Rect
|
||||||
|
var rect: Rect2 = Rect2(200.0,300.0, 200.0,200.0)
|
||||||
|
|
||||||
|
# For Draw_Primitive
|
||||||
|
var pointsArray: PackedVector2Array = PackedVector2Array([Vector2(700,100),Vector2(800,150),Vector2(900,100)])
|
||||||
|
var colorArray: PackedColorArray = PackedColorArray([Color(1,1,1,1),Color(1,1,1,1),Color(1,1,1,1)])
|
||||||
|
|
||||||
|
# For Draw_String
|
||||||
|
|
||||||
|
var dynamic_font = preload("res://scene/demo09_canvas/BarlowCondensed-Bold.ttf")
|
||||||
|
|
||||||
|
var texture: Texture = null
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
texture = load("res://icon.svg")
|
||||||
|
|
||||||
|
var count = 0
|
||||||
|
|
||||||
|
func _draw() -> void:
|
||||||
|
print("start drawing")
|
||||||
|
draw_circle(Vector2(100,100), circleRadius, whiteColor)
|
||||||
|
draw_line(Vector2(0,0),Vector2(100,100),whiteColor)
|
||||||
|
draw_multiline(multiLine, whiteColor)
|
||||||
|
draw_rect(rect, whiteColor, false) # filled is false
|
||||||
|
draw_primitive(pointsArray,colorArray, pointsArray)
|
||||||
|
draw_string(dynamic_font, Vector2(600,500), 'I draw good!')
|
||||||
|
if count >= 90:
|
||||||
|
draw_texture(texture, Vector2(400,400))
|
||||||
|
# For Draw_String
|
||||||
|
|
||||||
|
|
||||||
|
func _process(delta):
|
||||||
|
count += 1
|
||||||
|
if count == 90:
|
||||||
|
# draw_texture(texture, Vector2(400,400))
|
||||||
|
queue_redraw()
|
|
@ -0,0 +1,182 @@
|
||||||
|
[gd_scene load_steps=20 format=3 uid="uid://0m7gwx6kggro"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://do4b3hpflfwi1" path="res://scene/demo10_animation/image/player.png" id="1_s2byb"]
|
||||||
|
[ext_resource type="Script" path="res://scene/demo10_animation/script/timer_animation.gd" id="2_moa6m"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dwduwy3y2vipi" path="res://icon.svg" id="3_eunem"]
|
||||||
|
[ext_resource type="Script" path="res://scene/demo10_animation/script/tween_animation.gd" id="4_ih3vw"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://cdcpww682ywng" path="res://scene/demo10_animation/image/run-1.png" id="5_vwedp"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://chsdpv60jcl58" path="res://scene/demo10_animation/image/run-2.png" id="6_2xnpv"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dwbbk8etvj2nd" path="res://scene/demo10_animation/image/run-3.png" id="7_ev8ek"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://bt3r7fvye3ctd" path="res://scene/demo10_animation/image/run-4.png" id="8_puipc"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://d1gtcor5h4js5" path="res://scene/demo10_animation/image/run-5.png" id="9_i5m5b"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dmh8knrjxc8f1" path="res://scene/demo10_animation/image/run-6.png" id="10_6ea7i"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://gs5kwcor331o" path="res://scene/demo10_animation/image/run-7.png" id="11_shxe3"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://c2eu47l1mjehx" path="res://scene/demo10_animation/image/run-8.png" id="12_7ilo7"]
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_hax8x"]
|
||||||
|
resource_name = "player"
|
||||||
|
length = 5.0
|
||||||
|
loop_mode = 1
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Sprite2D:position")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 1, 1.6, 2.4, 3.6, 5),
|
||||||
|
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Vector2(89, 266), Vector2(263, 211), Vector2(398, 174), Vector2(635, 258), Vector2(978, 391), Vector2(1106, 63)]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_grv05"]
|
||||||
|
length = 0.001
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Sprite2D:position")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 0,
|
||||||
|
"values": [Vector2(89, 266)]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_i700a"]
|
||||||
|
_data = {
|
||||||
|
"RESET": SubResource("Animation_grv05"),
|
||||||
|
"player": SubResource("Animation_hax8x")
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_gpqtf"]
|
||||||
|
resource_name = "player"
|
||||||
|
length = 0.5
|
||||||
|
loop_mode = 1
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Sprite2D:frame")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0, 0.1, 0.2, 0.3, 0.4),
|
||||||
|
"transitions": PackedFloat32Array(1, 1, 1, 1, 1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [0, 1, 2, 3, 4]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id="Animation_3c1s5"]
|
||||||
|
length = 0.001
|
||||||
|
tracks/0/type = "value"
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/path = NodePath("Sprite2D:frame")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/keys = {
|
||||||
|
"times": PackedFloat32Array(0),
|
||||||
|
"transitions": PackedFloat32Array(1),
|
||||||
|
"update": 1,
|
||||||
|
"values": [0]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="AnimationLibrary" id="AnimationLibrary_67fo3"]
|
||||||
|
_data = {
|
||||||
|
"RESET": SubResource("Animation_3c1s5"),
|
||||||
|
"player": SubResource("Animation_gpqtf")
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="SpriteFrames" id="SpriteFrames_txsbt"]
|
||||||
|
animations = [{
|
||||||
|
"frames": [{
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": ExtResource("5_vwedp")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": ExtResource("6_2xnpv")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": ExtResource("7_ev8ek")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": ExtResource("8_puipc")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": ExtResource("9_i5m5b")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": ExtResource("10_6ea7i")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": ExtResource("11_shxe3")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": ExtResource("12_7ilo7")
|
||||||
|
}],
|
||||||
|
"loop": true,
|
||||||
|
"name": &"default",
|
||||||
|
"speed": 10.0
|
||||||
|
}]
|
||||||
|
|
||||||
|
[node name="Node2D" type="Node2D"]
|
||||||
|
|
||||||
|
[node name="Animation_1" type="Node2D" parent="."]
|
||||||
|
position = Vector2(74, 45)
|
||||||
|
metadata/_edit_group_ = true
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="Animation_1"]
|
||||||
|
scale = Vector2(2, 2)
|
||||||
|
texture = ExtResource("1_s2byb")
|
||||||
|
hframes = 60
|
||||||
|
script = ExtResource("2_moa6m")
|
||||||
|
|
||||||
|
[node name="Timer" type="Timer" parent="Animation_1/Sprite2D"]
|
||||||
|
wait_time = 0.1
|
||||||
|
autostart = true
|
||||||
|
|
||||||
|
[node name="Animation_2" type="Node2D" parent="."]
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="Animation_2"]
|
||||||
|
position = Vector2(85, 134)
|
||||||
|
scale = Vector2(0.5, 0.5)
|
||||||
|
texture = ExtResource("3_eunem")
|
||||||
|
script = ExtResource("4_ih3vw")
|
||||||
|
|
||||||
|
[node name="Animation_3" type="Node2D" parent="."]
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="Animation_3"]
|
||||||
|
position = Vector2(89, 266)
|
||||||
|
scale = Vector2(0.5, 0.5)
|
||||||
|
texture = ExtResource("3_eunem")
|
||||||
|
|
||||||
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="Animation_3"]
|
||||||
|
libraries = {
|
||||||
|
"": SubResource("AnimationLibrary_i700a")
|
||||||
|
}
|
||||||
|
autoplay = "player"
|
||||||
|
|
||||||
|
[node name="Animation_4" type="Node2D" parent="."]
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="Animation_4"]
|
||||||
|
position = Vector2(89, 396)
|
||||||
|
scale = Vector2(2, 2)
|
||||||
|
texture = ExtResource("1_s2byb")
|
||||||
|
hframes = 60
|
||||||
|
|
||||||
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="Animation_4"]
|
||||||
|
libraries = {
|
||||||
|
"": SubResource("AnimationLibrary_67fo3")
|
||||||
|
}
|
||||||
|
autoplay = "player"
|
||||||
|
|
||||||
|
[node name="Animation_5" type="Node2D" parent="."]
|
||||||
|
|
||||||
|
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="Animation_5"]
|
||||||
|
position = Vector2(96, 537)
|
||||||
|
sprite_frames = SubResource("SpriteFrames_txsbt")
|
||||||
|
autoplay = "default"
|
||||||
|
|
||||||
|
[connection signal="timeout" from="Animation_1/Sprite2D/Timer" to="Animation_1/Sprite2D" method="_on_timer_timeout"]
|
After Width: | Height: | Size: 16 KiB |
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://do4b3hpflfwi1"
|
||||||
|
path="res://.godot/imported/player.png-e28fee2dde34564549f6b47bedcbb62e.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://scene/demo10_animation/image/player.png"
|
||||||
|
dest_files=["res://.godot/imported/player.png-e28fee2dde34564549f6b47bedcbb62e.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
After Width: | Height: | Size: 893 B |
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://cdcpww682ywng"
|
||||||
|
path="res://.godot/imported/run-1.png-3280c05cb0e4f0094bf9a065f1c420ed.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://scene/demo10_animation/image/run-1.png"
|
||||||
|
dest_files=["res://.godot/imported/run-1.png-3280c05cb0e4f0094bf9a065f1c420ed.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
After Width: | Height: | Size: 885 B |
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://chsdpv60jcl58"
|
||||||
|
path="res://.godot/imported/run-2.png-c6dd0e2a0fd44ecce64d51822fe106eb.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://scene/demo10_animation/image/run-2.png"
|
||||||
|
dest_files=["res://.godot/imported/run-2.png-c6dd0e2a0fd44ecce64d51822fe106eb.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
After Width: | Height: | Size: 800 B |
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://dwbbk8etvj2nd"
|
||||||
|
path="res://.godot/imported/run-3.png-a7f3ee534265c5117fb56b89486b5e55.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://scene/demo10_animation/image/run-3.png"
|
||||||
|
dest_files=["res://.godot/imported/run-3.png-a7f3ee534265c5117fb56b89486b5e55.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
After Width: | Height: | Size: 749 B |
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://bt3r7fvye3ctd"
|
||||||
|
path="res://.godot/imported/run-4.png-5f322ba121a10ba33f069dd9c25a1035.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://scene/demo10_animation/image/run-4.png"
|
||||||
|
dest_files=["res://.godot/imported/run-4.png-5f322ba121a10ba33f069dd9c25a1035.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
After Width: | Height: | Size: 895 B |
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://d1gtcor5h4js5"
|
||||||
|
path="res://.godot/imported/run-5.png-6dc8b7d6582a966a0b43c5375057d646.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://scene/demo10_animation/image/run-5.png"
|
||||||
|
dest_files=["res://.godot/imported/run-5.png-6dc8b7d6582a966a0b43c5375057d646.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
After Width: | Height: | Size: 879 B |
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://dmh8knrjxc8f1"
|
||||||
|
path="res://.godot/imported/run-6.png-af2f504c10c840072a12547b0a3c767b.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://scene/demo10_animation/image/run-6.png"
|
||||||
|
dest_files=["res://.godot/imported/run-6.png-af2f504c10c840072a12547b0a3c767b.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
After Width: | Height: | Size: 835 B |
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://gs5kwcor331o"
|
||||||
|
path="res://.godot/imported/run-7.png-778e3a530cfcb29ce7258e12c61126fb.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://scene/demo10_animation/image/run-7.png"
|
||||||
|
dest_files=["res://.godot/imported/run-7.png-778e3a530cfcb29ce7258e12c61126fb.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
After Width: | Height: | Size: 760 B |
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://c2eu47l1mjehx"
|
||||||
|
path="res://.godot/imported/run-8.png-3d745ba5b7d037dda1ae54f02d2b148c.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://scene/demo10_animation/image/run-8.png"
|
||||||
|
dest_files=["res://.godot/imported/run-8.png-3d745ba5b7d037dda1ae54f02d2b148c.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
|
@ -0,0 +1,9 @@
|
||||||
|
extends Sprite2D
|
||||||
|
|
||||||
|
|
||||||
|
func _on_timer_timeout():
|
||||||
|
if frame < 5:
|
||||||
|
frame += 1
|
||||||
|
else:
|
||||||
|
frame = 0
|
||||||
|
pass
|
|
@ -0,0 +1,12 @@
|
||||||
|
extends Sprite2D
|
||||||
|
|
||||||
|
|
||||||
|
var tween: Tween = null;
|
||||||
|
var targetPosition = null
|
||||||
|
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
tween = create_tween()
|
||||||
|
tween.set_loops()
|
||||||
|
# 会在起始点和终点不断的插值计算
|
||||||
|
tween.tween_property(self, "position", Vector2.RIGHT * 300, 1).as_relative().set_trans(Tween.TRANS_SINE)
|
After Width: | Height: | Size: 1.0 KiB |
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://c7gp2gicvrsyx"
|
||||||
|
path="res://.godot/imported/white_square.png-1bf12a3951ac2e8d713316b3f8f54ac1.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://scene/demo11_particle_light/image/white_square.png"
|
||||||
|
dest_files=["res://.godot/imported/white_square.png-1bf12a3951ac2e8d713316b3f8f54ac1.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
|
@ -0,0 +1,28 @@
|
||||||
|
[gd_scene load_steps=2 format=3 uid="uid://bxg5bb58pw3ws"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://c7gp2gicvrsyx" path="res://scene/demo11_particle_light/image/white_square.png" id="1_6vp7i"]
|
||||||
|
|
||||||
|
[node name="Node2D" type="Node2D"]
|
||||||
|
|
||||||
|
[node name="Sprite1" type="Sprite2D" parent="."]
|
||||||
|
modulate = Color(0.176471, 0.384314, 0.396078, 1)
|
||||||
|
position = Vector2(212, 153)
|
||||||
|
scale = Vector2(0.5, 0.5)
|
||||||
|
texture = ExtResource("1_6vp7i")
|
||||||
|
|
||||||
|
[node name="Sprite2" type="Sprite2D" parent="."]
|
||||||
|
modulate = Color(0.423529, 0.32549, 0.227451, 1)
|
||||||
|
position = Vector2(536, 149)
|
||||||
|
scale = Vector2(0.5, 0.5)
|
||||||
|
texture = ExtResource("1_6vp7i")
|
||||||
|
|
||||||
|
[node name="Sprite3" type="Sprite2D" parent="."]
|
||||||
|
modulate = Color(0.588235, 0.168627, 0.278431, 1)
|
||||||
|
position = Vector2(859, 148)
|
||||||
|
scale = Vector2(0.5, 0.5)
|
||||||
|
texture = ExtResource("1_6vp7i")
|
||||||
|
|
||||||
|
[node name="PointLight2D" type="PointLight2D" parent="."]
|
||||||
|
position = Vector2(539, 246)
|
||||||
|
scale = Vector2(3.10667, 0.51)
|
||||||
|
texture = ExtResource("1_6vp7i")
|
|
@ -0,0 +1,19 @@
|
||||||
|
[gd_scene load_steps=5 format=3 uid="uid://g84n03stjs4g"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://bmspbq66hasqu" path="res://scene/demo11_particle_light/normal_map/azagaya.png" id="1_v4erc"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dgkurote0ib1k" path="res://scene/demo11_particle_light/normal_map/azagaya_n.png" id="2_cebln"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://cc1ix37wtungx" path="res://scene/demo11_particle_light/normal_map/LightSprite.png" id="3_56yy5"]
|
||||||
|
|
||||||
|
[sub_resource type="CanvasTexture" id="CanvasTexture_3p7d6"]
|
||||||
|
diffuse_texture = ExtResource("1_v4erc")
|
||||||
|
normal_texture = ExtResource("2_cebln")
|
||||||
|
|
||||||
|
[node name="Node2D" type="Node2D"]
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
position = Vector2(306, 192)
|
||||||
|
texture = SubResource("CanvasTexture_3p7d6")
|
||||||
|
|
||||||
|
[node name="PointLight2D" type="PointLight2D" parent="."]
|
||||||
|
position = Vector2(382, 169)
|
||||||
|
texture = ExtResource("3_56yy5")
|
After Width: | Height: | Size: 17 KiB |
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://cc1ix37wtungx"
|
||||||
|
path="res://.godot/imported/LightSprite.png-c40d01886f4a6ec8b4377142d643177e.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://scene/demo11_particle_light/normal_map/LightSprite.png"
|
||||||
|
dest_files=["res://.godot/imported/LightSprite.png-c40d01886f4a6ec8b4377142d643177e.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
After Width: | Height: | Size: 24 KiB |
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://bmspbq66hasqu"
|
||||||
|
path="res://.godot/imported/azagaya.png-ad429dd9403620b051e8578587d08aea.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://scene/demo11_particle_light/normal_map/azagaya.png"
|
||||||
|
dest_files=["res://.godot/imported/azagaya.png-ad429dd9403620b051e8578587d08aea.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
After Width: | Height: | Size: 33 KiB |
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://dgkurote0ib1k"
|
||||||
|
path="res://.godot/imported/azagaya_n.png-5b93a8bb5a6286587518a775b01152a3.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://scene/demo11_particle_light/normal_map/azagaya_n.png"
|
||||||
|
dest_files=["res://.godot/imported/azagaya_n.png-5b93a8bb5a6286587518a775b01152a3.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
After Width: | Height: | Size: 34 KiB |
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://cyuaotq1vs5pw"
|
||||||
|
path="res://.godot/imported/simplebrick.png-5e16cb9c113a4ed9a022f89e50a799bc.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://scene/demo11_particle_light/normal_map/simplebrick.png"
|
||||||
|
dest_files=["res://.godot/imported/simplebrick.png-5e16cb9c113a4ed9a022f89e50a799bc.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
After Width: | Height: | Size: 57 KiB |
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://dfv4k17llxbo6"
|
||||||
|
path="res://.godot/imported/simplebrick_n.png-b5f5247c3aa4e49d79ccb3dd8d40a42e.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://scene/demo11_particle_light/normal_map/simplebrick_n.png"
|
||||||
|
dest_files=["res://.godot/imported/simplebrick_n.png-b5f5247c3aa4e49d79ccb3dd8d40a42e.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
|
@ -0,0 +1,32 @@
|
||||||
|
[gd_scene load_steps=3 format=3 uid="uid://sfmyqojowakw"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://c7gp2gicvrsyx" path="res://scene/demo11_particle_light/image/white_square.png" id="1_3vx8l"]
|
||||||
|
|
||||||
|
[sub_resource type="OccluderPolygon2D" id="OccluderPolygon2D_xu7kt"]
|
||||||
|
polygon = PackedVector2Array(-142, -142, -150, 146, 154, 148, 148, -154)
|
||||||
|
|
||||||
|
[node name="Node2D" type="Node2D"]
|
||||||
|
|
||||||
|
[node name="Background" type="Sprite2D" parent="."]
|
||||||
|
modulate = Color(0.105882, 0.215686, 0.254902, 1)
|
||||||
|
position = Vector2(560, 332)
|
||||||
|
scale = Vector2(4.27333, 4.27333)
|
||||||
|
texture = ExtResource("1_3vx8l")
|
||||||
|
|
||||||
|
[node name="Shadow" type="Sprite2D" parent="."]
|
||||||
|
modulate = Color(0, 0.0156863, 0.180392, 1)
|
||||||
|
position = Vector2(471, 157)
|
||||||
|
scale = Vector2(0.5, 0.5)
|
||||||
|
texture = ExtResource("1_3vx8l")
|
||||||
|
|
||||||
|
[node name="LightOccluder2D" type="LightOccluder2D" parent="Shadow"]
|
||||||
|
position = Vector2(-10, 0)
|
||||||
|
occluder = SubResource("OccluderPolygon2D_xu7kt")
|
||||||
|
occluder_light_mask = 2
|
||||||
|
|
||||||
|
[node name="PointLight2D" type="PointLight2D" parent="."]
|
||||||
|
position = Vector2(619, 366)
|
||||||
|
scale = Vector2(4.56333, 2.77667)
|
||||||
|
shadow_enabled = true
|
||||||
|
shadow_item_cull_mask = 2
|
||||||
|
texture = ExtResource("1_3vx8l")
|
|
@ -0,0 +1,26 @@
|
||||||
|
[gd_scene load_steps=5 format=3 uid="uid://d25tq5jun4vv3"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://c7gp2gicvrsyx" path="res://scene/demo11_particle_light/image/white_square.png" id="1_ux0kf"]
|
||||||
|
|
||||||
|
[sub_resource type="Gradient" id="Gradient_i2rdc"]
|
||||||
|
|
||||||
|
[sub_resource type="GradientTexture1D" id="GradientTexture1D_mu0kg"]
|
||||||
|
gradient = SubResource("Gradient_i2rdc")
|
||||||
|
|
||||||
|
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_j8287"]
|
||||||
|
particle_flag_disable_z = true
|
||||||
|
direction = Vector3(0, -1, 0)
|
||||||
|
initial_velocity_max = 882.05
|
||||||
|
gravity = Vector3(0, 98, 0)
|
||||||
|
scale_min = 0.1
|
||||||
|
scale_max = 0.3
|
||||||
|
color = Color(0.772549, 0.101961, 0.27451, 1)
|
||||||
|
color_ramp = SubResource("GradientTexture1D_mu0kg")
|
||||||
|
|
||||||
|
[node name="Node2D" type="Node2D"]
|
||||||
|
|
||||||
|
[node name="GPUParticles2D" type="GPUParticles2D" parent="."]
|
||||||
|
position = Vector2(493, 458)
|
||||||
|
amount = 60
|
||||||
|
process_material = SubResource("ParticleProcessMaterial_j8287")
|
||||||
|
texture = ExtResource("1_ux0kf")
|
|
@ -0,0 +1,33 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="font_data_dynamic"
|
||||||
|
type="FontFile"
|
||||||
|
uid="uid://ck65b3tqyxgh0"
|
||||||
|
path="res://.godot/imported/Source_Han_Sans.ttf-8639e80c0af22b5c464d63266154e1ce.fontdata"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://scene/demo12_gui/Source_Han_Sans.ttf"
|
||||||
|
dest_files=["res://.godot/imported/Source_Han_Sans.ttf-8639e80c0af22b5c464d63266154e1ce.fontdata"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
Rendering=null
|
||||||
|
antialiasing=1
|
||||||
|
generate_mipmaps=false
|
||||||
|
multichannel_signed_distance_field=false
|
||||||
|
msdf_pixel_range=8
|
||||||
|
msdf_size=48
|
||||||
|
allow_system_fallback=true
|
||||||
|
force_autohinter=false
|
||||||
|
hinting=1
|
||||||
|
subpixel_positioning=1
|
||||||
|
oversampling=0.0
|
||||||
|
Fallbacks=null
|
||||||
|
fallbacks=[]
|
||||||
|
Compress=null
|
||||||
|
compress=true
|
||||||
|
preload=[]
|
||||||
|
language_support={}
|
||||||
|
script_support={}
|
||||||
|
opentype_features={}
|
|
@ -0,0 +1,13 @@
|
||||||
|
[gd_scene load_steps=2 format=3 uid="uid://62hau30vrs2h"]
|
||||||
|
|
||||||
|
[ext_resource type="FontFile" uid="uid://ck65b3tqyxgh0" path="res://scene/demo12_gui/Source_Han_Sans.ttf" id="1_vny5y"]
|
||||||
|
|
||||||
|
[node name="Node2D" type="Node2D"]
|
||||||
|
|
||||||
|
[node name="Label" type="Label" parent="."]
|
||||||
|
offset_left = 166.0
|
||||||
|
offset_top = 110.0
|
||||||
|
offset_right = 345.0
|
||||||
|
offset_bottom = 153.0
|
||||||
|
theme_override_fonts/font = ExtResource("1_vny5y")
|
||||||
|
text = "你好啊"
|
|
@ -0,0 +1,25 @@
|
||||||
|
[gd_scene load_steps=3 format=3 uid="uid://0lol8wbfschs"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dwduwy3y2vipi" path="res://icon.svg" id="2_02wmm"]
|
||||||
|
[ext_resource type="Script" path="res://scene/demo13_camera/script/move_camera.gd" id="2_lfqsy"]
|
||||||
|
|
||||||
|
[node name="Node2D" type="Node2D"]
|
||||||
|
|
||||||
|
[node name="Sprite1" type="Sprite2D" parent="."]
|
||||||
|
modulate = Color(0.14902, 1, 0.054902, 1)
|
||||||
|
position = Vector2(-528, 248)
|
||||||
|
texture = ExtResource("2_02wmm")
|
||||||
|
|
||||||
|
[node name="Sprite2" type="Sprite2D" parent="."]
|
||||||
|
modulate = Color(0.67451, 0.211765, 1, 1)
|
||||||
|
position = Vector2(507, 285)
|
||||||
|
texture = ExtResource("2_02wmm")
|
||||||
|
|
||||||
|
[node name="Sprite3" type="Sprite2D" parent="."]
|
||||||
|
modulate = Color(1, 0, 0.768627, 1)
|
||||||
|
position = Vector2(26, 293)
|
||||||
|
texture = ExtResource("2_02wmm")
|
||||||
|
script = ExtResource("2_lfqsy")
|
||||||
|
metadata/_edit_group_ = true
|
||||||
|
|
||||||
|
[node name="Camera2D" type="Camera2D" parent="Sprite3"]
|
|
@ -0,0 +1,29 @@
|
||||||
|
extends Sprite2D
|
||||||
|
|
||||||
|
|
||||||
|
# How fast the player will move (pixels/sec).
|
||||||
|
@export var speed = 400
|
||||||
|
# Size of the game window.
|
||||||
|
var screen_size
|
||||||
|
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
screen_size = get_viewport_rect().size
|
||||||
|
|
||||||
|
|
||||||
|
func _process(delta):
|
||||||
|
var velocity = Vector2.ZERO # The player's movement vector.
|
||||||
|
if Input.is_action_pressed("move_right"):
|
||||||
|
velocity.x += 1
|
||||||
|
if Input.is_action_pressed("move_left"):
|
||||||
|
velocity.x -= 1
|
||||||
|
if Input.is_action_pressed("move_down"):
|
||||||
|
velocity.y += 1
|
||||||
|
if Input.is_action_pressed("move_up"):
|
||||||
|
velocity.y -= 1
|
||||||
|
|
||||||
|
if velocity.length() <= 0:
|
||||||
|
return
|
||||||
|
|
||||||
|
velocity = velocity.normalized() * speed
|
||||||
|
position += velocity * delta
|
|
@ -0,0 +1,55 @@
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
const StringUtils = preload("res://zfoo/util/StringUtils.gd")
|
||||||
|
|
||||||
|
var camera1: Camera2D
|
||||||
|
var camera2: Camera2D
|
||||||
|
var camera3: Camera2D
|
||||||
|
var camera4: Camera2D
|
||||||
|
|
||||||
|
var timerCounter = 0
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
camera1 = get_node("Camera2D1")
|
||||||
|
camera2 = get_node("Camera2D2")
|
||||||
|
camera3 = get_node("Camera2D3")
|
||||||
|
camera4 = get_node("Camera2D4")
|
||||||
|
|
||||||
|
|
||||||
|
func _physics_process(delta: float) -> void:
|
||||||
|
timerCounter += 1
|
||||||
|
if(timerCounter == 100):
|
||||||
|
switchCamera1()
|
||||||
|
if(timerCounter == 200):
|
||||||
|
switchCamera2()
|
||||||
|
if(timerCounter == 300):
|
||||||
|
switchCamera3()
|
||||||
|
if(timerCounter == 400):
|
||||||
|
switchCamera4()
|
||||||
|
timerCounter = 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func switchCamera1() -> void:
|
||||||
|
camera1.make_current()
|
||||||
|
print("camera1---------------------------")
|
||||||
|
postionTest()
|
||||||
|
|
||||||
|
func switchCamera2() -> void:
|
||||||
|
camera2.make_current()
|
||||||
|
print("camera2---------------------------")
|
||||||
|
postionTest()
|
||||||
|
|
||||||
|
func switchCamera3() -> void:
|
||||||
|
camera3.make_current()
|
||||||
|
print("camera3---------------------------")
|
||||||
|
postionTest()
|
||||||
|
|
||||||
|
func switchCamera4() -> void:
|
||||||
|
camera4.make_current()
|
||||||
|
print("camera4---------------------------")
|
||||||
|
postionTest()
|
||||||
|
|
||||||
|
func postionTest():
|
||||||
|
print(StringUtils.format("全局坐标[{}]", [$Sprite1.global_position]))
|
||||||
|
print(StringUtils.format("屏幕坐标[{}]", [$Sprite1.get_global_transform_with_canvas()]))
|
|
@ -0,0 +1,34 @@
|
||||||
|
[gd_scene load_steps=3 format=3 uid="uid://df07ssfhn2ml5"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dwduwy3y2vipi" path="res://icon.svg" id="1_t771k"]
|
||||||
|
[ext_resource type="Script" path="res://scene/demo13_camera/script/move_camera.gd" id="2_mglxg"]
|
||||||
|
|
||||||
|
[node name="Node2D" type="Node2D"]
|
||||||
|
|
||||||
|
[node name="icon" type="Sprite2D" parent="."]
|
||||||
|
position = Vector2(249, 158)
|
||||||
|
texture = ExtResource("1_t771k")
|
||||||
|
|
||||||
|
[node name="Control" type="Control" parent="."]
|
||||||
|
modulate = Color(0.47451, 1, 1, 1)
|
||||||
|
layout_mode = 3
|
||||||
|
anchors_preset = 0
|
||||||
|
offset_left = 636.0
|
||||||
|
offset_top = 140.0
|
||||||
|
offset_right = 676.0
|
||||||
|
offset_bottom = 180.0
|
||||||
|
metadata/_edit_group_ = true
|
||||||
|
|
||||||
|
[node name="SubViewportContainer" type="SubViewportContainer" parent="Control"]
|
||||||
|
layout_mode = 0
|
||||||
|
offset_right = 519.0
|
||||||
|
offset_bottom = 512.0
|
||||||
|
|
||||||
|
[node name="SubViewport" type="SubViewport" parent="Control/SubViewportContainer"]
|
||||||
|
handle_input_locally = false
|
||||||
|
render_target_update_mode = 4
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="Control/SubViewportContainer/SubViewport"]
|
||||||
|
position = Vector2(100, 100)
|
||||||
|
texture = ExtResource("1_t771k")
|
||||||
|
script = ExtResource("2_mglxg")
|
|
@ -0,0 +1,39 @@
|
||||||
|
[gd_scene load_steps=3 format=3 uid="uid://cqfcap32ndasf"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scene/demo13_camera/script/switch_camera.gd" id="1_h3uuu"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dwduwy3y2vipi" path="res://icon.svg" id="2_2b276"]
|
||||||
|
|
||||||
|
[node name="Node2D" type="Node2D"]
|
||||||
|
script = ExtResource("1_h3uuu")
|
||||||
|
|
||||||
|
[node name="Sprite1" type="Sprite2D" parent="."]
|
||||||
|
modulate = Color(0.14902, 1, 0.054902, 1)
|
||||||
|
position = Vector2(-528, 248)
|
||||||
|
texture = ExtResource("2_2b276")
|
||||||
|
|
||||||
|
[node name="Sprite2" type="Sprite2D" parent="."]
|
||||||
|
modulate = Color(0.67451, 0.211765, 1, 1)
|
||||||
|
position = Vector2(507, 285)
|
||||||
|
texture = ExtResource("2_2b276")
|
||||||
|
|
||||||
|
[node name="Sprite3" type="Sprite2D" parent="."]
|
||||||
|
modulate = Color(1, 0, 0.768627, 1)
|
||||||
|
position = Vector2(-549, 884)
|
||||||
|
texture = ExtResource("2_2b276")
|
||||||
|
|
||||||
|
[node name="Sprite4" type="Sprite2D" parent="."]
|
||||||
|
modulate = Color(0.690196, 0.639216, 0, 1)
|
||||||
|
position = Vector2(533, 944)
|
||||||
|
texture = ExtResource("2_2b276")
|
||||||
|
|
||||||
|
[node name="Camera2D1" type="Camera2D" parent="."]
|
||||||
|
position = Vector2(-512, 300)
|
||||||
|
|
||||||
|
[node name="Camera2D2" type="Camera2D" parent="."]
|
||||||
|
position = Vector2(512, 300)
|
||||||
|
|
||||||
|
[node name="Camera2D3" type="Camera2D" parent="."]
|
||||||
|
position = Vector2(-512, 900)
|
||||||
|
|
||||||
|
[node name="Camera2D4" type="Camera2D" parent="."]
|
||||||
|
position = Vector2(512, 900)
|
|
@ -0,0 +1,6 @@
|
||||||
|
[gd_scene load_steps=2 format=3 uid="uid://c6kba7v68k7in"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://scene/demo14_file/script/file.gd" id="1_fl63m"]
|
||||||
|
|
||||||
|
[node name="Node2D" type="Node2D"]
|
||||||
|
script = ExtResource("1_fl63m")
|
|
@ -0,0 +1,33 @@
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
const TimeUtils = preload("res://zfoo/util/TimeUtils.gd")
|
||||||
|
const FileUtils = preload("res://zfoo/util/FileUtils.gd")
|
||||||
|
|
||||||
|
|
||||||
|
# Dictionary
|
||||||
|
var content = "hello file!!!"
|
||||||
|
|
||||||
|
# path string
|
||||||
|
var filePath: String = "user://playerData.txt"
|
||||||
|
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
print("Original Data: ", content)
|
||||||
|
self.loadData()
|
||||||
|
print("Altered Data: ", content)
|
||||||
|
|
||||||
|
|
||||||
|
func saveData() -> void:
|
||||||
|
FileUtils.writeStringToFile(filePath, content)
|
||||||
|
|
||||||
|
|
||||||
|
func loadData() -> void:
|
||||||
|
content = FileUtils.readFileToString(filePath)
|
||||||
|
|
||||||
|
|
||||||
|
# 退出的时候回调
|
||||||
|
func _notification(what):
|
||||||
|
if what == NOTIFICATION_WM_CLOSE_REQUEST:
|
||||||
|
content = content + str(TimeUtils.currentTimeMillis())
|
||||||
|
self.saveData()
|
||||||
|
get_tree().quit() # quitting the game
|