mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
parent
008ed26276
commit
f1fa8804d3
@ -182,12 +182,9 @@ func jump() bool {
|
|||||||
if inpututil.IsMouseButtonJustPressed(ebiten.MouseButtonLeft) {
|
if inpututil.IsMouseButtonJustPressed(ebiten.MouseButtonLeft) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if len(ebiten.Touches()) > 0 {
|
if len(inpututil.JustPressedTouches()) > 0 {
|
||||||
id := ebiten.Touches()[0].ID()
|
|
||||||
if inpututil.IsJustTouched(id) {
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,12 +249,19 @@ func GamepadButtonPressDuration(id int, button ebiten.GamepadButton) int {
|
|||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsJustTouched returns a boolean value indicating
|
// JustPressedTouches returns touch IDs that are created just in the current frame.
|
||||||
// whether the given touch is pressed just in the current frame.
|
|
||||||
//
|
//
|
||||||
// IsJustTouched is concurrent safe.
|
// JustPressedTouches is concurrent safe.
|
||||||
func IsJustTouched(id int) bool {
|
func JustPressedTouches() []int {
|
||||||
return TouchDuration(id) == 1
|
ids := []int{}
|
||||||
|
theInputState.m.RLock()
|
||||||
|
for id, s := range theInputState.touchStates {
|
||||||
|
if s == 1 {
|
||||||
|
ids = append(ids, id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
theInputState.m.RUnlock()
|
||||||
|
return ids
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsTouchJustReleased returns a boolean value indicating
|
// IsTouchJustReleased returns a boolean value indicating
|
||||||
|
Loading…
Reference in New Issue
Block a user