This site requires JavaScript, please enable it in your browser!
Greenfoot back
cxcpio
cxcpio wrote ...

2020/11/18

Stop Actors from being dragged

cxcpio cxcpio

2020/11/18

#
For some reason, all my actors are draggable by default and I was wondering if there was away to make them static? Thanks in advance
danpost danpost

2020/11/18

#
cxcpio wrote...
For some reason, all my actors are draggable by default and I was wondering if there was away to make them static?
In the greenfoot application, actors can be dragged around only while the scenario is in a stopped state. This allows the programmer the ability to adjust their positions (for a number of reasons). If uploaded or made into an executable, they will not be draggable. As the programmer, you can make it (while the scenario is stopped) so that dragging will not cause a re-positioning of an actor. They will still be draggable, but they will "snap" back to their initial position before the dragging when they are "dropped". Ask if details required.
cxcpio cxcpio

2020/11/19

#
Yes makes sense thank you. I want it to snap back to initial position when dragged. Can you explain how? Thank you
danpost danpost

2020/11/19

#
cxcpio wrote...
Yes makes sense thank you. I want it to snap back to initial position when dragged. Can you explain how? Thank you
Place the following in classes of actor types you want to "snap" back:
public void setLocation() {}
This will also prevent those types of actors from moving while the scenario is running as well, however.
You need to login to post a reply.