adjusted level and barrier
This commit is contained in:
parent
209884f133
commit
b2baccfa57
16 changed files with 138 additions and 46 deletions
|
@ -1,15 +1,24 @@
|
|||
extends Node2D
|
||||
|
||||
export var cost = 0
|
||||
export var label_offset = Vector2.ZERO
|
||||
onready var label = $Label
|
||||
onready var sprite = $Sprite
|
||||
onready var hitbox = $StaticBody2D/CollisionShape2D
|
||||
|
||||
func _ready():
|
||||
if scale.y != 1:
|
||||
sprite.set_region_rect(Rect2(0,0,4,scale.y))
|
||||
hitbox.scale.y = scale.y
|
||||
scale.y = 1
|
||||
#Label
|
||||
label.visible = true
|
||||
label.set_text(str(cost))
|
||||
label.rect_position.y = scale.y / 2
|
||||
|
||||
func _physics_process(delta):
|
||||
#Open
|
||||
if Game.golds >= cost: $AnimationPlayer.play("open")
|
||||
if Game.golds >= cost: queue_free()
|
||||
|
||||
func _on_AnimationPlayer_animation_finished(anim_name):
|
||||
if anim_name == "open":
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
[gd_scene load_steps=8 format=2]
|
||||
|
||||
[ext_resource path="res://objects/barrier/barrier.gd" type="Script" id=1]
|
||||
[ext_resource path="res://graphics/barrier/barrier.png" type="Texture" id=2]
|
||||
[ext_resource path="res://graphics/barrier/barrier_2px.png" type="Texture" id=2]
|
||||
[ext_resource path="res://fonts/2ndpuberty..fnt" type="BitmapFont" id=3]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 2, 8 )
|
||||
extents = Vector2( 2, 0.5 )
|
||||
|
||||
[sub_resource type="Animation" id=4]
|
||||
resource_name = "initial"
|
||||
|
@ -97,12 +97,12 @@ script = ExtResource( 1 )
|
|||
texture = ExtResource( 2 )
|
||||
centered = false
|
||||
region_enabled = true
|
||||
region_rect = Rect2( 0, 0, 16, 16 )
|
||||
region_rect = Rect2( 0, 0, 4, 1 )
|
||||
|
||||
[node name="StaticBody2D" type="StaticBody2D" parent="."]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"]
|
||||
position = Vector2( 8, 8 )
|
||||
position = Vector2( 2, 0.5 )
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
|
@ -110,13 +110,12 @@ anims/initial = SubResource( 4 )
|
|||
anims/open = SubResource( 3 )
|
||||
|
||||
[node name="Label" type="Label" parent="."]
|
||||
visible = false
|
||||
margin_left = -12.0
|
||||
margin_left = -18.0
|
||||
margin_top = -15.0
|
||||
margin_right = 28.0
|
||||
margin_right = 22.0
|
||||
margin_bottom = 5.0
|
||||
theme = SubResource( 5 )
|
||||
text = "0"
|
||||
text = "00"
|
||||
align = 1
|
||||
|
||||
[connection signal="animation_finished" from="AnimationPlayer" to="." method="_on_AnimationPlayer_animation_finished"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue