-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added looping path enemies and introduced tool mode.
- Loading branch information
1 parent
dd4bec6
commit 6de04c3
Showing
3 changed files
with
140 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
tool | ||
extends Path2D | ||
|
||
enum ANIMATION_TYPE { | ||
LOOP, | ||
BOUNCE | ||
} | ||
|
||
export(ANIMATION_TYPE) var animation_type setget set_animation_type | ||
export(int) var speed = 1 setget set_speed | ||
|
||
onready var animationPlayer: = $AnimationPlayer | ||
|
||
func set_animation_type(value): | ||
animation_type = value | ||
var ap = find_node("AnimationPlayer") | ||
if ap: play_updated_animation(ap) | ||
|
||
func set_speed(value): | ||
speed = value | ||
var ap = find_node("AnimationPlayer") | ||
if ap: ap.playback_speed = speed | ||
|
||
func _ready(): | ||
play_updated_animation(animationPlayer) | ||
|
||
func play_updated_animation(ap): | ||
match animation_type: | ||
ANIMATION_TYPE.LOOP: ap.play("MoveAlongPathLoop") | ||
ANIMATION_TYPE.BOUNCE: ap.play("MoveAlongPathBounce") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
[gd_scene load_steps=9 format=2] | ||
|
||
[ext_resource path="res://characters_packed.png" type="Texture" id=1] | ||
[ext_resource path="res://Hitbox.tscn" type="PackedScene" id=2] | ||
[ext_resource path="res://MovingSpikeEnemy.gd" type="Script" id=3] | ||
|
||
[sub_resource type="Curve2D" id=7] | ||
_data = { | ||
"points": PoolVector2Array( ) | ||
} | ||
|
||
[sub_resource type="CircleShape2D" id=2] | ||
radius = 8.0 | ||
|
||
[sub_resource type="Animation" id=6] | ||
resource_name = "MoveAlongPathBounce" | ||
length = 6.0 | ||
loop = true | ||
tracks/0/type = "value" | ||
tracks/0/path = NodePath("PathFollow2D:unit_offset") | ||
tracks/0/interp = 1 | ||
tracks/0/loop_wrap = true | ||
tracks/0/imported = false | ||
tracks/0/enabled = true | ||
tracks/0/keys = { | ||
"times": PoolRealArray( 0, 3 ), | ||
"transitions": PoolRealArray( 1, 1 ), | ||
"update": 0, | ||
"values": [ 0.0, 1.0 ] | ||
} | ||
|
||
[sub_resource type="Animation" id=4] | ||
resource_name = "MoveAlongPathLoop" | ||
length = 6.0 | ||
loop = true | ||
tracks/0/type = "value" | ||
tracks/0/path = NodePath("PathFollow2D:unit_offset") | ||
tracks/0/interp = 1 | ||
tracks/0/loop_wrap = true | ||
tracks/0/imported = false | ||
tracks/0/enabled = true | ||
tracks/0/keys = { | ||
"times": PoolRealArray( 0, 6 ), | ||
"transitions": PoolRealArray( 1, 1 ), | ||
"update": 0, | ||
"values": [ 0.0, 1.0 ] | ||
} | ||
|
||
[sub_resource type="Animation" id=5] | ||
length = 0.001 | ||
tracks/0/type = "value" | ||
tracks/0/path = NodePath("PathFollow2D:unit_offset") | ||
tracks/0/interp = 1 | ||
tracks/0/loop_wrap = true | ||
tracks/0/imported = false | ||
tracks/0/enabled = true | ||
tracks/0/keys = { | ||
"times": PoolRealArray( 0 ), | ||
"transitions": PoolRealArray( 1 ), | ||
"update": 0, | ||
"values": [ 1.0 ] | ||
} | ||
|
||
[node name="MovingSpikeEnemy" type="Path2D"] | ||
curve = SubResource( 7 ) | ||
script = ExtResource( 3 ) | ||
|
||
[node name="PathFollow2D" type="PathFollow2D" parent="."] | ||
rotate = false | ||
|
||
[node name="Enemy" type="Node2D" parent="PathFollow2D"] | ||
|
||
[node name="Sprite" type="Sprite" parent="PathFollow2D/Enemy"] | ||
texture = ExtResource( 1 ) | ||
region_enabled = true | ||
region_rect = Rect2( 192, 0, 24, 24 ) | ||
|
||
[node name="Hitbox" parent="PathFollow2D/Enemy" instance=ExtResource( 2 )] | ||
|
||
[node name="CollisionShape2D" type="CollisionShape2D" parent="PathFollow2D/Enemy/Hitbox"] | ||
shape = SubResource( 2 ) | ||
|
||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."] | ||
autoplay = "MoveAlongPathLoop" | ||
anims/MoveAlongPathBounce = SubResource( 6 ) | ||
anims/MoveAlongPathLoop = SubResource( 4 ) | ||
anims/RESET = SubResource( 5 ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters