Add animation, Box Trap for Area2D

This commit is contained in:
bip 2024-07-29 21:07:00 -04:00
parent 0b64fc5ff8
commit 4be87a6b40
17 changed files with 283 additions and 21 deletions

View File

@ -172,4 +172,4 @@ Anim={
"zfar": 4000.01, "zfar": 4000.01,
"znear": 0.05 "znear": 0.05
} }
selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@17140/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@VSplitContainer@62/@VBoxContainer@63/@PanelContainer@110/MainScreen/@CanvasItemEditor@9462/@VSplitContainer@9281/@HSplitContainer@9283/@HSplitContainer@9285/@Control@9286/@SubViewportContainer@9287/@SubViewport@9288/Game/TileMap")]) selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@17140/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@VSplitContainer@62/@VBoxContainer@63/@PanelContainer@110/MainScreen/@CanvasItemEditor@9462/@VSplitContainer@9281/@HSplitContainer@9283/@HSplitContainer@9285/@Control@9286/@SubViewportContainer@9287/@SubViewport@9288/Game/Area2D")])

View File

@ -172,4 +172,4 @@ Anim={
"zfar": 4000.01, "zfar": 4000.01,
"znear": 0.05 "znear": 0.05
} }
selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@17140/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@VSplitContainer@62/@VBoxContainer@63/@PanelContainer@110/MainScreen/@CanvasItemEditor@9462/@VSplitContainer@9281/@HSplitContainer@9283/@HSplitContainer@9285/@Control@9286/@SubViewportContainer@9287/@SubViewport@9288/Game/TileMap")]) selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@17140/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@VSplitContainer@62/@VBoxContainer@63/@PanelContainer@110/MainScreen/@CanvasItemEditor@9462/@VSplitContainer@9281/@HSplitContainer@9283/@HSplitContainer@9285/@Control@9286/@SubViewportContainer@9287/@SubViewport@9288/Game/Area2D")])

View File

@ -172,4 +172,4 @@ Anim={
"zfar": 4000.01, "zfar": 4000.01,
"znear": 0.05 "znear": 0.05
} }
selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@17140/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@VSplitContainer@62/@VBoxContainer@63/@PanelContainer@110/MainScreen/@CanvasItemEditor@9462/@VSplitContainer@9281/@HSplitContainer@9283/@HSplitContainer@9285/@Control@9286/@SubViewportContainer@9287/@SubViewport@9288/Game/TileMap")]) selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@17140/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@VSplitContainer@62/@VBoxContainer@63/@PanelContainer@110/MainScreen/@CanvasItemEditor@9462/@VSplitContainer@9281/@HSplitContainer@9283/@HSplitContainer@9285/@Control@9286/@SubViewportContainer@9287/@SubViewport@9288/Game/Area2D")])

View File

@ -1,9 +1,11 @@
Node2D
AnimationPlayer
CollisionShape2D
AnimatableBody2D
Sprite2D Sprite2D
TileMap TileMap
Camera2D Camera2D
Node Node
AnimatedSprite2D AnimatedSprite2D
Node2D
CollisionShape2D
Area2D Area2D
RayCast2D RayCast2D

View File

@ -19,7 +19,7 @@ dock_filesystem_split=0
dock_filesystem_display_mode=0 dock_filesystem_display_mode=0
dock_filesystem_file_sort=0 dock_filesystem_file_sort=0
dock_filesystem_file_list_display_mode=1 dock_filesystem_file_list_display_mode=1
dock_filesystem_selected_paths=PackedStringArray("res://Graphics/bullet.png") dock_filesystem_selected_paths=PackedStringArray("res://scenes/platform.tscn")
dock_filesystem_uncollapsed_paths=PackedStringArray("Favorites", "res://", "res://scripts/", "res://scenes/", "res://Graphics/") dock_filesystem_uncollapsed_paths=PackedStringArray("Favorites", "res://", "res://scripts/", "res://scenes/", "res://Graphics/")
dock_3="Scene,Import" dock_3="Scene,Import"
dock_4="FileSystem" dock_4="FileSystem"
@ -27,11 +27,11 @@ dock_5="Inspector,Node,History"
[EditorNode] [EditorNode]
open_scenes=PackedStringArray("res://scenes/game.tscn", "res://scenes/character.tscn", "res://scenes/bullet.tscn", "res://scenes/crate.tscn") open_scenes=PackedStringArray("res://scenes/game.tscn", "res://scenes/character.tscn", "res://scenes/bullet.tscn", "res://scenes/crate.tscn", "res://scenes/platform.tscn")
current_scene="res://scenes/game.tscn" current_scene="res://scenes/game.tscn"
center_split_offset=-333 center_split_offset=-333
selected_default_debugger_tab_idx=0 selected_default_debugger_tab_idx=0
selected_main_editor_idx=0 selected_main_editor_idx=2
selected_bottom_panel_item=0 selected_bottom_panel_item=0
[ScriptEditor] [ScriptEditor]

View File

@ -2,3 +2,5 @@ res://scenes/game.tscn
res://scenes/character.tscn res://scenes/character.tscn
res://scenes/bullet.tscn res://scenes/bullet.tscn
res://scenes/crate.tscn res://scenes/crate.tscn
res://scenes/platform.tscn
res://scripts/gamecontroller.gd

View File

@ -8,7 +8,7 @@ Anim={
"grid_snap_active": false, "grid_snap_active": false,
"grid_step": Vector2(8, 8), "grid_step": Vector2(8, 8),
"grid_visibility": 1, "grid_visibility": 1,
"ofs": Vector2(-267.191, 13.1037), "ofs": Vector2(-253.721, -135.25),
"primary_grid_step": Vector2i(8, 8), "primary_grid_step": Vector2i(8, 8),
"show_edit_locks": true, "show_edit_locks": true,
"show_guides": true, "show_guides": true,
@ -32,7 +32,7 @@ Anim={
"snap_rotation_step": 0.261799, "snap_rotation_step": 0.261799,
"snap_scale": false, "snap_scale": false,
"snap_scale_step": 0.1, "snap_scale_step": 0.1,
"zoom": 1.05946 "zoom": 0.890899
} }
3D={ 3D={
"fov": 70.01, "fov": 70.01,
@ -172,4 +172,4 @@ Anim={
"zfar": 4000.01, "zfar": 4000.01,
"znear": 0.05 "znear": 0.05
} }
selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@17140/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@VSplitContainer@62/@VBoxContainer@63/@PanelContainer@110/MainScreen/@CanvasItemEditor@9462/@VSplitContainer@9281/@HSplitContainer@9283/@HSplitContainer@9285/@Control@9286/@SubViewportContainer@9287/@SubViewport@9288/Game/TileMap")]) selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@17140/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@VSplitContainer@62/@VBoxContainer@63/@PanelContainer@110/MainScreen/@CanvasItemEditor@9462/@VSplitContainer@9281/@HSplitContainer@9283/@HSplitContainer@9285/@Control@9286/@SubViewportContainer@9287/@SubViewport@9288/Game/Area2D")])

View File

@ -1,5 +1,5 @@
[folding] [folding]
node_unfolds=[NodePath("."), PackedStringArray("Transform"), NodePath("TileMap"), PackedStringArray("tile_set"), NodePath("StaticBody2D"), PackedStringArray("Transform"), NodePath("Area2D"), PackedStringArray("Transform")] node_unfolds=[NodePath("."), PackedStringArray("Transform"), NodePath("TileMap"), PackedStringArray("tile_set"), NodePath("StaticBody2D"), PackedStringArray("Transform"), NodePath("Area2D"), PackedStringArray("Transform"), NodePath("Platform"), PackedStringArray("Transform")]
resource_unfolds=["res://scenes/game.tscn::TileSet_p8gjw", PackedStringArray("terrain_set_0/terrain__array", "physics_layer__array"), "res://scenes/game.tscn::WorldBoundaryShape2D_3u4a8", PackedStringArray("Resource"), "res://scenes/game.tscn::CircleShape2D_x8qck", PackedStringArray("Resource")] resource_unfolds=["res://scenes/game.tscn::TileSet_p8gjw", PackedStringArray("terrain_set_0/terrain__array", "physics_layer__array"), "res://scenes/game.tscn::WorldBoundaryShape2D_3u4a8", PackedStringArray("Resource"), "res://scenes/game.tscn::CircleShape2D_x8qck", PackedStringArray("Resource")]
nodes_folded=[NodePath("StaticBody2D"), NodePath("CharacterBody2D"), NodePath("Area2D")] nodes_folded=[NodePath("StaticBody2D"), NodePath("CharacterBody2D"), NodePath("Area2D")]

