Skip to content

Instantly share code, notes, and snippets.

@joshbc
Last active August 29, 2015 14:05
Show Gist options
  • Save joshbc/43795e8b8cfa2d3bc92a to your computer and use it in GitHub Desktop.
Save joshbc/43795e8b8cfa2d3bc92a to your computer and use it in GitHub Desktop.
cocos2d-x, debug CCSprite boundingBox()
void CCDrawNode::drawRect(const CCRect &rect, float radius,const ccColor3B &color){
ccColor4F color4 = ccc4FFromccc3B(color);
CCPoint pA = rect.origin;
CCPoint pB = ccp(rect.origin.x+rect.size.width,rect.origin.y);
CCPoint pC = ccp(rect.origin.x+rect.size.width,rect.origin.y+rect.size.height);;
CCPoint pD = ccp(rect.origin.x,rect.origin.y+rect.size.height);
drawSegment(pA,pB,radius,color4);
drawSegment(pD,pC,radius,color4);
drawSegment(pA,pD,radius,color4);
drawSegment(pB,pC,radius,color4);
}
void myLayer::onEnter()
{
CCDrawNode* node = CCDrawNode::create();
addChild(node,10,10000);
node->drawDot(worldPosition,5.0,ccc4FFromccc3B(ccBLACK));
CCRect cr = ccSprite->boundingBox();
node->drawRect(cr,5.0,ccBLACK);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment