Results 1 to 4 of 4

Thread: move object

  1. #1
    melonka.sg is offline Member
    Join Date
    Jan 2011
    Posts
    3
    Rep Power
    0

    Default move object

    Hi,
    I am a beginner in a java. Could you help me? I don't know how to make object move.
    I have a small rectange. And It has to move there where is a cursor.
    I think I have to make:
    public void mouseMoved(mouseEvent e)
    {
    Point souradnice = e.getPoint();
    }

    I don't know what to type next.
    Please, help me.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,993
    Rep Power
    9

    Default

    Store the values where the rectangle is drawn in a class variable. Update that variable when the mouse is moved. Repaint.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    melonka.sg is offline Member
    Join Date
    Jan 2011
    Posts
    3
    Rep Power
    0

    Default

    I do it. But It does not work.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by melonka.sg View Post
    I do it.
    You do what? You show us no code to prove what you've done.


    But It does not work.
    It doesn't work how? Please read Kevin's link on how to ask smart questions before replying. You are hiding information from us that we need.

Similar Threads

  1. Move from console to GUI
    By MaxMonic in forum Advanced Java
    Replies: 2
    Last Post: 01-01-2011, 06:34 AM
  2. How To Move An Object On A Random Path
    By burakesme in forum Java 2D
    Replies: 1
    Last Post: 05-23-2010, 05:22 PM
  3. Help Using KeyListener to Move an Object
    By jjonesmu in forum New To Java
    Replies: 3
    Last Post: 04-20-2010, 10:35 PM
  4. Replies: 1
    Last Post: 04-20-2010, 10:31 PM
  5. How do you move a picture?
    By Addez in forum New To Java
    Replies: 6
    Last Post: 11-03-2009, 08:44 PM

Tags for this Thread

Posting Permissions

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