Results 1 to 2 of 2
  1. #1
    mustachMan is offline Member
    Join Date
    Dec 2009
    Posts
    33
    Rep Power
    0

    Default moving an object

    I am wodering how you would go about taking an object, such as a circle,
    and making it move, as if leftarrow is pressed then it moves to the left by 2 pixels.
    The one way i know how to do this is to use draw, and everytime the button is presed, it redraws it 2 pixels, and to keep it from having the other drawings before it, i made a rectangle the size of the screen to redraw it each time it executes so it gets rid of the ones before.
    I realized this isnt a very good way and would not work well with more advanced applications.
    IS there a way to move it around in a better way?

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,197
    Rep Power
    19

    Default

    to keep it from having the other drawings before it, i made a rectangle the size of the screen to redraw it each time it executes so it gets rid of the ones before.
    Looks rather like you're not performing custom painting correctly. Have you gone through the tutorial?

    db

Similar Threads

  1. Help with mouse moving object and colisions
    By macwadu in forum AWT / Swing
    Replies: 12
    Last Post: 07-01-2010, 11:18 PM
  2. Moving objects
    By rsjava24 in forum AWT / Swing
    Replies: 1
    Last Post: 02-26-2010, 10:47 AM
  3. Drawing moving object
    By dotabyss in forum Java 2D
    Replies: 1
    Last Post: 02-16-2010, 11:20 PM
  4. Moving Box
    By anilanar in forum New To Java
    Replies: 2
    Last Post: 08-30-2009, 12:29 PM
  5. Moving textboxes
    By GabWit in forum New To Java
    Replies: 2
    Last Post: 01-26-2009, 04:07 PM

Posting Permissions

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