diff --git a/spx-gui/src/components/editor/code-editor/code-text-editor/tools/index.ts b/spx-gui/src/components/editor/code-editor/code-text-editor/tools/index.ts index feba55b6f..4e54eae1b 100644 --- a/spx-gui/src/components/editor/code-editor/code-text-editor/tools/index.ts +++ b/spx-gui/src/components/editor/code-editor/code-text-editor/tools/index.ts @@ -51,7 +51,7 @@ export const motionCategory: ToolCategory = { groups: [ { label: { en: 'Move', zh: '移动' }, - tools: [spx.move, spx.goto, spx.glide] + tools: [spx.step, spx.move, spx.goto, spx.glide] }, { label: { en: 'Position', zh: '位置' }, @@ -105,6 +105,10 @@ export const lookCategory: ToolCategory = { label: { en: 'Costume', zh: '造型' }, tools: [spx.costumeName, spx.costumeIndex, spx.setCostume, spx.nextCostume, spx.prevCostume] }, + { + label: { en: 'Animation', zh: '动画' }, + tools: [spx.animate] + }, { label: { en: 'Backdrop', zh: '背景' }, tools: [ @@ -258,6 +262,25 @@ export function getVariableCategory(project: Project): ToolCategory { }) if (project.selectedSprite != null) { + groups.push({ + label: { + en: `Animations of "${project.selectedSprite.name}"`, + zh: `${project.selectedSprite.name} 的动画` + }, + tools: project.selectedSprite.animations.map((animation) => { + const keyword = `"${animation.name}"` + return { + type: ToolType.variable, + target: ToolContext.sprite, + keyword, + desc: { en: `Animation "${animation.name}"`, zh: `动画 ${animation.name}` }, + usage: { + sample: keyword, + insertText: keyword + } + } + }) + }) groups.push({ label: { en: `Costumes of "${project.selectedSprite.name}"`, diff --git a/spx-gui/src/components/editor/code-editor/code-text-editor/tools/spx.ts b/spx-gui/src/components/editor/code-editor/code-text-editor/tools/spx.ts index 22c125f6c..52b514530 100644 --- a/spx-gui/src/components/editor/code-editor/code-text-editor/tools/spx.ts +++ b/spx-gui/src/components/editor/code-editor/code-text-editor/tools/spx.ts @@ -95,7 +95,10 @@ export const die: Tool = { callEffect: ToolCallEffect.write, target: ToolContext.sprite, keyword: 'die', - desc: { en: 'Let current sprite die', zh: '让当前精灵死亡' }, + desc: { + en: 'Let current sprite die. Animation bound to state "die" will be played.', + zh: '让当前精灵死亡,绑定到“死亡”状态的动画会被播放' + }, usage: { sample: 'die', insertText: 'die' @@ -201,6 +204,18 @@ export const prevCostume: Tool = { } } +export const animate: Tool = { + type: ToolType.method, + callEffect: ToolCallEffect.write, + target: ToolContext.sprite, + keyword: 'animate', + desc: { en: 'Play animation with given name', zh: '通过指定名称播放动画' }, + usage: { + sample: 'animate "jump"', + insertText: 'animate ${1:name}' + } +} + export const say: Tool = { type: ToolType.method, callEffect: ToolCallEffect.write, @@ -261,10 +276,25 @@ export const move: Tool = { callEffect: ToolCallEffect.write, target: ToolContext.sprite, keyword: 'move', - desc: { en: 'Move given steps, toward current heading', zh: '向当前朝向移动指定的步数' }, + desc: { en: 'Move given distance, toward current heading', zh: '向当前朝向移动指定的距离' }, usage: { sample: 'move 10', - insertText: 'move ${1:steps}' + insertText: 'move ${1:distance}' + } +} + +export const step: Tool = { + type: ToolType.method, + callEffect: ToolCallEffect.write, + target: ToolContext.sprite, + keyword: 'step', + desc: { + en: 'Step given distance, toward current heading. Animation bound to state "step" will be played', + zh: '向当前朝向行走指定的距离,绑定到“行走”状态的动画会被播放' + }, + usage: { + sample: 'step 10', + insertText: 'step ${1:distance}' } }