本文整理汇总了C++中Sprite3D::setPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ Sprite3D::setPosition方法的具体用法?C++ Sprite3D::setPosition怎么用?C++ Sprite3D::setPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sprite3D
的用法示例。
在下文中一共展示了Sprite3D::setPosition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool LoadingLayer::init()
{
if(!LayerColor::init())
return false;
//Set the background color
LoadingLayer::setColor(Color3B::WHITE);
Size visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
Vec2 centerPoint = Utils::Utils::getCentralPoint(visibleSize, origin);
//Load a planet sprite to show while the game loads
Sprite3D* sprPlanet = Sprite3D::create("3d/meshes/MarsPlanet.obj", "3d/textures/MarsMap.jpg");
sprPlanet->setPosition(centerPoint);
Utils::Utils::setScale3D(10, sprPlanet);
sprPlanet->runAction(RepeatForever::create(RotateBy::create(3,Vec3(0,360,0))));
//Load the sprite with "LOADING..." string while the game loads
Text* loadingText = Text::create("LOADING...", DEFAULT_FONT, 34);
loadingText->setPosition(Vec2(sprPlanet->getPositionX(), SCREEN_FRAME_OFFSET));
//Add elements as layer children
addChild(sprPlanet);
addChild(loadingText);
return true;
}
示例2: CCPoint
void MainScene::update( float delta )
{
Size visibleSize = Director::getInstance()->getVisibleSize();
/*
if( _inputLayer->isKeyboradPushDown( KEY_CODE::KEY_ENTER ) == true )
{
log( "enter push" );
}
if( _inputLayer->isKeyboradPushDown( KEY_CODE::KEY_ESCAPE ) == true )
{
log( "escape push" );
}
*/
Sprite3D* sprite = FileLoadManager::getInstance()->getSprite3D( _modelArray.size() );
if( sprite != nullptr )
{
sprite->setPosition( visibleSize.width * 0.5f, visibleSize.height * 0.5f );
sprite->setScale( 300.0f );
addChild( sprite );
_modelArray.pushBack( sprite );
}
if( _selectModel != nullptr )
{
_selectModel->setScale( _selectModel->getScale() + _inputLayer->getMouseScroll() * 2.0f );
_selectModel->setPosition( CCPoint( _inputLayer->getMousePosition().x, _inputLayer->getMousePosition().y - (_selectModel->getContentSize().height * _selectModel->getScale()) * 0.5f ));
}
if( _inputLayer->isMousePush( InputLayer::MouseFlags::LEFT_PUSH_FlAG ) == true && _selectModel == nullptr)
{
for( int i = 0; i < (int)_modelArray.size(); i++ )
{
auto rect = _modelArray.at( i )->getBoundingBox();
if( rect.containsPoint( _inputLayer->getMousePosition() ) == true )
{
log( "Model Push" );
_selectModel = _modelArray.at( i );
}
}
}
else
{
_selectModel = nullptr;
}
}