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

2018/11/7

Smooth Mover class

allens allens

2018/11/7

#
Hi, can someone please explain me how smooth mover class actually works, and how it is changing the movement of our actor? It is kinda more teoretical question but I was realy curious how our actor can move for example 0.5 pixel, and how is this class really changing the behaviour of our actors. I have tried to find some documentation about this but unfortunately I couldnt find exact description of it. What is also interesting for me is when I made a subclass of Smooth Mover and when I started using overriden move method I get more than only ability of making more precised steps, I get the feeling that setting location also works different right know - I mean the way how my object is moving. I will put a picture below ilustrating what i exactly mean. Can someone in explain me how this mechanics really change? It is relly important for me to understand it because it could be the key for developing my semestral project :)
danpost danpost

2018/11/8

#
allens wrote...
can someone please explain me how smooth mover class actually works, and how it is changing the movement of our actor? It is kinda more teoretical question but I was realy curious how our actor can move for example 0.5 pixel, and how is this class really changing the behaviour of our actors.
You cannot have the actual location coordinate be anything other than whole numbers. What a smooth moving support class will do is track a location of an actor more precisely -- and place the actor at the "nearest" pixel to that stored location. This essential removes the loss of fractional movement that you get when tracking using a 1:1 ratio of whole numbers to pixels. That last part was stated that way because there are various ways to smooth out the movement -- using float or double values is one way (as in the SmoothMover class) and increasing the ratio, like to 100:1 is another (as in my QActor class, which provides more accurate spin as well as movement -- see my Support Classes collection).
You need to login to post a reply.