examples/blocks: Use IsGamepadButtonJustPressed

This commit is contained in:
Hajime Hoshi 2018-04-30 03:43:50 +09:00
parent ea1444ea7e
commit 52dea245dc

View File

@ -18,6 +18,7 @@ import (
"fmt" "fmt"
"github.com/hajimehoshi/ebiten" "github.com/hajimehoshi/ebiten"
"github.com/hajimehoshi/ebiten/inpututil"
) )
type virtualGamepadButton int type virtualGamepadButton int
@ -104,7 +105,7 @@ func (c *gamepadConfig) Scan(gamepadID int, b virtualGamepadButton) bool {
if _, ok := c.assignedButtons[eb]; ok { if _, ok := c.assignedButtons[eb]; ok {
continue continue
} }
if ebiten.IsGamepadButtonPressed(gamepadID, eb) { if inpututil.IsGamepadButtonJustPressed(gamepadID, eb) {
c.buttons[b] = eb c.buttons[b] = eb
c.assignedButtons[eb] = struct{}{} c.assignedButtons[eb] = struct{}{}
return true return true