0

i know that the question is a bit confused, but in Java, i want to, example, when a image go less than 0 x of the panel, appear smoothly at another side, like a loop.

I'm bit newbie at this hehe, i dont have enought reputation to post images, but there ya go the link.

https://i.stack.imgur.com/gwzno.png

public void move(){

    x += dx;
    y += dy;

    if(x + dx < 0) dx = 0;
    if(y + dy < 0) dy = 0;
    if(x + dx > getWidth()) dx = 0;
    if(y + dy > getHeight()) dy = 0;

}

this is the movement of my word's method.

Memphys
  • 13
  • 5
  • Consider posting a [minimal example program](http://stackoverflow.com/help/mcve) that illustrates what you've got and your current best attempt to solve your problem. – Hovercraft Full Of Eels Apr 15 '14 at 20:58
  • i edited, see if this is ok – Memphys Apr 15 '14 at 21:05
  • Use `Swing timer` to implement this logic. Please have a look at [Java Swing: how to smoothly animate/move component](http://stackoverflow.com/questions/21247776/java-swing-how-to-smoothly-animate-move-component) – Braj Apr 15 '14 at 21:17
  • hmm, thanks, i think its not what i wanted, but i will take a look. – Memphys Apr 15 '14 at 21:39

0 Answers0