Skip to content

Add blocks for AnimationPlayer #124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions addons/block_code/ui/picker/categories/category_factory.gd
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ const BUILTIN_PROPS: Dictionary = {
"color": Color("03aa74"),
"order": 61,
},
"Graphics | Animation":
{
"color": Color("03aa74"),
"order": 62,
},
"Sounds":
{
"color": Color("e30fc0"),
Expand Down Expand Up @@ -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()
Expand Down
Loading