Created
November 8, 2012 12:54
-
-
Save kenpower/4038636 to your computer and use it in GitHub Desktop.
Create and use a List
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //creat a list of sprite objects | |
| List<Sprite> sprites=new List<Sprite>(); | |
| ... | |
| //populate a list of sprite objects | |
| for (int i = 0; i < 50; i++) | |
| { | |
| Sprite s = new Sprite(); | |
| s.SetRandomPosition(r,BattleFieldRect); | |
| s.SetRandomVelocity(r); | |
| sprites.Add(s); | |
| } | |
| ... | |
| //draw all the lements in a list | |
| spriteBatch.Begin(SpriteSortMode.Immediate, null, null, null, null, null, radarTrans); | |
| foreach (Sprite s in sprites) | |
| s.Draw(gameTime, spriteBatch, true); | |
| spriteBatch.End(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment