forked from team-sg/hero-mark-2
added a button :D
This commit is contained in:
parent
215d930022
commit
34b447cff1
5 changed files with 64 additions and 1 deletions
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=7 format=2]
|
[gd_scene load_steps=9 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://maps/map.gd" type="Script" id=1]
|
[ext_resource path="res://maps/map.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://objects/Camera2D.tscn" type="PackedScene" id=2]
|
[ext_resource path="res://objects/Camera2D.tscn" type="PackedScene" id=2]
|
||||||
|
@ -6,6 +6,8 @@
|
||||||
[ext_resource path="res://tilesets/t_rust.tres" type="TileSet" id=4]
|
[ext_resource path="res://tilesets/t_rust.tres" type="TileSet" id=4]
|
||||||
[ext_resource path="res://objects/player/player.tscn" type="PackedScene" id=5]
|
[ext_resource path="res://objects/player/player.tscn" type="PackedScene" id=5]
|
||||||
[ext_resource path="res://objects/enemy/robosnake.tscn" type="PackedScene" id=6]
|
[ext_resource path="res://objects/enemy/robosnake.tscn" type="PackedScene" id=6]
|
||||||
|
[ext_resource path="res://objects/enemy/steam.tscn" type="PackedScene" id=7]
|
||||||
|
[ext_resource path="res://objects/environment/switches/button.tscn" type="PackedScene" id=8]
|
||||||
|
|
||||||
[node name="Map" type="Node2D" groups=["map"]]
|
[node name="Map" type="Node2D" groups=["map"]]
|
||||||
pause_mode = 1
|
pause_mode = 1
|
||||||
|
@ -38,3 +40,14 @@ position = Vector2( 48, 152 )
|
||||||
position = Vector2( 232, 168 )
|
position = Vector2( 232, 168 )
|
||||||
left_up_boundry = 4.0
|
left_up_boundry = 4.0
|
||||||
right_down_boundry = 4.0
|
right_down_boundry = 4.0
|
||||||
|
|
||||||
|
[node name="Steam" parent="Enemies" groups=["button1"] instance=ExtResource( 7 )]
|
||||||
|
position = Vector2( 96, 152 )
|
||||||
|
|
||||||
|
[node name="StaticBody2D" type="StaticBody2D" parent="."]
|
||||||
|
|
||||||
|
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="StaticBody2D"]
|
||||||
|
polygon = PoolVector2Array( 145, 175, 183, 175, 184, 176, 184, 176, 144, 176, 144, 176 )
|
||||||
|
|
||||||
|
[node name="Button" parent="." instance=ExtResource( 8 )]
|
||||||
|
position = Vector2( 72, 168 )
|
||||||
|
|
|
@ -21,3 +21,6 @@ func _physics_process(delta):
|
||||||
active = true
|
active = true
|
||||||
collision_shape.disabled = false
|
collision_shape.disabled = false
|
||||||
particles.emitting = true
|
particles.emitting = true
|
||||||
|
|
||||||
|
func switch_action():
|
||||||
|
queue_free()
|
||||||
|
|
10
objects/environment/switches/button.gd
Normal file
10
objects/environment/switches/button.gd
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
extends "res://objects/environment/switches/switch.gd"
|
||||||
|
|
||||||
|
var pressed = false
|
||||||
|
|
||||||
|
func _on_ActivationArea_area_entered(area):
|
||||||
|
if !pressed:
|
||||||
|
if area.is_in_group("player"):
|
||||||
|
activate()
|
||||||
|
$Sprite.frame = 1
|
||||||
|
pressed = true
|
29
objects/environment/switches/button.tscn
Normal file
29
objects/environment/switches/button.tscn
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
[gd_scene load_steps=4 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://graphics/switches/button.png" type="Texture" id=1]
|
||||||
|
[ext_resource path="res://objects/environment/switches/button.gd" type="Script" id=2]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id=1]
|
||||||
|
extents = Vector2( 2, 0.5 )
|
||||||
|
|
||||||
|
[node name="Button" type="Node2D"]
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
type = "button"
|
||||||
|
|
||||||
|
[node name="Sprite" type="Sprite" parent="."]
|
||||||
|
position = Vector2( 4, 4 )
|
||||||
|
texture = ExtResource( 1 )
|
||||||
|
hframes = 2
|
||||||
|
|
||||||
|
[node name="StaticBody2D" type="StaticBody2D" parent="."]
|
||||||
|
|
||||||
|
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="StaticBody2D"]
|
||||||
|
polygon = PoolVector2Array( 1, 7, 0, 8, 1, 8, 7, 8, 8, 8, 7, 7 )
|
||||||
|
|
||||||
|
[node name="ActivationArea" type="Area2D" parent="."]
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="ActivationArea"]
|
||||||
|
position = Vector2( 4, 6.5 )
|
||||||
|
shape = SubResource( 1 )
|
||||||
|
|
||||||
|
[connection signal="area_entered" from="ActivationArea" to="." method="_on_ActivationArea_area_entered"]
|
8
objects/environment/switches/switch.gd
Normal file
8
objects/environment/switches/switch.gd
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
export var switch_index = 1
|
||||||
|
export var type = "switch"
|
||||||
|
|
||||||
|
func activate():
|
||||||
|
for object in get_tree().get_nodes_in_group(str(type) + str(switch_index)):
|
||||||
|
object.switch_action()
|
Loading…
Add table
Add a link
Reference in a new issue