I have the following block of code that draws a rectangle the way that I would like it to.
DrawNode *drawNode = DrawNode::create();
int x_position = visibleSize.width / 2;
int y_position = visibleSize.height / 2;
int width = 10;
int height = 10;
Point points[] = {Point(x_position, y_position), Point(x_position + width, y_position),
Point(x_position + width, y_position + height), Point(x_position, y_position + height)};
drawNode->drawPolygon(points, 4, Color4F::WHITE, 0, Color4F::WHITE);
drawNode->setPosition(Point(100, 100));
drawNode->setPosition(Point(250, 100));
this->addChild(drawNode);
I see in the documentation that there is a function I can call called setPosition(). When I add drawNode->setPosition(Point(100, 100)); it sets the position of the shape relative to the shape’s first vertex. Keeping track of the offset is easy enough if I want to move the shape around based on user input, but I was wondering if there was a simple method that I was missing that will allow me to move the shape without tracking the offset?