Examples - Move Control Creation to separate method
This commit is contained in:
parent
8284e82dcf
commit
bf16d96600
1 changed files with 19 additions and 14 deletions
|
@ -98,22 +98,27 @@ void activate(MouseEvent e) {
|
|||
break;
|
||||
}
|
||||
if (ex.canvas != ex.loop.game.canvas) ex.loop.game.canvas = ex.canvas;
|
||||
querySelector(ex.query).append(new ButtonElement()
|
||||
..text = "start"
|
||||
..onClick.listen((e) {
|
||||
ex.loop.stop();
|
||||
ex.loop.start();
|
||||
}));
|
||||
querySelector(ex.query).append(new ButtonElement()
|
||||
..text = "stop"
|
||||
..onClick.listen((e) {
|
||||
ex.loop.stop();
|
||||
}));
|
||||
// querySelector('#reset').onClick.listen((e) => ex.loop.game.reset());
|
||||
// querySelector('#plus').onClick.listen((e) => _changeGrid(-5));
|
||||
// querySelector('#minus').onClick.listen((e) => _changeGrid(5));
|
||||
addControls(ex);
|
||||
} else {
|
||||
resetExample(ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void addControls(Example ex) {
|
||||
querySelector(ex.query).append(new DivElement()
|
||||
..append(new ButtonElement()
|
||||
..text = "Start"
|
||||
..onClick.listen((e) {
|
||||
ex.loop.stop();
|
||||
ex.loop.start();
|
||||
}))
|
||||
..append(new ButtonElement()
|
||||
..text = "Stop"
|
||||
..onClick.listen((e) {
|
||||
ex.loop.stop();
|
||||
})));
|
||||
// querySelector('#reset').onClick.listen((e) => ex.loop.game.reset());
|
||||
// querySelector('#plus').onClick.listen((e) => _changeGrid(-5));
|
||||
// querySelector('#minus').onClick.listen((e) => _changeGrid(5));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue