Changed movement animation again.
Movement starts on KeyDownEvent instead of KeyCharEvent.
This commit is contained in:
parent
3488bb3767
commit
8ef4e4ea3a
11
alui/menu.go
11
alui/menu.go
@ -48,6 +48,13 @@ func (m *Menu) Handle(e allg5.Event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch e := e.(type) {
|
switch e := e.(type) {
|
||||||
|
case *allg5.KeyDownEvent:
|
||||||
|
switch e.KeyCode {
|
||||||
|
case allg5.KeyEscape:
|
||||||
|
if onEscape := m.OnEscape; onEscape != nil {
|
||||||
|
onEscape()
|
||||||
|
}
|
||||||
|
}
|
||||||
case *allg5.KeyCharEvent:
|
case *allg5.KeyCharEvent:
|
||||||
switch e.KeyCode {
|
switch e.KeyCode {
|
||||||
case allg5.KeyDown:
|
case allg5.KeyDown:
|
||||||
@ -58,10 +65,6 @@ func (m *Menu) Handle(e allg5.Event) {
|
|||||||
if onClick := m.buttons[m.active].OnClick; onClick != nil {
|
if onClick := m.buttons[m.active].OnClick; onClick != nil {
|
||||||
onClick()
|
onClick()
|
||||||
}
|
}
|
||||||
case allg5.KeyEscape:
|
|
||||||
if onEscape := m.OnEscape; onEscape != nil {
|
|
||||||
onEscape()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
case *allg5.MouseMoveEvent:
|
case *allg5.MouseMoveEvent:
|
||||||
for i, btn := range m.buttons {
|
for i, btn := range m.buttons {
|
||||||
|
@ -29,7 +29,7 @@ func newEntityMoveAnimation(e *entity, to geom.Point) *entityMoveAnimation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *entityMoveAnimation) Animate(start, now time.Duration) bool {
|
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
|
progress := float32((now-start)*1000/duration) * .001
|
||||||
from, to := a.from.ToF32(), a.to.ToF32()
|
from, to := a.from.ToF32(), a.to.ToF32()
|
||||||
|
@ -141,7 +141,7 @@ func (l *playLevel) Handle(e allg5.Event) {
|
|||||||
l.end.Handle(e)
|
l.end.Handle(e)
|
||||||
default:
|
default:
|
||||||
switch e := e.(type) {
|
switch e := e.(type) {
|
||||||
case *allg5.KeyCharEvent:
|
case *allg5.KeyDownEvent:
|
||||||
switch e.KeyCode {
|
switch e.KeyCode {
|
||||||
case allg5.KeyEscape:
|
case allg5.KeyEscape:
|
||||||
l.showMenu = true
|
l.showMenu = true
|
||||||
|
Loading…
Reference in New Issue
Block a user