bevy-2d-animation
БесплатноБез исполняемых скриптовНе проверенBevy ECS skill for 2D sprite animation. Keywords: Bevy, sprite, animation, AnimationPlayer, AnimationClip, 2D.
от thedivergentai★ 1 019 звёзд на GitHubОб этом скилле
Bevy 2D animation
When to use
Load this when a 2D actor needs clip playback on a sprite entity. Pair with bevy-animation for the player and clip types. Pair with bevy-animation-graph when clips must blend.
ECS shape
- Components:
Sprite(bevy::sprite) on the visible entity.AnimationPlayerandAnimationTargetId/AnimatedBy(bevy::animation) link a clip to that entity. - Resources: clip assets are
AnimationCliphandles, not a global player. - Systems:
advance_animationsandanimate_targetsare the engine systems named on the animation page. Gameplay code should not reimplement them. - Schedule: those systems are engine-owned. Gameplay that reacts to a finished clip chains after them.
Playback choices
| Need | Bevy idiom |
|---|---|
| Frame cells | Sprite with texture_atlas: Some(TextureAtlas { .. }), or an AnimationClip curve. |
| Named cutout limb | AnimationTargetId::from_name / from_names selects which entity a curve writes. |
| Loop | ActiveAnimation::repeat sets RepeatAnimation::Forever. |
Scope
- Frame sheets use
Sprite::from_atlas_imageandTextureAtlas. Clip curves useanimated_field!plusAnimatableCurve. - A cutout limb is an entity with
AnimationTargetIdandAnimatedBypointing at the entity that ownsAnimationPlayer.
Examples
Atlas frame on a sprite. TextureAtlas.index is the cell.
fn spawn_sheet(
mut commands: Commands,
assets: Res<AssetServer>,
mut layouts: ResMut<Assets<TextureAtlasLayout>>,
) {
let layout = TextureAtlasLayout::from_grid(UVec2::splat(32), 4, 1, None, None);
let layout = layouts.add(layout);
let image = assets.load("actor.png");
commands.spawn((
Sprite::from_atlas_image(image, TextureAtlas { layout, index: 0 }),
FrameClock {
timer: Timer::from_seconds(0.12, TimerMode::Repeating),
frames: 4,
},
));
}
#[derive(Component)]
struct FrameClock {
timer: Timer,
frames: usize,
}
fn tick_frames(time: Res<Time>, mut sprites: Query<(&mut Sprite, &mut FrameClock)>) {
for (mut sprite, mut clock) in &mut sprites {
clock.timer.tick(time.delta());
if clock.timer.just_finished() {
if let Some(atlas) = sprite.texture_atlas.as_mut() {
atlas.index = (atlas.index + 1) % clock.frames;
}
}
}
}
Clip playback. The player stores an AnimationNodeIndex from the graph, not a raw clip handle.
use bevy::animation::animated_field;
use bevy::animation::{AnimatedBy, AnimationTargetId};
#[derive(Component)]
struct IdleNode(AnimationNodeIndex);
fn spawn_clip(
mut commands: Commands,
mut clips: ResMut<Assets<AnimationClip>>,
mut graphs: ResMut<Assets<AnimationGraph>>,
) {
let name = Name::new("actor");
let target = AnimationTargetId::from_name(&name);
let samples = UnevenSampleAutoCurve::new([
(0.0, Vec3::ZERO),
(0.4, Vec3::new(8.0, 0.0, 0.0)),
])
.expect("two samples");
let mut clip = AnimationClip::default();
clip.add_curve_to_target(
target,
AnimatableCurve::new(animated_field!(Transform::translation), samples),
);
let clip_handle = clips.add(clip);
let (graph, indices) = AnimationGraph::from_clips([clip_handle]);
let idle = indices[0];
let graph_handle = graphs.add(graph);
let player = commands
.spawn((
name,
Sprite::from_color(Color::WHITE, Vec2::splat(32.0)),
AnimationPlayer::default(),
AnimationGraphHandle(graph_handle),
target,
IdleNode(idle),
))
.id();
commands.entity(player).insert(AnimatedBy(player));
}
fn play_idle(mut actors: Query<(&mut AnimationPlayer, &IdleNode)>) {
for (mut player, idle) in &mut actors {
player.play(idle.0).repeat();
}
}
fn cutout_id(root: &Name, limb: &Name) -> AnimationTargetId {
AnimationTargetId::from_names([root, limb].into_iter())
}
Facing and frame ticks both write Sprite, so they share one chain.
fn face_keys(keys: Res<ButtonInput<KeyCode>>, mut sprites: Query<&mut Sprite>) {
let left = keys.pressed(KeyCode::KeyA);
let right = keys.pressed(KeyCode::KeyD);
if !left && !right {
return;
}
for mut sprite in &mut sprites {
sprite.flip_x = left;
}
}
#[derive(Component)]
struct SheetClock {
timer: Timer,
frames: usize,
}
fn advance_sheet(time: Res<Time>, mut sprites: Query<(&mut Sprite, &mut SheetClock)>) {
for (mut sprite, mut clock) in &mut sprites {
clock.timer.tick(time.delta());
if clock.timer.just_finished() {
if let Some(atlas) = sprite.texture_atlas.as_mut() {
atlas.index = (atlas.index + 1) % clock.frames;
}
}
}
}
pub struct SpriteAnimPlugin;
impl Plugin for SpriteAnimPlugin {
fn build(&self, app: &mut App) {
app.add_systems(Update,
Установить bevy-2d-animation в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл bevy-2d-animation?
Bevy ECS skill for 2D sprite animation. Keywords: Bevy, sprite, animation, AnimationPlayer, AnimationClip, 2D.
Как установить скилл bevy-2d-animation?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл bevy-2d-animation запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic