Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 how to make a object that can move automatically? or can I make something like a track for it?
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
ChenWei




PostPosted: Fri Dec 17, 2010 9:49 am   Post subject: how to make a object that can move automatically? or can I make something like a track for it?

how to make a object that can move automatically? or can I make something like a track for it?

thank you so much Smile
Sponsor
Sponsor
Sponsor
sponsor
DemonWasp




PostPosted: Fri Dec 17, 2010 10:19 am   Post subject: RE:how to make a object that can move automatically? or can I make something like a track for it?

By "object that can move automatically", I assume you mean an object that manipulates an image on-screen. The answer to your question depends on whether you're using AWT, Swing, or SWT (or another library) to do this.

The basic idea, however, is clear:
1. All objects that move, animate, or otherwise update themselves implement an update() method that takes a parameter specifying the amount of time since the last update.
2. Your main loop repeatedly determines the amount of time since its last iteration, then calls update(iterationTime) on all such objects.

If you want to develop a Path or Track class to handle where an object moves, that's separate. You will probably want to read about splines to help smooth the pathway, but your first implementation should just move linearly through a set of points, interpolating between them based on distance / speed / time.
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: