make collectibles always use full hitbox

This commit is contained in:
Haze Weathers 2023-05-16 22:58:14 -04:00
parent e4cc684603
commit ca947c2f09
9 changed files with 26 additions and 17 deletions

View file

@ -2,9 +2,10 @@ extends Node2D
export var value = 1 export var value = 1
func _on_Area2D_area_entered(area):
func _on_Area2D_body_entered(body: Node) -> void:
#Collect #Collect
if area.is_in_group("player_hitbox"): if body.is_in_group("player"):
Game.arrows += value Game.arrows += value
Game.score += 25 Game.score += 25
Audio.play_sound(Audio.a_arrow,Audio.ac_collectible) Audio.play_sound(Audio.a_arrow,Audio.ac_collectible)

View file

@ -23,9 +23,11 @@ texture = ExtResource( 3 )
[node name="Area2D" type="Area2D" parent="."] [node name="Area2D" type="Area2D" parent="."]
visible = false visible = false
collision_layer = 0
collision_mask = 128
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] [node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
position = Vector2( 4, 4 ) position = Vector2( 4, 4 )
shape = SubResource( 6 ) shape = SubResource( 6 )
[connection signal="area_entered" from="Area2D" to="." method="_on_Area2D_area_entered"] [connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"]

View file

@ -6,9 +6,10 @@ func _ready():
#Sync all coinframes #Sync all coinframes
$AnimatedSprite.play() $AnimatedSprite.play()
func _on_Area2D_area_entered(area):
func _on_Area2D_body_entered(body: Node) -> void:
#Collect #Collect
if area.is_in_group("player_hitbox"): if body.is_in_group("player"):
Game.keys += value Game.keys += value
Game.score += 5 Game.score += 5
Audio.play_sound(Audio.a_gold,Audio.ac_collectible) Audio.play_sound(Audio.a_gold,Audio.ac_collectible)

View file

@ -70,15 +70,16 @@ material = SubResource( 7 )
position = Vector2( 0, -1 ) position = Vector2( 0, -1 )
frames = SubResource( 5 ) frames = SubResource( 5 )
animation = "key" animation = "key"
frame = 4
playing = true
centered = false centered = false
[node name="Area2D" type="Area2D" parent="."] [node name="Area2D" type="Area2D" parent="."]
visible = false visible = false
collision_layer = 0
collision_mask = 128
monitorable = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] [node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
position = Vector2( 4, 4 ) position = Vector2( 4, 4 )
shape = SubResource( 6 ) shape = SubResource( 6 )
[connection signal="area_entered" from="Area2D" to="." method="_on_Area2D_area_entered"] [connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"]

View file

@ -6,9 +6,9 @@ export var number = 0 #Used for saving which specific shards collected
func _ready(): func _ready():
$AnimationPlayer.play("glow") $AnimationPlayer.play("glow")
func _on_Area2D_area_entered(area): func _on_Area2D_body_entered(body):
#Collect #Collect
if area.is_in_group("player_hitbox"): if body.is_in_group("player_hitbox"):
Audio.play_shard_sound() Audio.play_shard_sound()
Game.score += 500 Game.score += 500
Game.shards += value Game.shards += value

View file

@ -39,6 +39,8 @@ position = Vector2( 5, 3 )
texture = ExtResource( 2 ) texture = ExtResource( 2 )
[node name="Area2D" type="Area2D" parent="."] [node name="Area2D" type="Area2D" parent="."]
collision_layer = 0
collision_mask = 128
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] [node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
position = Vector2( 4.5, 2.5 ) position = Vector2( 4.5, 2.5 )
@ -47,4 +49,4 @@ shape = SubResource( 6 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="."] [node name="AnimationPlayer" type="AnimationPlayer" parent="."]
anims/glow = SubResource( 8 ) anims/glow = SubResource( 8 )
[connection signal="area_entered" from="Area2D" to="." method="_on_Area2D_area_entered"] [connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"]

View file

@ -26,9 +26,9 @@ func _set_color(value):
if is_inside_tree(): if is_inside_tree():
sprite.material.set_shader_param("palette", COLORS[color]) sprite.material.set_shader_param("palette", COLORS[color])
func _on_Area2D_area_entered(area): func _on_Area2D_body_entered(body):
#Collect #Collect
if area.is_in_group("player_hitbox"): if body.is_in_group("player_hitbox"):
Audio.play_sound(Audio.a_star,Audio.ac_collectible) Audio.play_sound(Audio.a_star,Audio.ac_collectible)
Game.score += 100 Game.score += 100
Game.stars[color] = true Game.stars[color] = true

View file

@ -54,15 +54,17 @@ script = ExtResource( 3 )
material = SubResource( 10 ) material = SubResource( 10 )
position = Vector2( -1, -3 ) position = Vector2( -1, -3 )
frames = SubResource( 8 ) frames = SubResource( 8 )
frame = 2 frame = 3
playing = true playing = true
centered = false centered = false
[node name="Area2D" type="Area2D" parent="."] [node name="Area2D" type="Area2D" parent="."]
collision_layer = 0
collision_mask = 128
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] [node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
visible = false visible = false
position = Vector2( 4, 4 ) position = Vector2( 4, 4 )
shape = SubResource( 9 ) shape = SubResource( 9 )
[connection signal="area_entered" from="Area2D" to="." method="_on_Area2D_area_entered"] [connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"]

View file

@ -758,7 +758,7 @@ tracks/3/keys = {
[sub_resource type="StyleBoxEmpty" id=4] [sub_resource type="StyleBoxEmpty" id=4]
[node name="Player" type="KinematicBody2D" groups=["player"]] [node name="Player" type="KinematicBody2D" groups=["player"]]
collision_layer = 0 collision_layer = 128
collision_mask = 7 collision_mask = 7
moving_platform_apply_velocity_on_leave = 1 moving_platform_apply_velocity_on_leave = 1
script = ExtResource( 1 ) script = ExtResource( 1 )
@ -1168,8 +1168,8 @@ script = ExtResource( 8 )
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Grounded/Pushing" to="." method="_process_pushing"] [connection signal="state_physics_processing" from="StateChart/Root/Movement/Grounded/Pushing" to="." method="_process_pushing"]
[connection signal="state_entered" from="StateChart/Root/Movement/Airborne" to="." method="_on_Airborne_state_entered"] [connection signal="state_entered" from="StateChart/Root/Movement/Airborne" to="." method="_on_Airborne_state_entered"]
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Airborne" to="." method="_process_gravity"] [connection signal="state_physics_processing" from="StateChart/Root/Movement/Airborne" to="." method="_process_gravity"]
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Airborne/Jump" to="." method="_process_jump"]
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Airborne/Jump" to="." method="_process_horizontal_movement"] [connection signal="state_physics_processing" from="StateChart/Root/Movement/Airborne/Jump" to="." method="_process_horizontal_movement"]
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Airborne/Jump" to="." method="_process_jump"]
[connection signal="state_entered" from="StateChart/Root/Movement/Airborne/Jump/NormalJump" to="." method="_on_NormalJump_state_entered"] [connection signal="state_entered" from="StateChart/Root/Movement/Airborne/Jump/NormalJump" to="." method="_on_NormalJump_state_entered"]
[connection signal="state_exited" from="StateChart/Root/Movement/Airborne/Jump/NormalJump" to="." method="_on_NormalJump_state_exited"] [connection signal="state_exited" from="StateChart/Root/Movement/Airborne/Jump/NormalJump" to="." method="_on_NormalJump_state_exited"]
[connection signal="state_entered" from="StateChart/Root/Movement/Airborne/Jump/LadderJump" to="." method="_on_LadderJump_state_entered"] [connection signal="state_entered" from="StateChart/Root/Movement/Airborne/Jump/LadderJump" to="." method="_on_LadderJump_state_entered"]