This site requires JavaScript, please enable it in your browser!
Greenfoot back
Dialglex
Dialglex wrote ...

2014/8/13

Making an array

Dialglex Dialglex

2014/8/13

#
I am a newbie to greenfoot and I can't find any sources on how to make an array. I am making a TD game and and once a new enemy gets created, it waits 100 acts and creates the next one on the list. Sorry for being bad at this stuff, I am only 11 years old
lordhershey lordhershey

2014/8/13

#
1
2
3
4
5
6
Actor[] arr = new Actor[10];
 
for(int i=0;i<arr.length;i++)
{
  arr[i] = new Actor();
}
Actor is just whatever you want to use, this creates an array of ten elements, then it creates an object for every element of the new array. So you have to declare the array, create how big it is, then assign objects to each element.
NikZ NikZ

2014/8/13

#
Have you checked out the Java tutorials ?
Dialglex Dialglex

2014/8/14

#
Thanks for they help but I don't understand it at all. I seem to think I may of skipped something so I will just ask my brother.
gtogbes gtogbes

2014/8/14

#
hi guys am a student programmer please iwl need every pint of your advice in order to be grounded thank you all
You need to login to post a reply.