本文整理汇总了C++中CCRect::getMinY方法的典型用法代码示例。如果您正苦于以下问题:C++ CCRect::getMinY方法的具体用法?C++ CCRect::getMinY怎么用?C++ CCRect::getMinY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCRect
的用法示例。
在下文中一共展示了CCRect::getMinY方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CCLOG
bool Cocos2dxAtlasNode::initWithTextureAtlas( CCTextureAtlas* textureAtlas , unsigned int quadIndex , const CCRect &sourceRect)
{
m_nQuadIndex = quadIndex;
m_tColorUnmodified = ccWHITE;
m_bIsOpacityModifyRGB = true;
m_tBlendFunc.src = CC_BLEND_SRC;
m_tBlendFunc.dst = CC_BLEND_DST;
m_pTextureAtlas = textureAtlas;
if (! m_pTextureAtlas)
{
CCLOG("cocos2d: Could not initialize Cocos2dxAtlasNode. Invalid Texture.");
return false;
}
m_pTextureAtlas->retain();
this->updateBlendFunc();
this->updateOpacityModifyRGB();
// shader stuff
setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTexture_uColor));
m_nUniformColor = glGetUniformLocation( getShaderProgram()->getProgram(), "u_color");
cocos2d::ccV3F_C4B_T2F_Quad & quad = textureAtlas->getQuads()[quadIndex];
quad.bl.vertices.x = sourceRect.getMinX();
quad.bl.vertices.y = sourceRect.getMinY();
quad.bl.vertices.z = 0;
quad.br.vertices.x = sourceRect.getMaxX();
quad.br.vertices.y = sourceRect.getMinY();
quad.br.vertices.z = 0;
quad.tl.vertices.x = sourceRect.getMinX();
quad.tl.vertices.y = sourceRect.getMaxY();
quad.tl.vertices.z = 0;
quad.tr.vertices.x = sourceRect.getMaxX();
quad.tr.vertices.y = sourceRect.getMaxY();
quad.tr.vertices.z = 0;
//*(cocos2d::CCPoint*)&quad.bl.vertices = CCPointApplyAffineTransform(*(cocos2d::CCPoint*)&(quad.bl.vertices), matrix);
//*(cocos2d::CCPoint*)&quad.br.vertices = CCPointApplyAffineTransform(*(cocos2d::CCPoint*)&(quad.br.vertices), matrix);
//*(cocos2d::CCPoint*)&quad.tl.vertices = CCPointApplyAffineTransform(*(cocos2d::CCPoint*)&(quad.tl.vertices), matrix);
//*(cocos2d::CCPoint*)&quad.tr.vertices = CCPointApplyAffineTransform(*(cocos2d::CCPoint*)&(quad.tr.vertices), matrix);
//quad.bl.vertices.y = -quad.bl.vertices.y;
//quad.br.vertices.y = -quad.br.vertices.y;
//quad.tl.vertices.y = -quad.tl.vertices.y;
//quad.tr.vertices.y = -quad.tr.vertices.y;
return true;
}
示例2: CCRectIntersection
CCRect CollisionEngine::CCRectIntersection(CCRect r1, CCRect r2) {
CCRect intersection;
intersection = CCRectMake(std::max(r1.getMinX(), r2.getMinX()),
std::max(r1.getMinY(), r2.getMinY()), 0, 0);
intersection.size.width = std::min(r1.getMaxX(), r2.getMaxX())
- intersection.getMinX();
intersection.size.height = std::min(r1.getMaxY(), r2.getMaxY())
- intersection.getMinY();
return intersection;
}
示例3: CCRectUnion
CCRect CCControlUtils::CCRectUnion(const CCRect& src1, const CCRect& src2)
{
CCRect result;
float x1 = MIN(src1.getMinX(), src2.getMinX());
float y1 = MIN(src1.getMinY(), src2.getMinY());
float x2 = MAX(src1.getMaxX(), src2.getMaxX());
float y2 = MAX(src1.getMaxY(), src2.getMaxY());
result.origin=ccp(x1,x2);
result.size=CCSizeMake(x2-x1, y2-y1);
return result;
}
示例4: collision
void ItemTortoiseFly::collision()
{
if (_bGodMode || _mario->_status == Mario::DEAD || _mario->_bGodMode)
{
return;
}
CCRect rcItem = boundingBox();
CCRect rcMario = _mario->boundingBox();
if (rcItem.intersectsRect(rcMario))
{
if (_status == NORMAL)
{
if (_mario->_status == Mario::FLY && _mario->_speedUp <= 0 && rcMario.getMinY() > rcItem.getMaxY() - rcItem.size.height / 2)
{
_status = DROPPING;
updateStatus();
}
else
{
_mario->die(false);
}
}
else if (_status == DROPPING)
{
// ... nothing to do
// 设计中,乌龟下降的速度应该大于mario下降的速度,所以不应该有碰撞
}
else if (_status == ONLAND)
{
if (_mario->_status == Mario::FLY && _mario->_speedUp <= 0 && rcMario.getMinY() > rcItem.getMaxY() - rcItem.size.height / 2)
{
_status = SLEEP;
updateStatus();
}
else
{
_mario->die(false);
}
}
else if (_status == SLEEP)
{
if (_bGodMode) return;
_status = CRAZY;
updateStatus();
}
}
}
示例5: AABB
bool JoinMembers::AABB(CCRect a, CCRect b)
{
//접하면 충돌로 봄.
//x축에대하여
if( a.getMaxX() < b.getMinX() ||
a.getMinX() > b.getMaxX() )
return false;
//y축에대하여
if(a.getMaxY() < b.getMinY() ||
a.getMinY() > b.getMaxY() )
return false;
return true;
}
示例6: keyboardWillShow
void KeyboardNotificationLayer::keyboardWillShow(CCIMEKeyboardNotificationInfo& info)
{
if (! m_pTrackNode)
{
return;
}
CCRect rectTracked = ccGetRect(m_pTrackNode);
// if the keyboard area doesn't intersect with the tracking node area, nothing need to do.
if (! rectTracked.intersectsRect(info.end))
{
return;
}
// assume keyboard at the bottom of screen, calculate the vertical adjustment.
float adjustVert = info.end.getMaxY() - rectTracked.getMinY();
CCLOG("TextInputTest:needAdjustVerticalPosition(%f)", adjustVert);
// move all the children node of KeyboardNotificationLayer
/*CCArray * children = getChildren();
CCNode * node = 0;
int count = children->count();
CCPoint pos;
for (int i = 0; i < count; ++i)
{
node = (CCNode*)children->objectAtIndex(i);
pos = node->getPosition();
pos.y += adjustVert;
node->setPosition(pos);
}*/
}
示例7: fixCollision
void GameLayer::fixCollision(COLL_STATE state, CCNode *role, cocos2d::CCRect collisionBox) {
CCRect roleBox = role->boundingBox();
switch (state) {
case COLL_STATE_LEFT: {
float fixedX = role->getPositionX();
fixedX += collisionBox.getMaxX() - roleBox.getMinX();
role->setPositionX(fixedX);
break;
}
case COLL_STATE_RIGHT: {
float fixedX = role->getPositionX();
fixedX -= roleBox.getMaxX() - collisionBox.getMinX();
role->setPositionX(fixedX);
break;
}
case COLL_STATE_TOP: {
float fixedY = role->getPositionY();
fixedY -= roleBox.getMaxY() - collisionBox.getMinY();
role->setPositionY(fixedY);
break;
}
case COLL_STATE_BOTTOM: {
float fixedY = role->getPositionY();
fixedY += collisionBox.getMaxY() - roleBox.getMinY();
role->setPositionY(fixedY);
break;
}
default:
break;
}
}
示例8: isScrollWindowNotOutSide
bool CAScrollView::isScrollWindowNotOutSide()
{
CCSize size = this->getBounds().size;
CCRect rect = m_pContainer->getFrame();
if (rect.getMinX() > 0.5f)
{
return true;
}
if ((rect.getMaxX() - size.width) < -0.5f)
{
return true;
}
float y_max = this->isHeaderRefreshing() ? _px(128) : 0.0f;
float y_min = (this->isFooterRefreshing() ? _px(128) : 0.0f) - size.height;
if (rect.getMinY() + y_max > 0.5f)
{
return true;
}
if (rect.getMaxY() + y_min < -0.5f)
{
return true;
}
return false;
}
示例9: keyboardWillShow
void CCEditBox::keyboardWillShow(CCIMEKeyboardNotificationInfo& info)
{
// CCLOG("CCEditBox::keyboardWillShow");
CCRect rectTracked = getRect(this);
//postion bug fix code -sunxy
if (m_pParent != NULL)
{
rectTracked.origin = m_pParent->convertToWorldSpace(rectTracked.origin);
}
// if the keyboard area doesn't intersect with the tracking node area, nothing needs to be done.
if (!rectTracked.intersectsRect(info.end))
{
CCLOG("needn't to adjust view layout.");
return;
}
// assume keyboard at the bottom of screen, calculate the vertical adjustment.
m_fAdjustHeight = info.end.getMaxY() - rectTracked.getMinY();
// CCLOG("CCEditBox:needAdjustVerticalPosition(%f)", m_fAdjustHeight);
if (m_pEditBoxImpl != NULL)
{
m_pEditBoxImpl->doAnimationWhenKeyboardMove(info.duration, m_fAdjustHeight);
}
}
示例10: intersectsRect
bool CCRect::intersectsRect(const CCRect& rect) const
{
return !( getMaxX() < rect.getMinX() ||
rect.getMaxX() < getMinX() ||
getMaxY() < rect.getMinY() ||
rect.getMaxY() < getMinY());
}
示例11: isCollide
static bool isCollide(const CCRect r1, const CCRect r2)
{
bool bRet = false;
if(r1.intersectsRect(r2))
{
double area1 = (r1.getMaxX()-r1.getMinX())*(r1.getMaxY()-r1.getMinY());
double area2 = (r2.getMaxX()-r2.getMinX())*(r2.getMaxY()-r2.getMinY());
float maxX = min(r1.getMaxX(), r2.getMaxX());
float minX = max(r1.getMinX(), r2.getMinX());
float maxY = min(r1.getMaxY(), r2.getMaxY());
float minY = max(r1.getMinY(), r2.getMinY());
double interarea = (maxX-minX) * (maxY-minY);
bRet = interarea * 5 > max(area1, area2);
}
return bRet;
}
示例12: collisionBoundingBox
CCRect Player::collisionBoundingBox() {
CCRect collisionBox = this->boundingBox();
CCPoint diff = ccpSub(this->desiredPosition, this->getPosition());
CCRect returnBoundingBox;
returnBoundingBox.setRect(collisionBox.getMinX() + diff.x, collisionBox.getMinY() + diff.y, collisionBox.getMaxX()-collisionBox.getMinX(), collisionBox.getMaxY()-collisionBox.getMinY());
return returnBoundingBox;
// return CCRect::intersectsRect(this->boundingBox, 2, 0);
}
示例13: inVisibleRigion
static bool inVisibleRigion(const CCRect& rect)
{
CCSize size = CCDirector::sharedDirector()->getVisibleSize();
return rect.getMinX() < size.width
&& rect.getMaxX() > 0
&& rect.getMinY() < size.height
&& rect.getMaxY() > 0;
}
示例14: printRect
static void printRect(const CCRect& rect)
{
char msg[128];
sprintf(msg, "%f, %f, %f, %f",
rect.getMinX(),
rect.getMinY(),
rect.getMaxX(),
rect.getMaxY());
CCLOG(msg);
}
示例15: command
bool Tank::command(enumOrder order)
{
float stepX = 0.0f;
float stepY = 0.0f;
float fRotation = getRotation();
switch (order)
{
case cmdNothing:
break;
case cmdGoUP:
stepY = 1.0f;
fRotation = 0.0f;
break;
case cmdGoDown:
stepY = -1.0f;
fRotation = 180.0f;
break;
case cmdGoLeft:
stepX = -1.0f;
fRotation = 270.0f;
break;
case cmdGoRight:
stepX = 1.0f;
fRotation = 90.0f;
break;
case cmdFire:
//调用子弹开火
return mBullet->fire();
default:
break;
}
//根据运行方向旋转坦克
setRotation(fRotation);
CCRect rect = this->boundingBox();
mMovedRect = CCRectMake(rect.getMinX() + stepX,
rect.getMinY() + stepY, rect.size.width, rect.size.height);
//检测地图上的碰撞
if (!mTileMapInfo->collisionTest(mMovedRect))
{
IsBlock = false;
return true;
}
//如果碰撞了就不要移动,设置为阻塞状态
mMovedRect = rect;
IsBlock = true;
return false;
}