本文整理汇总了C++中BodyNode::getSprite方法的典型用法代码示例。如果您正苦于以下问题:C++ BodyNode::getSprite方法的具体用法?C++ BodyNode::getSprite怎么用?C++ BodyNode::getSprite使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BodyNode
的用法示例。
在下文中一共展示了BodyNode::getSprite方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
KDvoid SuperMarioClick::update ( KDfloat fDelta )
{
// The number of iterations influence the accuracy of the physics simulation. With higher values the
// body's velocity and position are more accurately tracked but at the cost of speed.
// Usually for games only 1 position iteration is necessary to achieve good results.
KDfloat fTimeStep = 0.03f;
KDint32 nVelocityIterations = 8;
KDint32 nPositionIterations = 1;
m_pWorld->Step ( fTimeStep, nVelocityIterations, nPositionIterations );
// for each body, get its assigned BodyNode and update the sprite's position
for ( b2Body* pBody = m_pWorld->GetBodyList ( ); pBody != KD_NULL; pBody = pBody->GetNext ( ) )
{
BodyNode* pBodyNode = (BodyNode*) pBody->GetUserData ( );
if ( pBodyNode != KD_NULL )
{
CCSprite* pBodySprite = pBodyNode->getSprite ( );
if ( pBodySprite != KD_NULL )
{
// update the sprite's position to where their physics bodies are
pBodySprite->setPosition ( Helper::toPixels ( pBody->GetPosition ( ) ) );
pBodySprite->setRotation ( -CC_RADIANS_TO_DEGREES ( pBody->GetAngle ( ) ) );
// update the scoreboard if the ball fall on the floor
if ( dynamic_cast<Ball*> ( pBodyNode ) )
{
if ( pBodySprite->getPositionX ( ) < 20 )
{
m_nContackCount = 0;
}
}
}
}
}
m_pLabel->setString ( ccszf ( "TOTAL: %d", m_nContackCount ) );
}