Ok, I was implementing a digital clock (with images) all is good
I displayed the initial startup (all good again)
When I then update the clockNode where seconds[##] is an array of objects that contain a node that I use to hold the textures. Then the image becomes a blank white square – viewable here http://gerbildrop.com/cm3demeter/xbgScreenshots/SimpleGameScreenShota0.jpg
The first image always displays, after that, it’s pretty random that they come back… sometimes never.
I may be updating too often, but still the images should be displaying no matter what I do to them right?
The seconds only update when the current second (from the calendar.getInstance() is different than the second before)
I’ve tried this with minutes as well, and the same thing happens, so I’m sure that it’s not b/c i’m updating “too often”. I’m sure it’s something else I’m doing.
I’ve removed all commented code from the code below.
public class DradisDigitalClock {
private static DradisNode[] seconds = new DradisNode[10];
private static DradisNode[] secondsPart2 = new DradisNode[10];
private static boolean initialized = false;
private static Node secondsNode = new Node("secondsNode");
public void load(DisplaySystem display) {
setArray(display, seconds, "seconds");
setArray(display, secondsPart2, "seconds2");
final Calendar c = Calendar.getInstance();
hour = c.get(Calendar.HOUR_OF_DAY);
minute = c.get(Calendar.MINUTE);
second = c.get(Calendar.SECOND);
drawClock();
}
private void setArray(DisplaySystem display, DradisNode[] numbers, String addtlName) {
for (int i = 0; i < 10; i++) {
switch (i) {
case 0:
numbers[0] = new DradisNode();
numbers[0].load(display, "zero" + addtlName + "Node", "zero" + addtlName + "Quad", "dradis/displays/clock/numbers/zero.png");
break;
case 1:
numbers[1] = new DradisNode();
numbers[1].load(display, "one" + addtlName + "Node", "one" + addtlName + "Quad", "dradis/displays/clock/numbers/one.png");
break;
case 2:
numbers[2] = new DradisNode();
numbers[2].load(display, "two" + addtlName + "Node", "two" + addtlName + "Quad", "dradis/displays/clock/numbers/two.png");
break;
case 3:
numbers[3] = new DradisNode();
numbers[3].load(display, "three" + addtlName + "Node", "three" + addtlName + "Quad", "dradis/displays/clock/numbers/three.png");
break;
case 4:
numbers[4] = new DradisNode();
numbers[4].load(display, "four" + addtlName + "Node", "four" + addtlName + "Quad", "dradis/displays/clock/numbers/four.png");
break;
case 5:
numbers[5] = new DradisNode();
numbers[5].load(display, "five" + addtlName + "Node", "five" + addtlName + "Quad", "dradis/displays/clock/numbers/five.png");
break;
case 6:
numbers[6] = new DradisNode();
numbers[6].load(display, "six" + addtlName + "Node", "six" + addtlName + "Quad", "dradis/displays/clock/numbers/six.png");
break;
case 7:
numbers[7] = new DradisNode();
numbers[7].load(display, "seven" + addtlName + "Node", "seven" + addtlName + "Quad", "dradis/displays/clock/numbers/seven.png");
break;
case 8:
numbers[8] = new DradisNode();
numbers[8].load(display, "eight" + addtlName + "Node", "eight" + addtlName + "Quad", "dradis/displays/clock/numbers/eight.png");
break;
case 9:
numbers[9] = new DradisNode();
numbers[9].load(display, "nine" + addtlName + "Node", "nine" + addtlName + "Quad", "dradis/displays/clock/numbers/nine.png");
break;
}
}
}
private void drawClock() {
if (second != secondStartTime) {
checkSeconds();
final Node secondOneNode = seconds[secondOne].getNode();
final Node secondTwoNode = secondsPart2[secondTwo].getNode();
secondOneNode.setLocalTranslation(secondOneVector);
secondTwoNode.setLocalTranslation(secondTwoVector);
clockNode.detachChildNamed("secondsNode");
secondsNode.attachChild(secondOneNode);
secondsNode.attachChild(secondTwoNode);
clockNode.attachChild(secondsNode);
}
}
public Node getNode() {
return clockNode;
}
private static float startTime;
public void update(float timer, Node node) {
final Calendar c = Calendar.getInstance();
hour = c.get(Calendar.HOUR_OF_DAY);
minute = c.get(Calendar.MINUTE);
second = c.get(Calendar.SECOND);
if(second != secondStartTime) {
node.detachChild(clockNode);
drawClock();
node.attachChild(clockNode);
clockNode.updateWorldData(timer);
node.updateWorldData(timer);
}
}
static int hour;
static int minute;
static int second;
static int secondStartTime;
static int secondOne;
static int secondTwo;
private static void checkSeconds() {
if (second > 9) {
if (second > 49) {
secondOne = 5;
secondTwo = second - 50;
} else if (second > 39) {
secondOne = 4;
secondTwo = second - 40;
} else if (second > 29) {
secondOne = 3;
secondTwo = second - 30;
} else if (second > 19) {
secondOne = 2;
secondTwo = second - 20;
} else {
secondOne = 1;
secondTwo = second - 10;
}
} else {
secondOne = 0;
secondTwo = second;
}
}
}
Any ideas?