A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
feat(editor): reorder animation frames + set a uniform duration
yhh0dc30a94905c
diff --git a/desktop/src/i18n/messages/tile.ts b/desktop/src/i18n/messages/tile.tsindex a916578ad..5b1d32a26 100644--- a/desktop/src/i18n/messages/tile.ts+++ b/desktop/src/i18n/messages/tile.ts@@ -211,6 +211,9 @@ export const tileMessages = defineMessages({'tile.anim.addFrames': { en: 'Click atlas tiles to add frames', zh: '点击图集瓦片以添加帧' },'tile.anim.appendFrames': { en: 'Click atlas tiles to append frames', zh: '点击图集瓦片以追加帧' },'tile.anim.clear': { en: 'Clear animation', zh: '清除动画' },+ 'tile.anim.reorderTip': { en: '#{tile} · drag to reorder', zh: '#{tile} · 拖动可重排' },+ 'tile.anim.setAll': { en: 'All', zh: '统一' },+ 'tile.anim.setAllTip': { en: 'Set every frame to one duration (uniform speed)', zh: '把所有帧设为同一时长(统一速度)' },'tile.preview': { en: 'Preview', zh: '预览' },// — New-Tilemap picker dialog —diff --git a/desktop/src/panels/TilesetEditor.tsx b/desktop/src/panels/TilesetEditor.tsxindex aa293b9b0..c7dbd7f75 100644--- a/desktop/src/panels/TilesetEditor.tsx+++ b/desktop/src/panels/TilesetEditor.tsx@@ -554,6 +554,18 @@ export function TilesetEditor() {const setFrames = (frames: TilesetAnimFrame[]) => {if (animTile != null) TilesetCommands.setTileAnimation(animTile, frames);};+ // Drag a frame thumbnail to reorder the sequence (append-only authoring otherwise meant+ // deleting and re-adding to fix the order).+ const frameDragFrom = useRef<number | null>(null);+ const [frameDropIdx, setFrameDropIdx] = useState<number | null>(null);+ const moveFrame = (from: number, to: number) => {+ if (from === to) return;+ const next = [...animFrames];+ const [m] = next.splice(from, 1);+ next.splice(to, 0, m);+ setFrames(next);+ };+ const setAllDurations = (ms: number) => setFrames(animFrames.map((g) => ({ ...g, durationMs: ms })));/** Atlas crop for a tile id at thumbnail size (shared with the painter palette). */const THUMB = 26;const atlas: TileAtlas | null = texUrl && natural@@ -818,8 +830,25 @@ export function TilesetEditor() {<span className="ts-astat">#{animTile}</span><span className="ts-sep" />{animFrames.map((f, i) => (- <span key={`${i}-${f.tile}`} className="ts-frame">- <span className="ts-fthumb" style={thumb(f.tile)} title={`#${f.tile}`} />+ <span+ key={`${i}-${f.tile}`}+ className={'ts-frame' + (frameDropIdx === i ? ' drop' : '')}+ onDragOver={(e) => { if (frameDragFrom.current == null) return; e.preventDefault(); setFrameDropIdx(i); }}+ onDragLeave={() => setFrameDropIdx((d) => (d === i ? null : d))}+ onDrop={(e) => {+ e.preventDefault();+ setFrameDropIdx(null);+ const from = frameDragFrom.current;+ frameDragFrom.current = null;+ if (from != null && from !== i) moveFrame(from, i);+ }}+ >+ <span+ className="ts-fthumb ts-fgrab" style={thumb(f.tile)} title={t('tile.anim.reorderTip', { tile: f.tile })}+ draggable+ onDragStart={(e) => { frameDragFrom.current = i; e.dataTransfer.effectAllowed = 'move'; }}+ onDragEnd={() => { frameDragFrom.current = null; setFrameDropIdx(null); }}+ /><inputkey={`${animTile}-${i}-${f.durationMs}`}className="ts-fdur"@@ -847,6 +876,21 @@ export function TilesetEditor() {{animFrames.length === 0 ? t('tile.anim.addFrames') : t('tile.anim.appendFrames')}</span><span className="ts-grow" />+ {animFrames.length > 1 && (+ // Set every frame to one duration — a uniform-speed loop without editing each.+ <label className="ts-fall" title={t('tile.anim.setAllTip')}>+ <span>{t('tile.anim.setAll')}</span>+ <input+ className="ts-fdur" type="text" inputMode="numeric" spellCheck={false} placeholder="ms"+ onKeyDown={(e) => { if (e.key === 'Enter') (e.target as HTMLInputElement).blur(); }}+ onBlur={(e) => {+ const n = parseInt(e.target.value, 10);+ if (Number.isFinite(n) && n > 0) setAllDurations(n);+ e.target.value = '';+ }}+ />+ </label>+ )}{animFrames.length > 0 && (<button type="button" className="ts-trm" title={t('tile.anim.clear')} onClick={() => setFrames([])}><Trash2 size={13} />diff --git a/desktop/src/theme/tileset.css b/desktop/src/theme/tileset.cssindex 7cfbf34a0..0a787bd5c 100644--- a/desktop/src/theme/tileset.css+++ b/desktop/src/theme/tileset.css@@ -447,6 +447,10 @@.ts-ahint { color: var(--text-faint); font-size: var(--fs-xs); }.ts-astat { font-family: var(--mono); color: var(--text-dim); font-size: var(--fs-xs); }.ts-frame { display: inline-flex; align-items: center; gap: 3px; background: var(--srf-3); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 2px; }+.ts-frame.drop { border-color: var(--acc); box-shadow: -2px 0 0 var(--acc); }+.ts-fgrab { cursor: grab; }+.ts-fgrab:active { cursor: grabbing; }+.ts-fall { display: inline-flex; align-items: center; gap: 4px; color: var(--text-faint); font-size: var(--fs-2xs); }.ts-fthumb { width: 26px; height: 26px; border-radius: var(--r-xs); background-color: var(--srf-0); image-rendering: pixelated; flex: none; }.ts-apreview { width: 32px; height: 32px; border: 1px solid var(--star-line); }.ts-fdur { width: 44px; background: var(--inset); border: 1px solid var(--line); border-radius: var(--r-xs); color: var(--text); padding: 1px 3px; font-family: var(--mono); font-size: var(--fs-2xs); }