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

2014/11/22

Bug in setRotation method?

stevetone stevetone

2014/11/22

#
If I set a moving object's rotation to between 1 and 7 degrees of the sides or top of the World, travelling parallel to those surfaces, it tracks perfectly parallel. If I set the direction to more than 7 degrees from those surfaces, it will track away from the parallel surface, although at what looks like an exaggerated angle. Example: the ball, moving with a rotation of 5 degrees, will track left-to-right, parallel to the top edge of the world. I have inspected the object, and the rotation is properly set. If I change the rotation to 8, it tracks left-to-right, but at an angle that looks like it's closer to 20 degrees to the top edge of the world than 8. I am using the move method to move the ball at 4 pixels per cycle. Any ideas?
danpost danpost

2014/11/22

#
stevetone wrote...
I am using the move method to move the ball at 4 pixels per cycle. Any ideas?
The actor cannot move to locations in-between two adjacent pixels. When rotation is zero degrees, the actor will move 4 pixels right. The angle between the original location and the one below the pixel 4 right is about 14 degrees. Therefore, the change will occur between a rotation of 7 degrees and 8 degrees. For a visual of what I am saying, check out my Radial Graphs scenario.
stevetone stevetone

2014/11/23

#
I have not looked at your scenario yet, but your explanation makes sense. Thank you! Is there an alternative method that I should be using to move in a more precise manner? It's not that important, as I am just bouncing ball objects off the world edge, but it would be nice to know if there is a more advanced technique to be learned.
danpost danpost

2014/11/23

#
stevetone wrote...
Is there an alternative method that I should be using to move in a more precise manner? It's not that important, as I am just bouncing ball objects off the world edge, but it would be nice to know if there is a more advanced technique to be learned.
There are several helper classes to produce smoother and more precise appearing movement. I have a QActor class in my Asteroids w/improved QActor SuperClass scenario. Plus there are other around.
You need to login to post a reply.