bool ObstacleSimple::collision(BaseVehicle &vehicle) { float top, bottom; CCRect area = boundingBox(); top = area.getMinY() + getContentSize().height * 0.0f; bottom = top + getContentSize().height * 0.37f; float y = vehicle.getGroundCollision().getMinY() + (vehicle.getGroundCollision().getMaxY() - vehicle.getGroundCollision().getMinY()) * 0.25f; y = vehicle.getPlayerY() + vehicle.getContentSize().height * 0.3f * 0.5f; if(y < top || y > bottom) return false; // CCLog("Pass %f ; %f ; %f", y, top, bottom); return BaseObstacle::collision(vehicle); }
bool BaseObstacle::collision(BaseVehicle& vehicle) { Rect rectAir = vehicle.getAirCollision(); Rect rectFloor = vehicle.getGroundCollision(); unsigned int i; Rect area; for(i = 0; i < vCollision.size(); i++) { area = currentCollisionArea(vCollision[i]); if(area.intersectsRect(rectAir) && area.intersectsRect(rectFloor)) { return true; } } return false; }