View File

@ -0,0 +1,3 @@
[folding]
sections_unfolded=PackedStringArray()

View File

@ -0,0 +1,175 @@
[editor_states]
Anim={
"visible": false
}
2D={
"grid_offset": Vector2(0, 0),
"grid_snap_active": false,
"grid_step": Vector2(8, 8),
"grid_visibility": 1,
"ofs": Vector2(-165, -110),
"primary_grid_step": Vector2i(8, 8),
"show_edit_locks": true,
"show_guides": true,
"show_helpers": false,
"show_origin": true,
"show_rulers": true,
"show_transformation_gizmos": true,
"show_viewport": true,
"show_zoom_control": true,
"smart_snap_active": false,
"snap_guides": true,
"snap_node_anchors": true,
"snap_node_center": true,
"snap_node_parent": true,
"snap_node_sides": true,
"snap_other_nodes": true,
"snap_pixel": true,
"snap_relative": false,
"snap_rotation": false,
"snap_rotation_offset": 0.0,
"snap_rotation_step": 0.261799,
"snap_scale": false,
"snap_scale_step": 0.1,
"zoom": 1.0
}
3D={
"fov": 70.01,
"gizmos_status": {
"AudioListener3D": 0,
"AudioStreamPlayer3D": 0,
"CPUParticles3D": 0,
"CSGShape3D": 0,
"Camera3D": 0,
"CollisionObject3D": 0,
"CollisionPolygon3D": 0,
"CollisionShape3D": 0,
"Decal": 0,
"FogVolume": 0,
"GPUParticles3D": 0,
"GPUParticlesCollision3D": 0,
"Joint3D": 0,
"Light3D": 0,
"LightmapGI": 0,
"LightmapProbe": 0,
"Marker3D": 0,
"NavigationLink3D": 0,
"NavigationRegion3D": 0,
"OccluderInstance3D": 0,
"Path3D": 0,
"PhysicalBone3D": 0,
"RayCast3D": 0,
"ReflectionProbe": 0,
"ShapeCast3D": 0,
"Skeleton3D": 0,
"SoftBody3D": 0,
"SpringArm3D": 0,
"VehicleWheel3D": 0,
"VisibleOnScreenNotifier3D": 0,
"VoxelGI": 0
},
"local_coords": false,
"preview_sun_env": {
"environ_ao_enabled": false,
"environ_enabled": true,
"environ_energy": 1.0,
"environ_gi_enabled": false,
"environ_glow_enabled": true,
"environ_ground_color": Color(0.2, 0.169, 0.133, 1),
"environ_sky_color": Color(0.385, 0.454, 0.55, 1),
"environ_tonemap_enabled": true,
"sun_color": Color(1, 1, 1, 1),
"sun_enabled": true,
"sun_energy": 1.0,
"sun_max_distance": 100.0,
"sun_rotation": Vector2(-1.0472, 2.61799)
},
"rotate_snap": 15.0,
"scale_snap": 10.0,
"show_grid": true,
"show_origin": true,
"snap_enabled": false,
"translate_snap": 1.0,
"viewport_mode": 1,
"viewports": [{
"auto_orthogonal": false,
"auto_orthogonal_enabled": true,
"cinematic_preview": false,
"display_mode": 20,
"distance": 4.0,
"doppler": false,
"frame_time": false,
"gizmos": true,
"half_res": false,
"information": false,
"listener": true,
"lock_rotation": false,
"orthogonal": false,
"position": Vector3(0, 0, 0),
"use_environment": false,
"view_type": 0,
"x_rotation": 0.5,
"y_rotation": -0.5
}, {
"auto_orthogonal": false,
"auto_orthogonal_enabled": true,
"cinematic_preview": false,
"display_mode": 20,
"distance": 4.0,
"doppler": false,
"frame_time": false,
"gizmos": true,
"half_res": false,
"information": false,
"listener": false,
"lock_rotation": false,
"orthogonal": false,
"position": Vector3(0, 0, 0),
"use_environment": false,
"view_type": 0,
"x_rotation": 0.5,
"y_rotation": -0.5
}, {
"auto_orthogonal": false,
"auto_orthogonal_enabled": true,
"cinematic_preview": false,
"display_mode": 20,
"distance": 4.0,
"doppler": false,
"frame_time": false,
"gizmos": true,
"half_res": false,
"information": false,
"listener": false,
"lock_rotation": false,
"orthogonal": false,
"position": Vector3(0, 0, 0),
"use_environment": false,
"view_type": 0,
"x_rotation": 0.5,
"y_rotation": -0.5
}, {
"auto_orthogonal": false,
"auto_orthogonal_enabled": true,
"cinematic_preview": false,
"display_mode": 20,
"distance": 4.0,
"doppler": false,
"frame_time": false,
"gizmos": true,
"half_res": false,
"information": false,
"listener": false,
"lock_rotation": false,
"orthogonal": false,
"position": Vector3(0, 0, 0),
"use_environment": false,
"view_type": 0,
"x_rotation": 0.5,
"y_rotation": -0.5
}],
"zfar": 4000.01,
"znear": 0.05
}
selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@17140/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@VSplitContainer@62/@VBoxContainer@63/@PanelContainer@110/MainScreen/@CanvasItemEditor@9462/@VSplitContainer@9281/@HSplitContainer@9283/@HSplitContainer@9285/@Control@9286/@SubViewportContainer@9287/@SubViewport@9288/Game/Area2D")])

