pull/2/head
jaysunxiao 2021-10-07 18:38:10 +08:00
parent a798153515
commit 7725e22c90
40 changed files with 695 additions and 22 deletions

View File

@ -1,2 +1,15 @@
![Image text](image/animation1.png)
![Image text](image/animation2.png)
![Image text](image/animation3.png)
![Image text](image/animation4.png)
![Image text](image/animation5.png)
![Image text](image/animation6.png)
![Image text](image/animation7.png)
![Image text](image/animation8.png)
![Image text](image/animation9.png)
![Image text](image/animation10.png)
![Image text](image/animation11.png)
![Image text](image/animation12.png)
- AnimationPlayer是时间和属性的变化是一种动画的表现
- AnimatedSprite是序列帧的简便的用法

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/animation1.png-2e16c162dbddc0ebeea917f892fabba4.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://doc/demo10_animation/image/animation1.png"
dest_files=[ "res://.import/animation1.png-2e16c162dbddc0ebeea917f892fabba4.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/animation10.png-0ee535f733c49f16435a95c4ba7696d6.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://doc/demo10_animation/image/animation10.png"
dest_files=[ "res://.import/animation10.png-0ee535f733c49f16435a95c4ba7696d6.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/animation11.png-84727766c32c30b25d868cdb214b5850.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://doc/demo10_animation/image/animation11.png"
dest_files=[ "res://.import/animation11.png-84727766c32c30b25d868cdb214b5850.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 MiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/animation12.png-b7ed43304f2d1f516db5659d7270393f.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://doc/demo10_animation/image/animation12.png"
dest_files=[ "res://.import/animation12.png-b7ed43304f2d1f516db5659d7270393f.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/animation2.png-bc27a339fd439363838ca5844b41e97e.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://doc/demo10_animation/image/animation2.png"
dest_files=[ "res://.import/animation2.png-bc27a339fd439363838ca5844b41e97e.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/animation3.png-3192fccf241921ac6b5248ba6de88a6f.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://doc/demo10_animation/image/animation3.png"
dest_files=[ "res://.import/animation3.png-3192fccf241921ac6b5248ba6de88a6f.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/animation4.png-895a32a551825612b04d629a186dc146.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://doc/demo10_animation/image/animation4.png"
dest_files=[ "res://.import/animation4.png-895a32a551825612b04d629a186dc146.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/animation5.png-3add2638e06576c63401c3a7939ed408.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://doc/demo10_animation/image/animation5.png"
dest_files=[ "res://.import/animation5.png-3add2638e06576c63401c3a7939ed408.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/animation6.png-699ccbcad3d4abb79eaf96b469875995.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://doc/demo10_animation/image/animation6.png"
dest_files=[ "res://.import/animation6.png-699ccbcad3d4abb79eaf96b469875995.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 MiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/animation7.png-318a96e3f1d40580333aa3f3e1c4e254.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://doc/demo10_animation/image/animation7.png"
dest_files=[ "res://.import/animation7.png-318a96e3f1d40580333aa3f3e1c4e254.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/animation8.png-d3676d524a1c638fc2c1bdb14b640470.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://doc/demo10_animation/image/animation8.png"
dest_files=[ "res://.import/animation8.png-d3676d524a1c638fc2c1bdb14b640470.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 MiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/animation9.png-4b5072688f929d27e7f9565737f2caaf.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://doc/demo10_animation/image/animation9.png"
dest_files=[ "res://.import/animation9.png-4b5072688f929d27e7f9565737f2caaf.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@ -1,3 +1,4 @@
# file文件系统
![Image text](image/file1.png)
![Image text](image/file2.png)
![Image text](image/file3.png)
@ -5,3 +6,11 @@
![Image text](image/file5.png)
![Image text](image/file6.png)
![Image text](image/file7.png)
# autoload单例模式
![Image text](image/autoload1.png)
![Image text](image/autoload2.png)
![Image text](image/autoload3.png)
![Image text](image/autoload4.png)
![Image text](image/autoload5.png)

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/autoload1.png-afd646f3d8d769a437b737e710545571.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://doc/demo14_file/image/autoload1.png"
dest_files=[ "res://.import/autoload1.png-afd646f3d8d769a437b737e710545571.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/autoload2.png-703eb674c83b3852b6206ca2cbdae617.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://doc/demo14_file/image/autoload2.png"
dest_files=[ "res://.import/autoload2.png-703eb674c83b3852b6206ca2cbdae617.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/autoload3.png-62bce05289b2141e879938c64fca24f3.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://doc/demo14_file/image/autoload3.png"
dest_files=[ "res://.import/autoload3.png-62bce05289b2141e879938c64fca24f3.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/autoload4.png-c01ee76da84561da13ad3f8778920018.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://doc/demo14_file/image/autoload4.png"
dest_files=[ "res://.import/autoload4.png-c01ee76da84561da13ad3f8778920018.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/autoload5.png-86f79af8b019a1d00c8ba7e0a846959a.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://doc/demo14_file/image/autoload5.png"
dest_files=[ "res://.import/autoload5.png-86f79af8b019a1d00c8ba7e0a846959a.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=14 format=2]
[gd_scene load_steps=16 format=2]
[ext_resource path="res://scene/demo10_animation/image/run-6.png" type="Texture" id=1]
[ext_resource path="res://scene/demo10_animation/image/run-5.png" type="Texture" id=2]
@ -10,6 +10,8 @@
[ext_resource path="res://scene/demo10_animation/image/run-3.png" type="Texture" id=8]
[ext_resource path="res://scene/demo10_animation/image/run-1.png" type="Texture" id=9]
[ext_resource path="res://scene/demo10_animation/image/run-2.png" type="Texture" id=10]
[ext_resource path="res://script/demo10_animation/timer_animation.gd" type="Script" id=11]
[ext_resource path="res://script/demo10_animation/tween_animation.gd" type="Script" id=12]
[sub_resource type="Animation" id=1]
resource_name = "my_animation_1"
@ -25,7 +27,7 @@ tracks/0/keys = {
"times": PoolRealArray( 0, 2 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Vector2( 107.526, 131.125 ), Vector2( 863.129, 129.537 ) ]
"values": [ Vector2( 319.48, 335.423 ), Vector2( 966.209, 326.747 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("icon:rotation_degrees")
@ -37,7 +39,7 @@ tracks/1/keys = {
"times": PoolRealArray( 0, 2 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ 0.0, 360.0 ]
"values": [ 0.0, 0.0 ]
}
tracks/2/type = "value"
tracks/2/path = NodePath("icon:scale")
@ -49,7 +51,7 @@ tracks/2/keys = {
"times": PoolRealArray( 0, 2 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 0,
"values": [ Vector2( 1, 1 ), Vector2( 3, 3 ) ]
"values": [ Vector2( 1, 1 ), Vector2( 1, 1 ) ]
}
[sub_resource type="Animation" id=2]
@ -81,35 +83,64 @@ animations = [ {
[node name="Animation_1" type="Node2D" parent="."]
[node name="icon" type="Sprite" parent="Animation_1"]
position = Vector2( 315.475, 141.204 )
rotation = 6.28319
scale = Vector2( 1.06651, 1.06651 )
texture = ExtResource( 4 )
[node name="Sprite" type="Sprite" parent="Animation_1"]
position = Vector2( 317.024, 70.0791 )
scale = Vector2( 1.70913, 1.70913 )
texture = ExtResource( 6 )
hframes = 60
script = ExtResource( 11 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="Animation_1"]
autoplay = "my_animation_1"
anims/my_animation_1 = SubResource( 1 )
[node name="Timer" type="Timer" parent="Animation_1/Sprite"]
wait_time = 0.1
autostart = true
[node name="Animation_2" type="Node2D" parent="."]
[node name="player" type="Sprite" parent="Animation_2"]
position = Vector2( 317.132, 336.313 )
[node name="Sprite" type="Sprite" parent="Animation_2"]
position = Vector2( 307.681, 157.511 )
texture = ExtResource( 4 )
script = ExtResource( 12 )
[node name="Tween" type="Tween" parent="Animation_2/Sprite"]
repeat = true
playback/repeat = true
[node name="TargetPosition" type="Sprite" parent="."]
position = Vector2( 928.381, 170.859 )
texture = ExtResource( 4 )
[node name="Animation_3" type="Node2D" parent="."]
[node name="icon" type="Sprite" parent="Animation_3"]
position = Vector2( 317.477, 302.72 )
texture = ExtResource( 4 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="Animation_3"]
autoplay = "my_animation_1"
anims/my_animation_1 = SubResource( 1 )
[node name="Animation_4" type="Node2D" parent="."]
[node name="player" type="Sprite" parent="Animation_4"]
position = Vector2( 319.802, 425.747 )
scale = Vector2( 1.86179, 1.57452 )
texture = ExtResource( 6 )
hframes = 60
frame = 5
[node name="AnimationPlayer" type="AnimationPlayer" parent="Animation_2"]
[node name="AnimationPlayer" type="AnimationPlayer" parent="Animation_4"]
autoplay = "animation_2"
anims/animation_2 = SubResource( 2 )
[node name="Animation_3" type="Node2D" parent="."]
[node name="Animation_5" type="Node2D" parent="."]
position = Vector2( 308.251, 522.067 )
__meta__ = {
"_edit_group_": true
}
[node name="AnimatedSprite" type="AnimatedSprite" parent="Animation_3"]
[node name="AnimatedSprite" type="AnimatedSprite" parent="Animation_5"]
frames = SubResource( 3 )
frame = 5
frame = 7
playing = true
[connection signal="timeout" from="Animation_1/Sprite/Timer" to="Animation_1/Sprite" method="_on_Timer_timeout"]

View File

@ -0,0 +1,9 @@
extends Sprite
func _on_Timer_timeout():
if frame < 5:
frame += 1
else:
frame = 0

View File

@ -0,0 +1,15 @@
extends Sprite
onready var tween = $Tween
onready var targetPosition = get_node("/root/Node2D/TargetPosition")
# Called when the node enters the scene tree for the first time.
func _ready():
tween.follow_property(self, "position", get_position(), targetPosition, "position", 2.0, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
tween.start()
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass

View File

@ -18,16 +18,34 @@ func _ready() -> void:
func saveData() -> void:
var saveFile = File.new()
saveFile.open(filePath, File.WRITE)
print(saveFile.get_path_absolute())
FileUtils.writeStringToFile(filePath, content)
# bread and butter
saveFile.store_line(content)
saveFile.close()
#FileUtils.writeStringToFile(filePath, content)
func loadData() -> void:
var dataFile = File.new()
content = FileUtils.readFileToString(filePath)
# make sure our file exists on users system
if not dataFile.file_exists(filePath):
return # File does not exist
# allow reading only for file
dataFile.open(filePath, File.READ)
content = dataFile.get_as_text()
dataFile.close()
#content = FileUtils.readFileToString(filePath)
# 退出的时候回调
func _notification(what):
if what == MainLoop.NOTIFICATION_WM_QUIT_REQUEST:
content = content + TimeUtils.currentTimeMillis() as String