Dart Documentationgame_loopGameLoopKeyboard

GameLoopKeyboard class

A keyboard input. Has digital buttons corresponding to keyboard keys.

class GameLoopKeyboard extends GameLoopDigitalInput {
 /** The A key. */
 static const A = KeyCode.A;
 /** The B key. */
 static const B = KeyCode.B;
 /** The C key. */
 static const C = KeyCode.C;
 /** The D key. */
 static const D = KeyCode.D;
 /** The E key. */
 static const E = KeyCode.E;
 /** The F key. */
 static const F = KeyCode.F;
 /** The G key. */
 static const G = KeyCode.G;
 /** The H key. */
 static const H = KeyCode.H;
 /** The I key. */
 static const I = KeyCode.I;
 /** The J key. */
 static const J = KeyCode.J;
 /** The K key. */
 static const K = KeyCode.K;
 /** The L key. */
 static const L = KeyCode.L;
 /** The M key. */
 static const M = KeyCode.M;
 /** The N key. */
 static const N = KeyCode.N;
 /** The O key. */
 static const O = KeyCode.O;
 /** The P key. */
 static const P = KeyCode.P;
 /** The Q key. */
 static const Q = KeyCode.Q;
 /** The R key. */
 static const R = KeyCode.R;
 /** The S key. */
 static const S = KeyCode.S;
 /** The T key. */
 static const T = KeyCode.T;
 /** The U key. */
 static const U = KeyCode.U;
 /** The V key. */
 static const V = KeyCode.V;
 /** The W key. */
 static const W = KeyCode.W;
 /** The X key. */
 static const X = KeyCode.X;
 /** The Y key. */
 static const Y = KeyCode.Y;
 /** The Z key. */
 static const Z = KeyCode.Z;
 /** The Shift key. */
 static const SHIFT = KeyCode.SHIFT;
 /** The Control key. */
 static const CTRL = KeyCode.CTRL;
 /** The Alt key. */
 static const ALT = KeyCode.ALT;
 /** The Space key. */
 static const SPACE = KeyCode.SPACE;
 /** The Zero key. */
 static const ZERO = KeyCode.ZERO;
 /** The One key. */
 static const ONE = KeyCode.ONE;
 /** The Two key. */
 static const TWO = KeyCode.TWO;
 /** The Three key. */
 static const THREE = KeyCode.THREE;
 /** The Four key. */
 static const FOUR = KeyCode.FOUR;
 /** The Five key. */
 static const FIVE = KeyCode.FIVE;
 /** The Six key. */
 static const SIX = KeyCode.SIX;
 /** The Seven key. */
 static const SEVEN = KeyCode.SEVEN;
 /** The Eight key. */
 static const EIGHT = KeyCode.EIGHT;
 /** The Nine key. */
 static const NINE = KeyCode.NINE;
 /** The Tilde key. */
 static const TILDE = KeyCode.TILDE;
 /** The Enter key. */
 static const ENTER = KeyCode.ENTER;
 /** The Up key. */
 static const UP = KeyCode.UP;
 /** The Down key. */
 static const DOWN = KeyCode.DOWN;
 /** The Left key. */
 static const LEFT = KeyCode.LEFT;
 /** The Right key. */
 static const RIGHT = KeyCode.RIGHT;
 static final List<int> _buttonIds = [A, B, C,
                              D, E, F,
                              G, H, I,
                              J, K, L,
                              M, N, O,
                              P, Q, R,
                              S, T, U,
                              V, W, X,
                              Y, Z,
                              SHIFT,
                              CTRL,
                              ALT,
                              SPACE,
                              ZERO,
                              ONE,
                              TWO,
                              THREE,
                              FOUR,
                              FIVE,
                              SIX,
                              SEVEN,
                              EIGHT,
                              NINE,
                              TILDE,
                              ENTER,
                              UP,
                              DOWN,
                              LEFT,
                              RIGHT
                              ];

 GameLoopKeyboard(gameLoop) : super(gameLoop, _buttonIds);
}

Extends

GameLoopDigitalInput > GameLoopKeyboard

Static Properties

const A #

A = KeyCode.A

const ALT #

ALT = KeyCode.ALT

const B #

B = KeyCode.B

const C #

C = KeyCode.C

const CTRL #

CTRL = KeyCode.CTRL

const D #

D = KeyCode.D

const DOWN #

DOWN = KeyCode.DOWN

const E #

E = KeyCode.E

const EIGHT #

EIGHT = KeyCode.EIGHT

const ENTER #

ENTER = KeyCode.ENTER

const F #

F = KeyCode.F

const FIVE #

FIVE = KeyCode.FIVE

const FOUR #

FOUR = KeyCode.FOUR

const G #

G = KeyCode.G

const H #

H = KeyCode.H

const I #

I = KeyCode.I

const J #

J = KeyCode.J

const K #

K = KeyCode.K

const L #

L = KeyCode.L

const LEFT #

LEFT = KeyCode.LEFT

const M #

M = KeyCode.M

const N #

N = KeyCode.N

const NINE #

NINE = KeyCode.NINE

const O #

O = KeyCode.O

const ONE #

ONE = KeyCode.ONE

const P #

P = KeyCode.P

const Q #

Q = KeyCode.Q

const R #

R = KeyCode.R
RIGHT = KeyCode.RIGHT

const S #

S = KeyCode.S

const SEVEN #

SEVEN = KeyCode.SEVEN

const SHIFT #

SHIFT = KeyCode.SHIFT

const SIX #

SIX = KeyCode.SIX

const SPACE #

SPACE = KeyCode.SPACE

const T #

T = KeyCode.T

const THREE #

THREE = KeyCode.THREE

const TILDE #

TILDE = KeyCode.TILDE

const TWO #

TWO = KeyCode.TWO

const U #

U = KeyCode.U

const UP #

UP = KeyCode.UP

const V #

V = KeyCode.V

const W #

W = KeyCode.W

const X #

X = KeyCode.X

const Y #

Y = KeyCode.Y

const Z #

Z = KeyCode.Z

const ZERO #

ZERO = KeyCode.ZERO

Constructors

new GameLoopKeyboard(gameLoop) #

GameLoopKeyboard(gameLoop) : super(gameLoop, _buttonIds);

Properties

final Map<int, GameLoopDigitalButton> buttons #

inherited from GameLoopDigitalInput
buttons =
new Map<int, GameLoopDigitalButton>()

final GameLoop gameLoop #

inherited from GameLoopDigitalInput
gameLoop

Methods

void digitalButtonEvent(GameLoopDigitalButtonEvent event) #

inherited from GameLoopDigitalInput

Deliver an input event

void digitalButtonEvent(GameLoopDigitalButtonEvent event) {
 GameLoopDigitalButton button = buttons[event.buttonId];
 if (button == null) {
   return;
 }
 if (event.down) {
   if (button.down == false) {
     // Ignore repeated downs.
     button.framePressed = event.frame;
     button.timePressed = event.time;
   }
 } else {
   button.frameReleased = event.frame;
   button.timeReleased = event.time;
 }
}

bool isDown(int buttonId) #

inherited from GameLoopDigitalInput

Is buttonId down this frame?

bool isDown(int buttonId) {
 GameLoopDigitalButton button = buttons[buttonId];
 if (button == null) {
   return false;
 }
 return button.down;
}

bool isUp(int buttonId) #

inherited from GameLoopDigitalInput

Is buttonId up this frame?

bool isUp(int buttonId) {
 GameLoopDigitalButton button = buttons[buttonId];
 if (button == null) {
   return true;
 }
 return button.up;
}

bool pressed(int buttonId) #

inherited from GameLoopDigitalInput

Was buttonId just pressed down?

bool pressed(int buttonId) {
 GameLoopDigitalButton button = buttons[buttonId];
 if (button == null) {
   return false;
 }
 return button.framePressed == gameLoop.frame;
}

bool released(int buttonId) #

inherited from GameLoopDigitalInput

Was buttonId just released?

bool released(int buttonId) {
 GameLoopDigitalButton button = buttons[buttonId];
 if (button == null) {
   return false;
 }
 return button.frameReleased == gameLoop.frame;
}

double timePressed(int buttonId) #

inherited from GameLoopDigitalInput

Time buttonId was pressed.

double timePressed(int buttonId) {
 GameLoopDigitalButton button = buttons[buttonId];
 if (button == null) {
   return 0.0;
 }
 return button.timePressed;
}

double timeReleased(int buttonId) #

inherited from GameLoopDigitalInput

Time buttonId was released.

double timeReleased(int buttonId) {
 GameLoopDigitalButton button = buttons[buttonId];
 if (button == null) {
   return 0.0;
 }
 return button.timeReleased;
}