Pochi
Pochi

Reputation: 13459

Anchor point in a Cocos2d-x DrawNode

I have been experimenting with draw nodes and so far i am getting the results i want but kind of using a trial and error way.

The main issue I have with draw nodes is that i can't seem to understand how the anchor point works.

Normally I would adjust the anchor point to the middle for example, and move a sprite somewhere, then the middle of the image of the sprite would be at the center exactly where the anchor point is.

However how does changing the anchor point really work in a draw node? Does it even work? (I am starting to believe it doesn't)

Does the anchor point affect the drawing? or just the final image? or nothing?

Right now when I draw something it seems to be drawn as if i was in a canvas drawing around (0,0) and moving the anchor point doesn't seem to do anything (regardless of if i move it before or after drawing)

Upvotes: 1

Views: 823

Answers (1)

Makalele
Makalele

Reputation: 7521

As far as I remember DrawNode is subclass of Node. And Node, by default does not have a size. If node doesn't have a size (technically it's 0x0) anchor points won't work, because for example center of 0x0 object it's just the same point. If you want to center your node you have to specify it's size using setContentSize method.

Upvotes: 7

Related Questions