I’m trying to make a breakout style game as a project to learn JME with.
I’m trying to make the blocks with an array, but I really cant seem to get it to work.
My array code so far is:
(Gbox is a box geometry)
[java]
int[] topline = new int[10];
int i;
for (i=0; i < topline.length; i++){
Gbox.clone();
Gbox.move(i, i, i);
}
[/java]
Im sure I’m missing something pretty obvious but I’ve tried everything I can think of, so if someone could point me in the right direction I’d really appreciate it.
Make sure you attach Gbox.clone() to the rootnode either directly or to another node which is attached to the rootnode. Here is an example of creating multiple spatials with an array:
It may be worth picking up the JME beginner’s guide. I still don’t have it =( But… that’s what I get for being poor. From all accounts it brings you from not knowing how to make a game in JME to having a pretty solid foundation to making your own games. Not to mention, it actually helps support the dev/hosting/etc efforts that are out-of-pocket expenses atm (I believe).
Anyways, I’m really looking forward to getting a copy as soon as I can afford it. Maybe it will help?
Thanks a lot for all the help everyone! Its been really helpful and Ive nearly got it working now, but I’ve run into a second problem.
I get a line of boxes, which is what I want, and I’m trying to assign them random colors. So I have 5 different materials which I defined before the for loop, created a random number for each iteration in the for loop and have an if/else condition in the loop to decide which color the box should be depending on the random number. What happens however is I get a line of white boxes (my default cube material) and a few blue ones in the line which occupy the same space as some of the white ones so I get a kind of Z-fighting effect. I think the problem is somewhere in my if conditions, please could you take a quick look?
[java]
TLB = new Node();