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


C++ Sprite3D::setPosition方法代码示例

本文整理汇总了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;
}
开发者ID:Skillath,项目名称:ET-Wars,代码行数:29,代码来源:LoadingLayer.cpp

示例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;
	}
}
开发者ID:jacket-code,项目名称:Cocos3DEditor,代码行数:49,代码来源:MainScene.cpp


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