develop #50
@ -1,7 +1,7 @@
|
||||
[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/coin/CoinCounter.gdns" type="Script" id=2]
|
||||
[ext_resource path="res://hud/CoinHUD.gd" type="Script" id=3]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=1]
|
||||
@ -28,31 +28,34 @@ 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
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
margin_left = -44.5
|
||||
margin_top = 5.0
|
||||
margin_right = 44.5
|
||||
margin_bottom = 25.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
|
||||
[node name="X" type="Label" parent="Panel"]
|
||||
margin_left = 40.0
|
||||
margin_top = 4.0
|
||||
margin_right = 53.0
|
||||
margin_bottom = 24.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
|
||||
[node name="Coins" type="Label" parent="Panel"]
|
||||
anchor_left = 0.5
|
||||
anchor_right = 0.5
|
||||
margin_left = 13.5
|
||||
margin_top = 4.0
|
||||
margin_right = 36.0
|
||||
margin_bottom = 18.0
|
||||
text = "##"
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="."]
|
||||
position = Vector2( 162, 18 )
|
||||
[node name="AnimatedSprite" type="AnimatedSprite" parent="Panel"]
|
||||
position = Vector2( 12, 1 )
|
||||
frames = SubResource( 4 )
|
||||
animation = "spin"
|
||||
frame = 1
|
||||
playing = true
|
||||
centered = false
|
||||
|
@ -15,6 +15,7 @@
|
||||
collision_layer = 5
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="Player"]
|
||||
current = true
|
||||
limit_left = 0
|
||||
limit_top = 0
|
||||
limit_right = 512
|
||||
@ -51,9 +52,6 @@ script = ExtResource( 1 )
|
||||
[node name="coin" parent="Coins" instance=ExtResource( 5 )]
|
||||
position = Vector2( 72, 450 )
|
||||
|
||||
[node name="AnimatedSprite" parent="Coins/coin" index="1"]
|
||||
frame = 0
|
||||
|
||||
[node name="coin2" parent="Coins" instance=ExtResource( 5 )]
|
||||
position = Vector2( 234, 450 )
|
||||
|
||||
|
@ -23,15 +23,24 @@ void alai::CoinCounter::_init()
|
||||
coins = 0;
|
||||
}
|
||||
|
||||
void alai::CoinCounter::_on_coin_collected(int amount)
|
||||
{
|
||||
coins = coins + amount;
|
||||
set_text(godot::String::num(coins));
|
||||
}
|
||||
|
||||
void alai::CoinCounter::_ready()
|
||||
{
|
||||
set_text("0");
|
||||
set_text("00");
|
||||
auto event = get_node<alai::Event>("/root/Event");
|
||||
event->connect("coin_collected", this, "_on_coin_collected");
|
||||
}
|
||||
|
||||
|
||||
void alai::CoinCounter::_on_coin_collected(int amount)
|
||||
{
|
||||
coins = coins + amount;
|
||||
godot::String coin_string = godot::String();
|
||||
if (coins <= 9)
|
||||
{
|
||||
coin_string = "0" + godot::String::num(coins);
|
||||
}
|
||||
else{
|
||||
coin_string = godot::String::num(coins);
|
||||
}
|
||||
set_text(coin_string);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user