Add Setter Function to VariableRender Interface
This commit is contained in:
parent
1c3264f33c
commit
08c7e8ac1d
3 changed files with 18 additions and 5 deletions
|
@ -3,10 +3,11 @@ import 'package:browserloop/game/Game.dart';
|
|||
abstract class LoopExample {
|
||||
Game game;
|
||||
|
||||
void stop() {}
|
||||
void start() {}
|
||||
void stop();
|
||||
|
||||
void start();
|
||||
}
|
||||
|
||||
abstract class VariableUpdates {
|
||||
double MS_PER_UPDATE = 300.0;
|
||||
void setUpdates(double updateRate);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,8 @@ class FixedLoopVariableRender implements LoopExample, VariableUpdates {
|
|||
game.draw(interp);
|
||||
}
|
||||
|
||||
// Starting and stopping the loop for the example page
|
||||
// CONTROLS ON THE EXAMPLE PAGE
|
||||
// NOT NECESSARY FOR LOOP ITSELF
|
||||
void stop() {
|
||||
elapsed.stop();
|
||||
window.cancelAnimationFrame(id);
|
||||
|
@ -44,4 +45,9 @@ class FixedLoopVariableRender implements LoopExample, VariableUpdates {
|
|||
elapsed.reset();
|
||||
window.requestAnimationFrame(eventloop);
|
||||
}
|
||||
|
||||
@override
|
||||
void setUpdates(double updateRate) {
|
||||
MS_PER_UPDATE = updateRate;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,8 @@ class DirtyFlagRender implements LoopExample, VariableUpdates {
|
|||
dirty = false;
|
||||
}
|
||||
|
||||
// Starting and stopping the loop for the example page
|
||||
// CONTROLS ON THE EXAMPLE PAGE
|
||||
// NOT NECESSARY FOR LOOP ITSELF
|
||||
void stop() {
|
||||
elapsed.stop();
|
||||
window.cancelAnimationFrame(id);
|
||||
|
@ -50,4 +51,9 @@ class DirtyFlagRender implements LoopExample, VariableUpdates {
|
|||
elapsed.reset();
|
||||
window.requestAnimationFrame(eventloop);
|
||||
}
|
||||
|
||||
@override
|
||||
void setUpdates(double updateRate) {
|
||||
MS_PER_UPDATE = updateRate;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue