| View previous topic :: View next topic |
| Author |
Message |
jim89
Joined: 07 Jul 2009 Posts: 2
|
Posted: Tue Jul 07, 2009 4:26 pm Post subject: Multiple sprite/image instances |
|
|
Hi,
i am using a custom number font to display 12 individual units hit point values on the screen at the same time. So i have 10 images 0-9 and i can't figure out how to get say the image of "1" onto the screen in maybe 12 or even 24 different positons at the same time.
I belive the answer may lye in dynamicly creating the image sprites, so that the image can be displayed on the screen as many times as i like using different variable names. But i'm not sure how to do this.
Would be great is someone could explain how to do this. |
|
| Back to top |
|
 |
jim89
Joined: 07 Jul 2009 Posts: 2
|
Posted: Fri Jul 10, 2009 12:22 am Post subject: SOLVED |
|
|
Ok silly me,
Was over complicating the issue when i had the right answer from the start. For anyone asking the same question as me:
e.g.
private void paintSprites(Graphics g) {
Vector vOfSprites = new Vector();
*Declair your sprites here*
*loop through the vector as many times as needed adding each sprite each loop, you may need to be creative here*
for (int i = 0; i < 10; i++) {
Sprite temp = vOfSprites.elementAt(i); // the sprite location is copied
temp.paint(g); // the sprite is printed to screen
}
} |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|
|
|