Fixed virtual buttons.
This commit is contained in:
parent
19adf64c54
commit
1a393c0065
@ -63,8 +63,8 @@ func (a *app) Init(ctx ui.Context) error {
|
|||||||
virtual.RegisterKey("confirm", ui.KeyEnter, tins2021.MustCreateNamedTextureImage(textures, "return-key", drawReturnKey()))
|
virtual.RegisterKey("confirm", ui.KeyEnter, tins2021.MustCreateNamedTextureImage(textures, "return-key", drawReturnKey()))
|
||||||
virtual.RegisterKey("arrow-top-left", ui.KeyUp, tins2021.MustCreateNamedTextureImage(textures, "arrow-top-left-key", drawArrowKey(.75*geom.Pi)))
|
virtual.RegisterKey("arrow-top-left", ui.KeyUp, tins2021.MustCreateNamedTextureImage(textures, "arrow-top-left-key", drawArrowKey(.75*geom.Pi)))
|
||||||
virtual.RegisterKey("arrow-top-right", ui.KeyRight, tins2021.MustCreateNamedTextureImage(textures, "arrow-top-right-key", drawArrowKey(.25*geom.Pi)))
|
virtual.RegisterKey("arrow-top-right", ui.KeyRight, tins2021.MustCreateNamedTextureImage(textures, "arrow-top-right-key", drawArrowKey(.25*geom.Pi)))
|
||||||
virtual.RegisterKey("arrow-bottom-left", ui.KeyDown, tins2021.MustCreateNamedTextureImage(textures, "arrow-bottom-left-key", drawArrowKey(1.25*geom.Pi)))
|
virtual.RegisterKey("arrow-bottom-left", ui.KeyLeft, tins2021.MustCreateNamedTextureImage(textures, "arrow-bottom-left-key", drawArrowKey(1.25*geom.Pi)))
|
||||||
virtual.RegisterKey("arrow-bottom-right", ui.KeyLeft, tins2021.MustCreateNamedTextureImage(textures, "arrow-bottom-right-key", drawArrowKey(1.75*geom.Pi)))
|
virtual.RegisterKey("arrow-bottom-right", ui.KeyDown, tins2021.MustCreateNamedTextureImage(textures, "arrow-bottom-right-key", drawArrowKey(1.75*geom.Pi)))
|
||||||
virtual.RegisterKey("cancel", ui.KeyEscape, tins2021.MustCreateNamedTextureImage(textures, "arrow-left-key", drawArrowKey(geom.Pi)))
|
virtual.RegisterKey("cancel", ui.KeyEscape, tins2021.MustCreateNamedTextureImage(textures, "arrow-left-key", drawArrowKey(geom.Pi)))
|
||||||
|
|
||||||
virtual.Enabled = a.settings.Controls.Virtual
|
virtual.Enabled = a.settings.Controls.Virtual
|
||||||
|
@ -197,8 +197,8 @@ func (app *appContext) SetVirtualKeys(cancel, confirm, controls bool) {
|
|||||||
topRight = append(topRight, "confirm")
|
topRight = append(topRight, "confirm")
|
||||||
}
|
}
|
||||||
if controls {
|
if controls {
|
||||||
bottomRight = append(bottomRight, "arrow-top-right", "arrow-bottom-right")
|
bottomRight = append(bottomRight, "arrow-bottom-right", "arrow-top-right")
|
||||||
bottomLeft = append(bottomLeft, "arrow-top-left", "arrow-bottom-left")
|
bottomLeft = append(bottomLeft, "arrow-bottom-left", "arrow-top-left")
|
||||||
}
|
}
|
||||||
app.Virtual.SetControls(topLeft, topRight, bottomRight, bottomLeft)
|
app.Virtual.SetControls(topLeft, topRight, bottomRight, bottomLeft)
|
||||||
}
|
}
|
||||||
|
@ -80,6 +80,13 @@ func newLevelControl(app *appContext, ctx ui.Context, level *tins2021.Level) *le
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if app.Virtual.Enabled {
|
||||||
|
control.Controls[ui.KeyUp] = tins2021.DirectionUpLeft
|
||||||
|
control.Controls[ui.KeyLeft] = tins2021.DirectionDownLeft
|
||||||
|
control.Controls[ui.KeyDown] = tins2021.DirectionDownRight
|
||||||
|
control.Controls[ui.KeyRight] = tins2021.DirectionUpRight
|
||||||
|
}
|
||||||
|
|
||||||
control.Play(level)
|
control.Play(level)
|
||||||
|
|
||||||
return control
|
return control
|
||||||
|
@ -14,6 +14,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func drawArrowKey(a float64) image.Image {
|
func drawArrowKey(a float64) image.Image {
|
||||||
|
a = -a
|
||||||
const keyHeight_5 = .5 * tins2021.TextureSize
|
const keyHeight_5 = .5 * tins2021.TextureSize
|
||||||
const keyWidth_5 = .5 * tins2021.TextureSize
|
const keyWidth_5 = .5 * tins2021.TextureSize
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user