Tech
Forums
Jobs
Books
Events
Live
Interviews
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
1
Reply
Reducing repetitive asset loading
time and space
Aug 25 2011 1:43 PM
1.5k
Reply
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);
}
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
Car on a track
XNA Reference enabling