Skip to content

Commit 60920fa

Browse files
committed
all: adjust example
1 parent e605b2c commit 60920fa

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ DebugUI is a UI toolkit for Ebitengine applications, primarily intended for debu
88

99
DebugUI is based on [Microui](https://github.com/rxi/microui). The original Microui was developed by [@rxi](https://github.com/rxi/microui). The original Go port was developed by [@zeozeozeo](https://github.com/zeozeozeo) and [@Zyko0](https://github.com/Zyko0).
1010

11-
## Example go file
11+
## Example Go file
12+
1213
```go
1314
package main
1415

@@ -20,22 +21,23 @@ import (
2021
"github.com/hajimehoshi/ebiten/v2"
2122
)
2223

23-
const loopCount = 10
24-
2524
type Game struct {
26-
debugui debugui.DebugUI // Place a debugui instance on your Game
25+
debugui debugui.DebugUI
2726
}
2827

2928
func (g *Game) Update() error {
3029
if _, err := g.debugui.Update(func(ctx *debugui.Context) error {
3130
ctx.Window("Debugui Window", image.Rect(0, 0, 320, 240), func(layout debugui.ContainerLayout) {
32-
// Place all your widgets inside a ctx.Window
31+
// Place all your widgets inside a ctx.Window's callback.
3332
ctx.Text("Some text")
3433

35-
// If you ever need to make a loop to make widgets, use ctx.Loop
36-
34+
// Use Loop if you ever need to make a loop to make widgets.
35+
const loopCount = 10
3736
ctx.Loop(loopCount, func(index int) {
38-
ctx.Text(fmt.Sprintf("Index value is %d", index))
37+
// Specify a presssing-button event handler by On.
38+
ctx.Button(fmt.Sprintf("Button %d", index)).On(func() {
39+
fmt.Printf("Button %d is pressed")
40+
})
3941
})
4042
})
4143
return nil
@@ -46,7 +48,7 @@ func (g *Game) Update() error {
4648
}
4749

4850
func (g *Game) Draw(screen *ebiten.Image) {
49-
g.debugui.Draw(screen) // Draw debugui at the end
51+
g.debugui.Draw(screen)
5052
}
5153

5254
func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int) {

0 commit comments

Comments
 (0)