Changed movement animation again.

Movement starts on KeyDownEvent instead of KeyCharEvent.
This commit is contained in:
Sander Schobers 2019-12-29 10:15:32 +01:00
parent 3488bb3767
commit 8ef4e4ea3a
3 changed files with 9 additions and 6 deletions

View File

@ -48,6 +48,13 @@ func (m *Menu) Handle(e allg5.Event) {
}
switch e := e.(type) {
case *allg5.KeyDownEvent:
switch e.KeyCode {
case allg5.KeyEscape:
if onEscape := m.OnEscape; onEscape != nil {
onEscape()
}
}
case *allg5.KeyCharEvent:
switch e.KeyCode {
case allg5.KeyDown:
@ -58,10 +65,6 @@ func (m *Menu) Handle(e allg5.Event) {
if onClick := m.buttons[m.active].OnClick; onClick != nil {
onClick()
}
case allg5.KeyEscape:
if onEscape := m.OnEscape; onEscape != nil {
onEscape()
}
}
case *allg5.MouseMoveEvent:
for i, btn := range m.buttons {

View File

@ -29,7 +29,7 @@ func newEntityMoveAnimation(e *entity, to geom.Point) *entityMoveAnimation {
}
func (a *entityMoveAnimation) Animate(start, now time.Duration) bool {
const duration = 270 * time.Millisecond
const duration = 210 * time.Millisecond
progress := float32((now-start)*1000/duration) * .001
from, to := a.from.ToF32(), a.to.ToF32()

View File

@ -141,7 +141,7 @@ func (l *playLevel) Handle(e allg5.Event) {
l.end.Handle(e)
default:
switch e := e.(type) {
case *allg5.KeyCharEvent:
case *allg5.KeyDownEvent:
switch e.KeyCode {
case allg5.KeyEscape:
l.showMenu = true