Size boxSize(100, 124);
ccPointSize(30);
ccDrawColor4B(255, 255, 255, 130);
ccDrawPoint(this->getPosition());
auto box = LayerColor::create(Color4B(255, 255, 0, 255));
box->setAnchorPoint(Vec2(0.5, 0.5));
box->setContentSize(boxSize);
box->ignoreAnchorPointForPosition(false);
box->setPosition(mPlayer->getBoundingBox().origin.x, mPlayer->getBoundingBox().origin.y);
this->addChild(box, 4);
ccPointSize(30);
ccDrawColor4B(255, 255, 255, 130);
ccDrawPoint(this->getPosition());
auto box = LayerColor::create(Color4B(255, 255, 0, 255));
box->setAnchorPoint(Vec2(0.5, 0.5));
box->setContentSize(boxSize);
box->ignoreAnchorPointForPosition(false);
box->setPosition(mPlayer->getBoundingBox().origin.x, mPlayer->getBoundingBox().origin.y);
this->addChild(box, 4);
}
直接添加代码即可
本文介绍使用 Cocos2d-x 游戏引擎进行绘制的基本操作,包括设置绘图尺寸、颜色、位置等关键步骤。通过具体代码演示如何创建并定位绘图层,实现精确的坐标定位。
322

被折叠的 条评论
为什么被折叠?



