diff --git a/addons/block_code/ui/picker/categories/category_factory.gd b/addons/block_code/ui/picker/categories/category_factory.gd index b1c57009..ba85a11e 100644 --- a/addons/block_code/ui/picker/categories/category_factory.gd +++ b/addons/block_code/ui/picker/categories/category_factory.gd @@ -47,6 +47,11 @@ const BUILTIN_PROPS: Dictionary = { "color": Color("03aa74"), "order": 61, }, + "Graphics | Animation": + { + "color": Color("03aa74"), + "order": 62, + }, "Sounds": { "color": Color("e30fc0"), @@ -630,6 +635,47 @@ static func get_built_in_blocks(_class_name: String) -> Array[Block]: "angular_velocity": "Physics | Velocity", } + "AnimationPlayer": + var b = BLOCKS["statement_block"].instantiate() + b.block_format = "Play {animation: STRING} {direction: OPTION}" + b.statement = ( + """ + if "{direction}" == "ahead": + play({animation}) + else: + play_backwards({animation}) + """ + . dedent() + ) + b.defaults = { + "direction": OptionData.new(["ahead", "backwards"]), + } + b.tooltip_text = "Play the animation." + b.category = "Graphics | Animation" + block_list.append(b) + + b = BLOCKS["statement_block"].instantiate() + b.block_format = "Pause" + b.statement = "pause()" + b.tooltip_text = "Pause the currently playing animation." + b.category = "Graphics | Animation" + block_list.append(b) + + b = BLOCKS["statement_block"].instantiate() + b.block_format = "Stop" + b.statement = "stop()" + b.tooltip_text = "Stop the currently playing animation." + b.category = "Graphics | Animation" + block_list.append(b) + + b = BLOCKS["parameter_block"].instantiate() + b.variant_type = TYPE_BOOL + b.block_format = "Is playing" + b.statement = "is_playing()" + b.tooltip_text = "Check if an animation is currently playing." + b.category = "Graphics | Animation" + block_list.append(b) + "Area2D": for verb in ["entered", "exited"]: var b = BLOCKS["entry_block"].instantiate()