Play sprite animations from an animation asset worn through texture
An animation asset is a list of pictures (whole textures or frames) with frames per second and Loop/Once/Ping-pong playback. A sprite wears it through its texture property, so the picker, instance overrides and the Properties node work unchanged; there is no dedicated play node. A different animation starts from its first frame, the same one set again runs on, so a graph may choose Run or Idle every frame. The clock lives on the entity, not in props, which the world writes back as overrides. The AnimationSystem ticks before behaviors, and On animation finished fires once when a Once animation reaches its end. The Animation tab plays a preview above a frame strip: reorder by dragging, Delete, duplicate, + Frames, pause/resume, and wheel zoom about the pointer with pan and Fit. Scene and Container tabs show the first frame; edit mode has no clock. Right-clicking a texture creates an animation from its frames. Button now measures its label with the bold font it draws in, which cut the Animation tab and red dialog buttons short. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bf4191956c
commit
1135bf4562
39 files changed
+1935
-87
No files matched your search
+7
-2
@@ -27,6 +27,7 @@ import type { SceneObject } from '../src/core/model/SceneObject';
|
||||
import { deserializeProject, serializeProject } from '../src/core/store/serialize';
|
||||
import { BehaviorSystem } from '../src/runtime/systems/BehaviorSystem';
|
||||
import { CollisionSystem } from '../src/runtime/systems/CollisionSystem';
|
||||
import { AnimationSystem } from '../src/runtime/systems/AnimationSystem';
|
||||
import { Input } from '../src/runtime/systems/Input';
|
||||
import { World } from '../src/runtime/World';
|
||||
|
||||
@@ -230,6 +231,7 @@ export function runNode(
|
||||
|
||||
export interface WorldOptions {
|
||||
collisions?: boolean;
|
||||
animations?: boolean;
|
||||
behaviors?: boolean;
|
||||
}
|
||||
|
||||
@@ -242,7 +244,7 @@ export interface StartedWorld {
|
||||
frame(dt?: number): void;
|
||||
}
|
||||
|
||||
/** Instantiates the fixture's scene, optionally with a CollisionSystem and a BehaviorSystem (fed by those collisions). */
|
||||
/** Instantiates the fixture's scene, optionally with collisions, animations and a BehaviorSystem fed by both. */
|
||||
export function startWorld(
|
||||
fixture: SceneFixture,
|
||||
options: WorldOptions & { collisions: true },
|
||||
@@ -252,8 +254,11 @@ export function startWorld(fixture: SceneFixture, options: WorldOptions = {}): S
|
||||
const world = World.instantiate(fixture.project, fixture.sceneId);
|
||||
const collisions = options.collisions ? new CollisionSystem() : null;
|
||||
const input = new Input();
|
||||
const animations = options.animations ? new AnimationSystem() : null;
|
||||
if (collisions) world.addSystem(collisions);
|
||||
if (options.behaviors) world.addSystem(new BehaviorSystem(fixture.project, input, collisions));
|
||||
if (animations) world.addSystem(animations);
|
||||
if (options.behaviors)
|
||||
world.addSystem(new BehaviorSystem(fixture.project, input, { collisions, animations }));
|
||||
return {
|
||||
world,
|
||||
collisions,
|
||||
|
||||
Reference in new issue
Block a user