From 1daf972fb9e3cd82475bd61a184c884a5c58eab7 Mon Sep 17 00:00:00 2001 From: Aaron Mueller Date: Thu, 16 May 2013 21:28:17 +0200 Subject: [PATCH] Rotate the chars in an infinite loop --- dev/lib/game/entities/namefield.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/dev/lib/game/entities/namefield.js b/dev/lib/game/entities/namefield.js index f0662f7..aca817c 100644 --- a/dev/lib/game/entities/namefield.js +++ b/dev/lib/game/entities/namefield.js @@ -31,16 +31,23 @@ ig.module( update: function() { // Switch chars - if (ig.input.pressed('prev-char') && this.highlightedChar > 0) + if (ig.input.pressed('prev-char') && this.highlightedChar > 0) { this.highlightedChar--; + } if (ig.input.pressed('next-char') && this.highlightedChar < this.numberOfChars-1) this.highlightedChar++; // Switch symbols - if (ig.input.pressed('prev-symbol') && this._name[this.highlightedChar] > 0) + if (ig.input.pressed('prev-symbol')) { this._name[this.highlightedChar]--; - if (ig.input.pressed('next-symbol') && this._name[this.highlightedChar] < this.symbols.length-1) + if (this._name[this.highlightedChar] < 0) + this._name[this.highlightedChar] = this.symbols.length-1; + } + if (ig.input.pressed('next-symbol')) { this._name[this.highlightedChar]++; + if (this._name[this.highlightedChar] == this.symbols.length) + this._name[this.highlightedChar] = 0; + } this.parent(); },