ci / release (push) Successful in 5m5s
ci-platforms / build (amd64, windows, windows-2022) (push) Skipped
ci-platforms / build (arm64, darwin, macos-15) (push) Skipped
ci-platforms / build (amd64, darwin, macos-15-intel) (push) Skipped
ci / checks (push) Successful in 4m41s
ci / build (amd64, linux, ubuntu-24.04) (push) Successful in 7m14s
The remaining editor strings and undo step names; component, field, enum, setting, diagnostic and Script API texts under schema.*, enum.*, setting.*, diag.* and api.*; the launcher, the in-game Settings View with a Language setting, the CLI and aego schema show --lang. Every documentation page has a .ru.md translation; the site has a full Russian tree with hreflang, a language switch and ru/llms.txt; aego docs check --lang ru. New doc.tutorial and doc.recipe icons. Fix: an animator restored by a rewind prepares its controller before the replayed step.
45 lines
1.8 KiB
Markdown
45 lines
1.8 KiB
Markdown
---
|
|
id: aego/input
|
|
summary: Читает действия, отдельные клавиши, мышь и геймпады, управляет контекстами ввода и даёт игрокам переназначать управление.
|
|
---
|
|
|
|
Используйте действия (`Pressed("Jump")`, `Axis2("Move")`), а не отдельные клавиши: действия назначаются в проекте, игроки могут их переназначить, и они работают с любым устройством. Варианты с `P` читают одного игрока. В песочнице документации нет устройств, поэтому пример читает нулевые значения и сообщает, что устройство не использовалось; в игре тот же код двигает узел. См. [Ввод](ref:input).
|
|
|
|
## Пример
|
|
|
|
```aes run
|
|
package demo
|
|
|
|
import (
|
|
"aego/input"
|
|
"aego/log"
|
|
)
|
|
|
|
script Player {
|
|
@export var Speed float = 4
|
|
|
|
var jumps int
|
|
var frames int
|
|
|
|
func Update(dt float) {
|
|
move := input.Axis2("Move")
|
|
node.SetPosition(node.Position() + move * Speed * dt)
|
|
if input.Pressed("Jump") {
|
|
jumps++
|
|
}
|
|
if input.Down(input.KeyF1) || input.MousePressed(input.MouseLeft) {
|
|
log.Info("cursor at " + string(input.MouseWorld().X) + ", " + string(input.MouseWorld().Y))
|
|
}
|
|
frames++
|
|
if frames % 60 == 0 {
|
|
device := input.ActiveDevice()
|
|
if device < 0 {
|
|
log.Info("no input yet; move " + string(move.X) + ", " + string(move.Y) + ", jumps " + string(jumps))
|
|
} else {
|
|
log.Info("device " + string(device) + ", jump is " + input.Glyph("Jump"))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
```
|