File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Moving Objects Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Moving Objects" Watch "Moving Objects" New topic
Author

Moving Objects

Richard Jones
Greenhorn

Joined: May 24, 2006
Posts: 17
I have to move the position of an object in a box using x and y

Using the following is ok

public void moveTo(int xPos, intyPos)
{
this.setXPos(xPos);
this.setYPos(yPos);
this.update();

on interface use aSquare.moveTo(100,100);

all fine but need to make the square change its steps in ypos to 200 and back again to 100 using the interface comand aSquare.Bounce();

I have used so far
public void Bounce (int yPos)
{
this.setYpos(this.getYpos();
while (Ypos) < 199
Ypos++;
while (Ypos > 200)
Ypos-;

Am I on the right lines any help very greatful
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
You should reply to your original thread instead of starting a new one:

http://www.coderanch.com/t/403597/java/java/Moving-object

And before writing *any more* code, you should read that reference to the Swing timer class, or this part of the Swing tuorial http://java.sun.com/docs/books/tutorial/uiswing/misc/timer.html


There is no emoticon for what I am feeling!
Richard Jones
Greenhorn

Joined: May 24, 2006
Posts: 17
Sorry thought I had put the question in the wrong place
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Moving Objects
 
Similar Threads
change pixel value to cell coordinate
placing images in applets
Moving object
YPOS
How to implement my next waypoint for pathfinding.