• Post Reply Bookmark Topic Watch Topic
  • New Topic

Moving Objects  RSS feed

 
Richard Jones
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Richard Jones
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry thought I had put the question in the wrong place
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!