FeaturesPluginsDocs & SupportCommunityPartners

NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Multiple sprite/image instances

 
Post new topic   Reply to topic    NetBeans Forums -> Java ME Users
View previous topic :: View next topic  
Author Message
jim89



Joined: 07 Jul 2009
Posts: 2

PostPosted: Tue Jul 07, 2009 4:26 pm    Post subject: Multiple sprite/image instances Reply with quote

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
View user's profile Send private message MSN Messenger
jim89



Joined: 07 Jul 2009
Posts: 2

PostPosted: Fri Jul 10, 2009 12:22 am    Post subject: SOLVED Reply with quote

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
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> Java ME Users All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB