Examples - Move Control Creation to separate method

This commit is contained in:
Marty Oehme 2018-07-20 18:19:57 +02:00
parent 8284e82dcf
commit bf16d96600

View file

@ -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));
}