1

Currently working on a game (similar to a space defender game with random enemy spawns) and need the enemies to have a random.next attached to label the enemy. However I'm having trouble figuring a way to do so, since the enemy is also moving on its Y axis at a speed of 4; "position.Y = position.Y + 4. Also whats making this difficult is the fact that i need my bullets that collide with the enemy to somehow also delete the label, and refreshing the label with a new random number on the next spawned enemy.

Sadly I'm currently away from my work station, so i can't present any code, but as of this moment, the way I'm managing my enemy spawning is through a list, it loops to check if the list has < 5 in its .count, and if so, add another enemy with a random Y, and X position. My method of reseting an enemy after it reaches the bottom of the screen, is that once it hits Y == 950, the enemy is set to "isvisible = false", the list is then looped in a check ,where if an enemy is found with isvisible = false, it is removed from the list. You can say that the list is slightly useless, but I'm currently using it to limit the amount of spawns on screen.

kevin man
  • 297
  • 3
  • 10

1 Answers1

1

see Drawing Text with a Sprite, I would just create a Label string property in your enemy class set it to whatever you need to in its constructor, and then when you loop over your list it to draw it also draw the text that you assign when you create the enemy at whatever offset from the sprites location.

Casey Price
  • 768
  • 7
  • 16
  • wouldn't doing that only allow my label to spawn at the original location of the enemy, since the enemy is moving downwards, the label would be left behind; at the top of the screen. – kevin man Dec 11 '15 at 11:55
  • No, as long as you redraw the label sprite every-time you redraw your enemy with the new offset. – Casey Price Dec 11 '15 at 14:57