mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 13:07:26 +01:00
parent
ea99743e0d
commit
0e75540f8e
@ -114,6 +114,11 @@ func (g *Game) ResetDestination(viewportWidth, viewportHeight int) {
|
|||||||
g.binding.Call("SetDestination", nil, viewportWidth, viewportHeight)
|
g.binding.Call("SetDestination", nil, viewportWidth, viewportHeight)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *Game) IsKeyPressed(key driver.Key) bool {
|
||||||
|
// Pass a string of the key since both driver.Key value and XNA's key value are not reliable.
|
||||||
|
return g.binding.Call("IsKeyPressed", key.String()).Bool()
|
||||||
|
}
|
||||||
|
|
||||||
type RenderTarget2D struct {
|
type RenderTarget2D struct {
|
||||||
v js.Value
|
v js.Value
|
||||||
binding js.Value
|
binding js.Value
|
||||||
|
@ -18,9 +18,11 @@ package monogame
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/hajimehoshi/ebiten/internal/driver"
|
"github.com/hajimehoshi/ebiten/internal/driver"
|
||||||
|
"github.com/hajimehoshi/ebiten/internal/monogame"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Input struct {
|
type Input struct {
|
||||||
|
game *monogame.Game
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Input) CursorPosition() (x, y int) {
|
func (i *Input) CursorPosition() (x, y int) {
|
||||||
@ -56,7 +58,7 @@ func (i *Input) IsGamepadButtonPressed(id int, button driver.GamepadButton) bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (i *Input) IsKeyPressed(key driver.Key) bool {
|
func (i *Input) IsKeyPressed(key driver.Key) bool {
|
||||||
return false
|
return i.game.IsKeyPressed(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Input) IsMouseButtonPressed(button driver.MouseButton) bool {
|
func (i *Input) IsMouseButtonPressed(button driver.MouseButton) bool {
|
||||||
|
@ -39,6 +39,7 @@ func (u *UI) Run(context driver.UIContext) error {
|
|||||||
defer g.Dispose()
|
defer g.Dispose()
|
||||||
|
|
||||||
u.game = g
|
u.game = g
|
||||||
|
u.input.game = g
|
||||||
u.context = context
|
u.context = context
|
||||||
u.Graphics().(*graphics.Graphics).SetGame(g)
|
u.Graphics().(*graphics.Graphics).SetGame(g)
|
||||||
u.updateSize()
|
u.updateSize()
|
||||||
|
Loading…
Reference in New Issue
Block a user