View File

@ -0,0 +1,5 @@
[folding]
node_unfolds=[]
resource_unfolds=["res://scenes/platform.tscn::RectangleShape2D_2kknn", PackedStringArray()]
nodes_folded=[]

View File

@ -10,11 +10,11 @@ tile_snap_subdiv=4.0
run_live_debug=true run_live_debug=true
run_reload_scripts=true run_reload_scripts=true
run_debug_collisions=false run_debug_collisions=true
[recent_files] [recent_files]
scenes=["res://scenes/crate.tscn", "res://scenes/bullet.tscn", "res://scenes/character.tscn", "res://scenes/game.tscn", "res://scenes/rigid_body_2d.tscn"] scenes=["res://scenes/platform.tscn", "res://scenes/crate.tscn", "res://scenes/bullet.tscn", "res://scenes/character.tscn", "res://scenes/game.tscn", "res://scenes/rigid_body_2d.tscn"]
scripts=["res://scripts/bullet.gd", "res://scripts/CharacterBody2D.gd", "res://scripts/gamecontroller.gd"] scripts=["res://scripts/bullet.gd", "res://scripts/CharacterBody2D.gd", "res://scripts/gamecontroller.gd"]
[linked_properties] [linked_properties]
@ -31,6 +31,7 @@ Camera2D:zoom=true
Camera2D:scale=true Camera2D:scale=true
TileMap:scale=true TileMap:scale=true
Sprite2D:scale=true Sprite2D:scale=true
AnimatableBody2D:scale=true
[dialog_bounds] [dialog_bounds]

View File

@ -3,11 +3,11 @@
state={ state={
"bookmarks": PackedInt32Array(), "bookmarks": PackedInt32Array(),
"breakpoints": PackedInt32Array(), "breakpoints": PackedInt32Array(),
"column": 0, "column": 12,
"folded_lines": Array[int]([]), "folded_lines": Array[int]([]),
"h_scroll_position": 0, "h_scroll_position": 0,
"row": 0, "row": 25,
"scroll_position": 0.0, "scroll_position": 7.0,
"selection": false, "selection": false,
"syntax_highlighter": "GDScript" "syntax_highlighter": "GDScript"
} }

Binary file not shown.

View File

