本文整理汇总了C++中AABB::getCenterY方法的典型用法代码示例。如果您正苦于以下问题:C++ AABB::getCenterY方法的具体用法?C++ AABB::getCenterY怎么用?C++ AABB::getCenterY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AABB
的用法示例。
在下文中一共展示了AABB::getCenterY方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: hasReachedNode
bool OrthographicGridPathfinder::hasReachedNode(AnimatedSprite *sprite, PathNode destination)
{
AABB *spriteAABB = sprite->getBoundingVolume();
float xDiff = fabs(spriteAABB->getCenterX() - getColumnCenterX(destination.column));
float yDiff = fabs(spriteAABB->getCenterY() - getRowCenterY(destination.row));
bool xReached = xDiff < GRID_EPSILON;
bool yReached = yDiff < GRID_EPSILON;
return xReached && yReached;
}
示例2: getCollisionsSpriteSprite
void Physics::getCollisionsSpriteSprite( World *world,
CollidableObject *spriteA,
CollidableObject *spriteB,
float percentageOfFrameRemaining)
{
//vector<WorldLayer*> *layers = world->getLayers();
AABB *boundingVolumeA = spriteA->getBoundingVolume();
AABB *boundingVolumeB = spriteB->getBoundingVolume();
PhysicalProperties *ppA = spriteA->getPhysicalProperties();
PhysicalProperties *ppB = spriteB->getPhysicalProperties();
int centerXA = boundingVolumeA->getCenterX();
int centerXB = boundingVolumeB->getCenterX();
int centerYA = boundingVolumeA->getCenterY();
int centerYB = boundingVolumeB->getCenterY();
int widthA = boundingVolumeA->getWidth();
int widthB = boundingVolumeB->getWidth();
int heightA = boundingVolumeA->getHeight();
int heightB = boundingVolumeB->getHeight();
int vxA = ppA->getVelocityX();
int vxB = ppB->getVelocityX();
int vyA = ppA->getVelocityY();
int vyB = ppB->getVelocityY();
// A - B
if ((centerXB - (widthB/2)) > (centerXA + (widthA/2)))
{
//if(!((vxA - vxB) == 0)) {
// if(boundingVolumeA->overlapsX(boundingVolumeB)){
if(!((vxA - vxB) == 0)) {
int tx_first_contact = abs(((centerXB - (widthB/2)) - (centerXA + (widthA/2)))/(vxA - vxB));
int tx_last_contact = abs(((centerXB + (widthB/2)) - (centerXA - (widthA/2)))/(vxA - vxB));
if(tx_first_contact > percentageOfFrameRemaining)
{
//there`s no collision
}
else
{
if(!(vyA - vyB) == 0)
{
//there`s contact on X axis, so let`s see if there`s contact on y axis
int ty_first_contact = abs(((centerYB - (heightB/2)) - (centerYA + (heightA/2)))/(vyA - vyB));
//int ty_first_contact = boundingVolumeA->overlapsY(boundingVolumeB);
int ty_last_contact = abs(((centerYB + (heightB/2)) - (centerYA - (heightA/2)))/(vyA - vyB));
if(ty_first_contact > percentageOfFrameRemaining)
{
//there`s no collision
}
else
{
//there`s collision!
//add collision to vector
addCollisionSpriteSprite(spriteA, spriteB);
}
}
else
{
//none of them are not going anywhere up, so they must collide on x axis
//if they collide on y
//if(((centerYB + heightB/2) - (centerYA - heightA/2)) >= 0)
if(boundingVolumeA->overlapsY(boundingVolumeB))
{addCollisionSpriteSprite(spriteA, spriteB);}
}
// }
}
}
else
{
//the situation here is kind of special
//they could be stopped in X, or they could be walking in the same velocity
//in the second situation, we are cool because they wouldn`t collide anyway
//in the firt situation, they could colide (one on top of the other)
//because of this, we have to make sure that one is on top of the other
//and that they can collide on y axis
//boundingVolumeB->setWidth(boundingVolumeB->getWidth() *2);
if(boundingVolumeA->myOverlapsX(boundingVolumeB))// && !(boundingVolumeA->overlapsY(boundingVolumeB)))
{
//boundingVolumeB->setWidth(boundingVolumeB->getWidth()/2);
addCollisionSpriteSprite(spriteA, spriteB);
}
}
}
// B - A
else
{
if(!((vxB - vxA) == 0)) {
//.........这里部分代码省略.........