TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
time and space
1.4k
31
57.1k
Reducing repetitive asset loading
Aug 25 2011 1:43 PM
Let's say I have the following code to load a sprite into a gameobject:
bot1 = new GameObject[bots.maxBots];
for (short i = 0; i < bots.maxBots; i++)
bot1[i] = new GameObject(
Content.Load<Texture2D>("Sprites\\bot1"));
bots.Add(bot1);
Is there anyway I can substitute the bot number with a variable and put it in a loop (to create 100 bot1s, for example). Something like this:
for (short i = 0; i < 100; i++
{
bot + i = new GameObject[bots.maxBots];
for (short i = 0; i < bots.maxBots; i++)
bot + i[i] = new GameObject(
Content.Load<Texture2D>("Sprites\\bot" + i));
bots.Add(bot + i);
}
Reply
Answers (
1
)
Car on a track
XNA Reference enabling