当前位置: 首页>>代码示例>>C++>>正文


C++ BodyNode::getSprite方法代码示例

本文整理汇总了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 ) );
}
开发者ID:mcodegeeks,项目名称:OpenKODE-Framework,代码行数:39,代码来源:SuperMarioClick.cpp


注:本文中的BodyNode::getSprite方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。