@ -1,10 +1,11 @@
[gd_scene load_steps=10 format=3 uid="uid://y083suj12rld"] [gd_scene load_steps=14 format=3 uid="uid://y083suj12rld"]
[ext_resource type="Script" path="res://scripts/gamecontroller.gd" id="1_77wyw"] [ext_resource type="Script" path="res://scripts/gamecontroller.gd" id="1_77wyw"]
[ext_resource type="PackedScene" uid="uid://go4yc8hfo1gq" path="res://scenes/character.tscn" id="2_64ccm"] [ext_resource type="PackedScene" uid="uid://go4yc8hfo1gq" path="res://scenes/character.tscn" id="2_64ccm"]
[ext_resource type="Texture2D" uid="uid://iphyceyp7aay" path="res://Graphics/Terrain (32x32).png" id="2_74wn8"] [ext_resource type="Texture2D" uid="uid://iphyceyp7aay" path="res://Graphics/Terrain (32x32).png" id="2_74wn8"]
[ext_resource type="Script" path="res://scripts/Trigger.gd" id="2_nfj1w"] [ext_resource type="Script" path="res://scripts/Trigger.gd" id="2_nfj1w"]
[ext_resource type="PackedScene" uid="uid://cwfm01fpdmr1k" path="res://scenes/crate.tscn" id="2_wqngy"] [ext_resource type="PackedScene" uid="uid://cwfm01fpdmr1k" path="res://scenes/crate.tscn" id="2_wqngy"]
[ext_resource type="PackedScene" uid="uid://47xe40uafw3l" path="res://scenes/platform.tscn" id="6_lke75"]
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_vd3un"] [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_vd3un"]
texture = ExtResource("2_74wn8") texture = ExtResource("2_74wn8")
@ -480,6 +481,44 @@ sources/0 = SubResource("TileSetAtlasSource_vd3un")
[sub_resource type="CircleShape2D" id="CircleShape2D_x8qck"] [sub_resource type="CircleShape2D" id="CircleShape2D_x8qck"]
radius = 60.2993 radius = 60.2993
[sub_resource type="Animation" id="Animation_wmrpw"]
resource_name = "move"
loop_mode = 2
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 1),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Vector2(0, 0), Vector2(150, 0)]
}
[sub_resource type="Animation" id="Animation_fpywj"]
length = 0.001
loop_mode = 2
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(0, 0)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_eotb0"]
_data = {
"RESET": SubResource("Animation_fpywj"),
"move": SubResource("Animation_wmrpw")
}
[node name="Game" type="Node2D"] [node name="Game" type="Node2D"]
script = ExtResource("1_77wyw") script = ExtResource("1_77wyw")
@ -506,7 +545,7 @@ PUSH_FORCE = 550
[node name="Camera2D" type="Camera2D" parent="CharacterBody2D"] [node name="Camera2D" type="Camera2D" parent="CharacterBody2D"]
[node name="Area2D" type="Area2D" parent="."] [node name="Area2D" type="Area2D" parent="."]
position = Vector2(260, 352) position = Vector2(335, 117)
script = ExtResource("2_nfj1w") script = ExtResource("2_nfj1w")
metadata/_edit_group_ = true metadata/_edit_group_ = true
@ -518,5 +557,16 @@ debug_color = Color(0.556863, 0.415686, 0.964706, 0.419608)
position = Vector2(216, 145) position = Vector2(216, 145)
scale = Vector2(2.96, 2.56) scale = Vector2(2.96, 2.56)
[node name="Platform" parent="." instance=ExtResource("6_lke75")]
[node name="AnimationPlayer" type="AnimationPlayer" parent="Platform"]
libraries = {
"": SubResource("AnimationLibrary_eotb0")
}
autoplay = "move"
[node name="BoxTrap" type="Node2D" parent="."]
position = Vector2(345, 108)
[connection signal="areatrigger" from="Area2D" to="." method="_on_area_2d_areatrigger"] [connection signal="areatrigger" from="Area2D" to="." method="_on_area_2d_areatrigger"]
[connection signal="body_entered" from="Area2D" to="Area2D" method="_on_body_entered"] [connection signal="body_entered" from="Area2D" to="Area2D" method="_on_body_entered"]

11
scenes/platform.tscn Normal file
View File

@ -0,0 +1,11 @@
[gd_scene load_steps=2 format=3 uid="uid://47xe40uafw3l"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_2kknn"]
size = Vector2(146, 25)
[node name="AnimatableBody2D" type="AnimatableBody2D"]
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(63, 2.5)
shape = SubResource("RectangleShape2D_2kknn")
one_way_collision = true

View File

@ -1,5 +1,7 @@
extends Node2D extends Node2D
var myBox = preload("res://scenes/crate.tscn")
@onready var box_trap = $BoxTrap
# Called when the node enters the scene tree for the first time. # Called when the node enters the scene tree for the first time.
func _ready(): func _ready():
@ -11,5 +13,16 @@ func _process(delta):
pass pass
func _on_area_2d_areatrigger(effect, Object): func _on_area_2d_areatrigger(effect, body):
print("Game Controller sees the trigger") print("Game Controller sees the trigger"+effect)
match effect:
"alert":
print("hi")
if body.is_in_group("player"):
for n in 3:
var box = myBox.instantiate()
add_child(box)
box.position = box_trap.position
"powerup":
print("you got power")