本文整理汇总了C++中cocos2d::PhysicsContact::setData方法的典型用法代码示例。如果您正苦于以下问题:C++ PhysicsContact::setData方法的具体用法?C++ PhysicsContact::setData怎么用?C++ PhysicsContact::setData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cocos2d::PhysicsContact
的用法示例。
在下文中一共展示了PhysicsContact::setData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setHit
bool GameScene::setHit(cocos2d::PhysicsContact &contact)
{
if (GameManager::sharedGameManager()->isGameLive == true)
{
PhysicsBody *a = contact.getShapeA()->getBody();
PhysicsBody *b = contact.getShapeB()->getBody();
float* v = new float[2];
v[0] = a->getVelocity().length(); // Created By An Unknown Source, Via Stack OverFlow
v[1] = b->getVelocity().length(); // Created By An Unknown Source, Via Stack OverFlow
contact.setData(v);
if ((1 == a->getCollisionBitmask() && 2 == b->getCollisionBitmask()) || (2 == a->getCollisionBitmask() && 1 == b->getCollisionBitmask()))// BACK TO FRONT FOR NOW
{
bool hit = true;
}
else
{
bool hit = false;
}
if (hit = true)
{
if ((a->getCollisionBitmask() == Paddle_Bitmask && b->getCollisionBitmask() == Ball_Bitmask) || (a->getCollisionBitmask() == Ball_Bitmask && b->getCollisionBitmask() == Paddle_Bitmask))
{
Ball::sharedBall()->AddToDampening(5000.0f);
SoundManager::sharedSoundManager()->PlaySoundEffect("ballRebound.mp3", false, 1.0f, 1.0f, 1.0f);
}
if ((a->getCollisionBitmask() == Brick_Bitmask && b->getCollisionBitmask() == Ball_Bitmask) || (a->getCollisionBitmask() == Ball_Bitmask && b->getCollisionBitmask() == Brick_Bitmask))
{
Ball::sharedBall()->AddToDampening(5000.0f);
GameManager::sharedGameManager()->AddToScore(1);
this->removeChild(contact.getShapeB()->getBody()->getNode());
Ball::sharedBall()->AddToAcceleration(5000);
//ScoreLabel->setString(StringUtils::format("%d", GameManager::sharedGameManager()->GetScore()));
Vec2 first = contact.getShapeA()->getBody()->getNode()->convertToWorldSpace(Vec2(50, 50));
x = first.x;
y = first.y;
this->schedule(schedule_selector(GameScene::SetPowerUp));
//level = 50;
if (level == 1)
{
number = number + 1;
CCLOG("number = %i", number);
brick.SetLevel(level);
//if (number == 5)
//{
// CCLOG("level 2");
// //level = 2;
// this->removeChild(contact.getShapeA()->getBody()->getNode());
//this->schedule(schedule_selector(GameScene::SetBrick));
//this->schedule(schedule_selector(GameScene::SetBall));
//}
}
else if (level == 2)
{
number = number + 1;
brick.SetLevel(level);
/*if (number == 5)
{
level = 3;
this->removeChild(contact.getShapeA()->getBody()->getNode());
this->schedule(schedule_selector(GameScene::SetBrick));
this->schedule(schedule_selector(GameScene::SetBall));
}*/
}
else if (level == 3)
{
number = number + 1;
brick.SetLevel(level);
/*if (number == 5)
{
level = 4;
this->removeChild(contact.getShapeA()->getBody()->getNode());
this->schedule(schedule_selector(GameScene::SetBrick));
this->schedule(schedule_selector(GameScene::SetBall));
}*/
}
else if (level == 4)
{
number = number + 1;
brick.SetLevel(level);
/*if (number == 5)
//.........这里部分代码省略.........