Files
aego/modules/animation/res/docs/try/AnimationPlayer.aes
sanspie 515f4ca1b3 Stage 11a: animation (D333–D340, D344, D354–D357)
Clips (.aeanim) and controllers (.aectrl) with importers, AnimationPlayer and Animator with crossfades, root motion and events on fixed steps, rewind support. Editor: Animation panel (dope sheet, curves, record, preview, trajectory), Animator panel, sprite sheet slicer and flipbooks, Programming workspace, export panel redesign. Motion 2D ledge climb. 11c: the component and Create palette.
2026-10-25 15:31:22 +03:00

57 lines
1.2 KiB
Plaintext

package demo
import (
"aego/anim"
"aego/debug"
"aego/input"
)
// Runner plays the built-in run clip; R plays it again, B reverses it.
script Runner {
var steps int
var dust float
func Update(dt float) {
a := node.Get<AnimationPlayer>()
if input.KeyPressed(input.KeyR) {
a.Play(nil)
}
if input.KeyPressed(input.KeyB) {
a.SetSpeed(-a.Speed)
}
p := node.WorldPosition()
if dust > 0 {
dust -= dt
debug.Rect(Rect{p.X - 0.5, p.Y + 0.45, dust * 4, 0.06}, Color{0.85, 0.85, 0.85, dust * 4})
}
debug.Text(Vec2{p.X - 2, p.Y - 1.4}, "R: replay B: reverse steps " + string(steps), Color{0.8, 0.8, 0.8, 1})
}
func OnAnimEvent(id int, payload float) {
if anim.EventName(id) == "Footstep" {
steps++
dust = 0.25
}
}
}
// Pendulum sways with the built-in bob clip; its gameplay event Hit lights the mark.
script Pendulum {
var flash float
func OnAnimEvent(id int, payload float) {
if anim.EventName(id) == "Hit" {
flash = payload
}
}
func Update(dt float) {
p := node.WorldPosition()
if flash > 0 {
flash -= dt * 2
}
debug.Rect(Rect{p.X - 0.25, p.Y - 0.6, 0.5, 0.2}, Color{1, 0.55, 0.3, 0.2 + flash})
debug.Text(Vec2{p.X - 1, p.Y - 1}, "Hit at the right turn", Color{0.8, 0.8, 0.8, 1})
}
}