Skip to content

Commit 58e3e0d

Browse files
authored
Merge pull request #124 from endlessm/animation-blocks
Add blocks for AnimationPlayer
2 parents 70864aa + 296d132 commit 58e3e0d

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

addons/block_code/ui/picker/categories/category_factory.gd

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ const BUILTIN_PROPS: Dictionary = {
4747
"color": Color("03aa74"),
4848
"order": 61,
4949
},
50+
"Graphics | Animation":
51+
{
52+
"color": Color("03aa74"),
53+
"order": 62,
54+
},
5055
"Sounds":
5156
{
5257
"color": Color("e30fc0"),
@@ -630,6 +635,47 @@ static func get_built_in_blocks(_class_name: String) -> Array[Block]:
630635
"angular_velocity": "Physics | Velocity",
631636
}
632637

638+
"AnimationPlayer":
639+
var b = BLOCKS["statement_block"].instantiate()
640+
b.block_format = "Play {animation: STRING} {direction: OPTION}"
641+
b.statement = (
642+
"""
643+
if "{direction}" == "ahead":
644+
play({animation})
645+
else:
646+
play_backwards({animation})
647+
"""
648+
. dedent()
649+
)
650+
b.defaults = {
651+
"direction": OptionData.new(["ahead", "backwards"]),
652+
}
653+
b.tooltip_text = "Play the animation."
654+
b.category = "Graphics | Animation"
655+
block_list.append(b)
656+
657+
b = BLOCKS["statement_block"].instantiate()
658+
b.block_format = "Pause"
659+
b.statement = "pause()"
660+
b.tooltip_text = "Pause the currently playing animation."
661+
b.category = "Graphics | Animation"
662+
block_list.append(b)
663+
664+
b = BLOCKS["statement_block"].instantiate()
665+
b.block_format = "Stop"
666+
b.statement = "stop()"
667+
b.tooltip_text = "Stop the currently playing animation."
668+
b.category = "Graphics | Animation"
669+
block_list.append(b)
670+
671+
b = BLOCKS["parameter_block"].instantiate()
672+
b.variant_type = TYPE_BOOL
673+
b.block_format = "Is playing"
674+
b.statement = "is_playing()"
675+
b.tooltip_text = "Check if an animation is currently playing."
676+
b.category = "Graphics | Animation"
677+
block_list.append(b)
678+
633679
"Area2D":
634680
for verb in ["entered", "exited"]:
635681
var b = BLOCKS["entry_block"].instantiate()

0 commit comments

Comments
 (0)