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

2011/8/2

Moving objects to objects/location

1
2
danpost danpost

2011/8/6

#
davmac wrote...
the setRotation() is used to control the direction of movement
Thank you davmac, I have not yet used the Mover class and was un-aware that the rotation was used in the move() method to determine the direction of movement; but, then again, I guess it would have to, because the direction is not passed to the move() method. (+: Still learning :+)
Robto Robto

2011/8/6

#
Hi guys, Really appreciate your help and comments. Going to adjust the mouseClicked. I had to reset the setRotation to 0 each time, because when I tested the code without the "reset", the second time I move the actor, the actor add the value of angle to it's current angle. If it's current angle isn't 0, the actor rotates to far and doesn't go to the clicked place but to current rotation value + angle & distance.
danpost danpost

2011/8/6

#
Your statement 'setRotation(getRotation() + x);' says to add 'x' to the current rotation ('getRotation()') and set that value as the new rotation. Just change that statement to 'setRotation(x);' and you will not have to change rotation back to zero (until state reverts back to NEUTRAL_STATE). (see my previous note regarding this)
Robto Robto

2011/8/7

#
Hi guys, Code works like a charm. danmac: the hang was indeed due to the not specified move() value. Changing it to move(1.0) solved the "hanging". danpost: I adjusted the setRotation to setRotation(x) and thats work fine. I new actually keep the setRotation(0) in the code because I like the actor not turning better for now. Only funny thing is that the actor not always moves in a straight line. It somethings goes to the specified location in a curve which is funny to see. Next step is awareness and world population refinement. Have the resources appear next to eachother and make the actor aware of the resources in the world by going around them :)
You need to login to post a reply.
1
2