You Are Here:

Community: Developer Discussion Boards

#1 Old sprite mover - 2003-04-07, 14:55

Join Date: Mar 2003
Posts: 37
nodevelop
Offline
Registered User
hi
how can I set 2 state for a sprite.
I mean I have 2 image of the same sprite: spriteOn.png and spriteOff.png
I can simply draw them on the display using the paint method.
but how can I alternate them using a fixed time (about 500 ms)?
I tryied to use the wait and the timer method with no success.
a simply example code will be very wellcome.

thanks

eml
Reply With Quote

#2 Old 2003-04-07, 16:52

Join Date: Mar 2003
Posts: 7
gediman
Offline
Registered User
try to use System.currentTimeMillis() and check time while you repaint (if you use another thread to update) or simple - use timer. hmmm...but what do you want to do? an idea depends on expected result.

gediman
Reply With Quote

#3 Old 2003-04-07, 21:05

Join Date: Mar 2003
Posts: 8
thid
Offline
Registered User
A simple thread should do it... the thread is created by

Thread paintThread = new Swaper();
paintThread.start();

and the code for the thread:

private class Swaper extends Thread{
public Swaper (){
//constructor
}

public void run(){
this.setPriority(Thread.MIN_PRIORITY);
while (true){
something.repaint();
}

try{
this.sleep(500);
}catch (Exception e){
}
}

and instead of something.repaint();
in the thread you could have a method that swaps the images and repaints or something...
Last edited by thid : 2003-04-07 at 21:13.
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fdiscussionE2eforumE2enokiaE2ecomE2fforumE2fshowthreadE2ephpE3ftE3d134434X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE44iscussionQ qdcZtypeQUqfntypeZE44iscussionContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZentertainmentQ qfnZtopicQUqfnTopicZj2meQ qfnZtopicQUqfnTopicZjavaQ qfnZtopicQUqfnTopicZmediaQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE44iscussionQ qfnZtypeQUqfntypeZE44iscussionContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE44iscussionQ qrdfZtypeQUqfntypeZE44iscussionContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