Can any one explain difference between position and anchor point in cocos-2D with some example.I searched in google but cannot find good explanation,thanks in advance .
Can any one explain difference between position and anchor point in cocos-2D with some
Share
Suppose you have a square which is 10×10. If you say that you want to position it on your screen at position (50,40) then you need to know where that position refers to – the top left of your square, bottom left, etc.
The anchor point refers to this position. So, if your anchor point is (0,0) then the position (50,40) will be the position of the top left corner of your square.
If your anchor point is (10,0) then the position (50,40) will be the position of the top right corner of your square and so the top-left corner will be at (40,40).
So, the anchor point is the point that is positioned, and is then relative to your square.
Another example – suppose you have a building 100 floors high. Now, suppose you are a giant and you are 4 floors tall. If you are told to put your feet (that’s your anchor point) on the 3rd floor, then your head will be on the 7th floor. If you were told to put your head (that’s now your anchor point) on the 7th floor, then your feet would be on the 3rd. You are still in the same place, but your reference point (the anchor) has been changed.