• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Moving Multiple Objects

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi:
I'm currently taking my first Java Programming class. My current project involves the creation of 9 reindeer within an applet. Those reindeer have been created. Now I need to be able to move them collectively with a mouseEvent so that they follow the mouse. I can get them to be selected simultaneouslly, but they don't keep their spacing--when I select them with a mouse click, they end up piling up on top of each other.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Welcome to JavaRanch!
Presumably you're getting some x,y coordinates from the mouse event, and drawing the reindeer at those coordinates. What you'll need to do, simply stated, is use different x,y coordinates for each reindeer. You might simply use x+0, x+5, x+10 ... for the 1st, 2nd, 3rd reindeer, or you could do something more complex in which both the x and y coordinates varied for each reindeer, perhaps not even in such a linear way. But anyway, the solution to your problem is quite simple: don't draw them all in the same place!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic