changes to coinHUD

This commit is contained in:
Martin Araneda 2022-08-01 15:05:09 -04:00
parent 2be22ceb68
commit e54e3b0687
5 changed files with 77 additions and 55 deletions

View File

@ -36,11 +36,11 @@ shape = SubResource( 5 )
position = Vector2( 18, 18 )
frames = SubResource( 8 )
animation = "flagmove"
frame = 1
playing = true
[node name="StateMachine" type="Node" parent="."]
script = ExtResource( 4 )
default_state = "GoalNotReached"
[node name="GoalReached" type="Node" parent="StateMachine"]
script = ExtResource( 3 )

8
godot/hud/CoinHUD.gd Normal file
View File

@ -0,0 +1,8 @@
extends CanvasLayer
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _physics_process(delta):
if get_tree().paused:
visible = false
else:
visible = true

58
godot/hud/CoinHUD.tscn Normal file
View File

@ -0,0 +1,58 @@
[gd_scene load_steps=8 format=2]
[ext_resource path="res://assets/coin.png" type="Texture" id=1]
[ext_resource path="res://hud/coin/Counter.gdns" type="Script" id=2]
[ext_resource path="res://hud/CoinHUD.gd" type="Script" id=3]
[sub_resource type="StyleBoxFlat" id=1]
bg_color = Color( 0, 0, 0, 0.541176 )
[sub_resource type="AtlasTexture" id=2]
atlas = ExtResource( 1 )
region = Rect2( 0, 0, 18, 18 )
[sub_resource type="AtlasTexture" id=3]
atlas = ExtResource( 1 )
region = Rect2( 18, 0, 18, 18 )
[sub_resource type="SpriteFrames" id=4]
animations = [ {
"frames": [ SubResource( 2 ), SubResource( 3 ) ],
"loop": true,
"name": "spin",
"speed": 5.0
} ]
[node name="CoinHUD" type="CanvasLayer"]
pause_mode = 2
script = ExtResource( 3 )
[node name="Panel" type="Panel" parent="."]
margin_left = 144.0
margin_top = 18.0
margin_right = 288.0
margin_bottom = 54.0
custom_styles/panel = SubResource( 1 )
[node name="Label" type="Label" parent="."]
margin_left = 180.0
margin_top = 18.0
margin_right = 220.0
margin_bottom = 36.0
text = "X"
[node name="Coins" type="Label" parent="."]
margin_left = 198.0
margin_top = 18.0
margin_right = 238.0
margin_bottom = 32.0
text = "##"
script = ExtResource( 2 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
position = Vector2( 162, 18 )
frames = SubResource( 4 )
animation = "spin"
frame = 1
playing = true
centered = false

View File

@ -1,33 +1,13 @@
[gd_scene load_steps=13 format=2]
[gd_scene load_steps=8 format=2]
[ext_resource path="res://CameraLimit.gdns" type="Script" id=1]
[ext_resource path="res://characters/player/Player.tscn" type="PackedScene" id=2]
[ext_resource path="res://levels/Prototype.tmx" type="PackedScene" id=3]
[ext_resource path="res://assets/backgrounds/mountains.png" type="Texture" id=4]
[ext_resource path="res://collectables/coin/Coin.tscn" type="PackedScene" id=5]
[ext_resource path="res://assets/coin.png" type="Texture" id=6]
[ext_resource path="res://hud/coin/Counter.gdns" type="Script" id=7]
[ext_resource path="res://hud/CoinHUD.tscn" type="PackedScene" id=6]
[ext_resource path="res://goal/Goal.tscn" type="PackedScene" id=8]
[sub_resource type="StyleBoxFlat" id=1]
bg_color = Color( 0, 0, 0, 0.541176 )
[sub_resource type="AtlasTexture" id=2]
atlas = ExtResource( 6 )
region = Rect2( 0, 0, 18, 18 )
[sub_resource type="AtlasTexture" id=3]
atlas = ExtResource( 6 )
region = Rect2( 18, 0, 18, 18 )
[sub_resource type="SpriteFrames" id=4]
animations = [ {
"frames": [ SubResource( 2 ), SubResource( 3 ) ],
"loop": true,
"name": "spin",
"speed": 5.0
} ]
[node name="Prototype" type="Node2D"]
[node name="Player" parent="." instance=ExtResource( 2 )]
@ -64,37 +44,7 @@ centered = false
[node name="Prototype" parent="Map" instance=ExtResource( 3 )]
script = ExtResource( 1 )
[node name="CoinHUD" type="CanvasLayer" parent="."]
[node name="Panel" type="Panel" parent="CoinHUD"]
margin_left = 144.0
margin_top = 18.0
margin_right = 288.0
margin_bottom = 54.0
custom_styles/panel = SubResource( 1 )
[node name="Label" type="Label" parent="CoinHUD"]
margin_left = 180.0
margin_top = 18.0
margin_right = 220.0
margin_bottom = 36.0
text = "X"
[node name="Coins" type="Label" parent="CoinHUD"]
margin_left = 198.0
margin_top = 18.0
margin_right = 238.0
margin_bottom = 32.0
text = "##"
script = ExtResource( 7 )
[node name="AnimatedSprite" type="AnimatedSprite" parent="CoinHUD"]
position = Vector2( 162, 18 )
frames = SubResource( 4 )
animation = "spin"
frame = 1
playing = true
centered = false
[node name="CoinHUD" parent="." instance=ExtResource( 6 )]
[node name="Coins" type="Node" parent="."]

View File

@ -38,7 +38,13 @@ void GoalNotReached::_state_exit()
void GoalNotReached::_on_Goal_body_entered(Node *node)
{
auto parent_node = get_parent();
if (parent_node != nullptr)
{
auto goal = Object::cast_to<Area2D>(parent_node);
goal->set_collision_mask_bit(0, false);
}
get_state_machine()->change("GoalReached");