Skip to content

Commit

Permalink
update code-editor for animation
Browse files Browse the repository at this point in the history
  • Loading branch information
nighca committed Jul 2, 2024
1 parent 5a8d9b6 commit 464d1d2
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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: '位置' },
Expand Down Expand Up @@ -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: [
Expand Down Expand Up @@ -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}"`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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}'
}
}

Expand Down

0 comments on commit 464d1d2

Please sign in to comment.