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


C++ KeyEvent::getCode方法代码示例

本文整理汇总了C++中KeyEvent::getCode方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyEvent::getCode方法的具体用法?C++ KeyEvent::getCode怎么用?C++ KeyEvent::getCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KeyEvent的用法示例。


在下文中一共展示了KeyEvent::getCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: keyUp

void PopGameApp::keyUp(KeyEvent event)
{
    if(event.getCode () == KeyEvent::KEY_UP)
    {
        plane->setKey(1,0);
        
    }else if(event.getCode () == KeyEvent::KEY_DOWN)
    {
        plane->setKey(1,1);
        
    }else if(event.getCode () == KeyEvent::KEY_LEFT)
    {
        plane->setKey(1,2);
        
    }else if(event.getCode () == KeyEvent::KEY_RIGHT)
    {
        plane->setKey(1,3);
        
    }else if(event.getCode () == KeyEvent::KEY_SPACE)
    {
        plane->setKey(1,4);
        
    }


}
开发者ID:neuroprod,项目名称:PopupGame,代码行数:26,代码来源:PopGameApp.cpp

示例2: keyDown

void FrustumCullingApp::keyDown( KeyEvent event )
{
	if( event.getChar() == 'f' ){
		setFullScreen( ! isFullScreen() );
	} else if( event.getChar() == '1' ){
		mShapeType = SPHERE;
	} else if( event.getChar() == '2' ){
		mShapeType = CUBE;
	} else if( event.getChar() == '3' ){
		mShapeType = POINT;
	} else if( event.getChar() == 'c' ){
		mIsWatchingCam = ! mIsWatchingCam;
	} else if( event.getChar() == '/' || event.getChar() == '?' ){
		mInfoPanel.toggleState();
	}
	
	
	if( event.getCode() == KeyEvent::KEY_UP ){
		mEyeDest += mEyeNormal * 40.0f;
	} else if( event.getCode() == KeyEvent::KEY_DOWN ){
		mEyeDest -= mEyeNormal * 40.0f;
	}
	
	if( event.getCode() == KeyEvent::KEY_LEFT ){
		mAngleDest += 0.1f;
	} else if( event.getCode() == KeyEvent::KEY_RIGHT ){
		mAngleDest -= 0.1f;
	}
}
开发者ID:arturoc,项目名称:Cinder,代码行数:29,代码来源:FrustumCullingApp.cpp

示例3:

void Willard_HW02_Linked_ListApp::keyDown(KeyEvent event)
{

	if(event.getCode() == KeyEvent::KEY_r){
		reverseList(sentinel);
	}

	char yup = event.getChar();
	if(yup == '/' || yup == '?')
	{
	if(showMenu){
		showMenu = false;
	} else{
		showMenu = true;
		}
	}

	if(event.getCode() == KeyEvent::KEY_SPACE){
		reverseList(sentinel);
	}

	if(event.getCode() == KeyEvent::KEY_UP){
		toTop();
	}
}
开发者ID:CaryWillard,项目名称:Willard_HW02_Linked_List,代码行数:25,代码来源:Willard_HW02_Linked_ListApp.cpp

示例4: if

/* The instructions say that pressing '?' should turn
the instructions on and off, so I went ahead and made
it so you can toggle the text.
-bakersc3
*/
void HW02App::keyDown(KeyEvent event)
{
	if(event.getChar() == '?')//If ? is pressed, set removeText to true
	{
		if(removeText == true)
			removeText = false;
		else if(removeText == false)
			removeText = true;
	}
	if(event.getCode() == KeyEvent::KEY_LEFT)//If left arrow key is pressed, travel to previous node
	{
		head = head->prev_;
	}
	if(event.getCode() == KeyEvent::KEY_RIGHT)
	{
		head = head->next_;
	}
		//Because of the order my nodes are drawn in, this appears to improperly reorder 
		//nodes in the background. It is just because my nodes are drawn in reverse order so
		//the current head node always appears on top
	if(event.getChar() == 'r')//If 'r' key is pressed, reverse the list
	{
		reverse(head);
	}
}
开发者ID:sbaker92,项目名称:HW02App,代码行数:30,代码来源:HW02App.cpp

示例5: keyDown

/*
	Checks for keyboard input from the user, also moves currently selected window
*/
void RoyalSocietyApp::keyDown(KeyEvent event) {
	// Matt: Added usage of the '/' key, because it's simpler to press
	// one button than two!
	if(event.getChar() == '?' || event.getChar() == '/')
	{
		if(help_)
			help_ = false;
		else help_ = true;
	}
	if(sentinel_->next_ != sentinel_)
	{
		// check for key input and move window accordingly
		if(event.getCode() == KeyEvent::KEY_RIGHT || event.getChar() == 'd')
		{
			sentinel_->next_->window_->pos_.x += moveSpeed_;
		}
		else if(event.getCode() == KeyEvent::KEY_LEFT || event.getChar() == 'a')
		{
			sentinel_->next_->window_->pos_.x -= moveSpeed_;
		}
		else if(event.getCode() == KeyEvent::KEY_UP || event.getChar() == 'w')
		{
			sentinel_->next_->window_->pos_.y -= moveSpeed_;
		}
		else if(event.getCode() == KeyEvent::KEY_DOWN || event.getChar() == 's')
		{
			sentinel_->next_->window_->pos_.y += moveSpeed_;
		}
	}
}
开发者ID:Dwyguy,项目名称:RoyalSociety-1,代码行数:33,代码来源:RoyalSocietyApp.cpp

示例6: keyUp

void reflection_animationApp::keyUp( KeyEvent event )
{
    if (event.getCode() == KeyEvent::KEY_TAB) {
        m_showInterface = !m_showInterface;
    }
    
    if (event.getCode() == KeyEvent::KEY_SPACE) {
        Surface frame = copyWindowSurface();
        stringstream filename;
        filename << "geometry_screenshot_" << (getElapsedFrames()) << ".png";
        writeImage( m_path / filename.str(), frame);
    }
    
    if (event.getCode() == KeyEvent::KEY_r) {
        if (m_recording) {
            m_movieWriter.finish();
        }
        if (!m_recording) {
            stringstream filename;
            filename << "geometry_animation_" << (getElapsedFrames()) << ".mov";
            m_movieWriter = qtime::MovieWriter( m_path / filename.str(), getWindowWidth(), getWindowHeight() );
        }
        m_recording = !m_recording;
    }
}
开发者ID:rapatski,项目名称:321,代码行数:25,代码来源:reflection_animationApp.cpp

示例7: keyDown

void SamplePlayerNodeTestApp::keyDown( KeyEvent event )
{
	if( event.getCode() == KeyEvent::KEY_c )
		testConverter();
	if( event.getCode() == KeyEvent::KEY_w )
		testWrite();
	if( event.getCode() == KeyEvent::KEY_s )
		mSamplePlayerNode->seekToTime( 1.0 );
}
开发者ID:DSDev-NickHogle,项目名称:Cinder,代码行数:9,代码来源:SampleTestApp.cpp

示例8: keyDown

void iosAppTestApp::keyDown( KeyEvent event )
{
	std::cout << "Key: " << event.getCharUtf32() << std::endl;
	if( event.getCode() == KeyEvent::KEY_BACKSPACE )
		console() << "backspace!" << std::endl;
	else if( event.getCode() == KeyEvent::KEY_RETURN )
		console() << "return!" << std::endl;

	mSecondWindowMessage = getKeyboardString();
}
开发者ID:CinimodStudio,项目名称:Cinder,代码行数:10,代码来源:iosAppTestApp.cpp

示例9: PushKey

void Key_Event::PushKey(KeyEvent& key_event)
{
	if (key_status->press_key.find(key_event.getCode()) == key_status->press_key.cend())
	{
		key_status->push_key.insert(key_event.getCode());
	}

	if (key_status->press_key.find(key_event.getCode()) == key_status->press_key.cend())
		key_status->press_key.insert(key_event.getCode());
}
开发者ID:ryohalon,项目名称:sample,代码行数:10,代码来源:Key_Event.cpp

示例10: keyDown

void DeviceTestApp::keyDown( KeyEvent event )
{
    TextInput *currentSelected = TextInput::getCurrentSelected();
    if( ! currentSelected )
        return;

    if( event.getCode() == KeyEvent::KEY_RETURN ) {
#if defined( CINDER_COCOA_TOUCH )
        hideKeyboard();
#endif

        try {
            if( currentSelected == &mSamplerateInput ) {
                int sr = currentSelected->getValue();
                CI_LOG_V( "updating samplerate from: " << mOutputDeviceNode->getSampleRate() << " to: " << sr );
                mOutputDeviceNode->getDevice()->updateFormat( audio::Device::Format().sampleRate( sr ) );
            }
            else if( currentSelected == &mFramesPerBlockInput ) {
                int frames = currentSelected->getValue();
                CI_LOG_V( "updating frames per block from: " << mOutputDeviceNode->getFramesPerBlock() << " to: " << frames );
                mOutputDeviceNode->getDevice()->updateFormat( audio::Device::Format().framesPerBlock( frames ) );
            }
            else if( currentSelected == &mNumInChannelsInput ) {
                int numChannels = currentSelected->getValue();
                CI_LOG_V( "updating nnm input channels from: " << mInputDeviceNode->getNumChannels() << " to: " << numChannels );
                setInputDevice( mInputDeviceNode->getDevice(), numChannels );
            }
            else if( currentSelected == &mNumOutChannelsInput ) {
                int numChannels = currentSelected->getValue();
                CI_LOG_V( "updating nnm output channels from: " << mOutputDeviceNode->getNumChannels() << " to: " << numChannels );
                setOutputDevice( mOutputDeviceNode->getDevice(), numChannels );
            }
            else if( currentSelected == &mSendChannelInput ) {
                if( mTestSelector.currentSection() == "send" || mTestSelector.currentSection() == "send stereo" )
                    setupTest( mTestSelector.currentSection() );
            }
            else
                CI_LOG_E( "unhandled return for string: " << currentSelected->mInputString );
        }
        catch( audio::AudioDeviceExc &exc ) {
            CI_LOG_E( "AudioDeviceExc caught, what: " << exc.what() );
            auto ctx = audio::master();
            mSamplerateInput.setValue( ctx->getSampleRate() );
            mFramesPerBlockInput.setValue( ctx->getFramesPerBlock() );
            return;
        }
    }
    else {
        if( event.getCode() == KeyEvent::KEY_BACKSPACE )
            currentSelected->processBackspace();
        else {
            currentSelected->processChar( event.getChar() );
        }
    }
}
开发者ID:ffimusic,项目名称:Cinder,代码行数:55,代码来源:DeviceTestApp.cpp

示例11: keyDown

void SimplePlaybackApp::keyDown(KeyEvent evt)
{
	if (evt.getCode() == KeyEvent::KEY_SPACE)
	{
		moviePlayer->pause();
	}
	else if (evt.getCode() == KeyEvent::KEY_q)
	{
		quit();
	}
}
开发者ID:num3ric,项目名称:Cinder-VLC,代码行数:11,代码来源:SimplePlaybackApp.cpp

示例12: keyUp

void LooperApp::keyUp(KeyEvent event)
{
	if (event.getCode() == KeyEvent::KEY_SPACE)
	{
		loop->toggleRecord();
	}
	if (event.getCode() == KeyEvent::KEY_RETURN)
	{
		loop->clear();
	}

}
开发者ID:MartinBspheroid,项目名称:Looper,代码行数:12,代码来源:LooperApp.cpp

示例13: keyDown

void CinderProjectionTestApp::keyDown( KeyEvent event )
{
	switch (event.getCode()) {
		case KeyEvent::KEY_1:
		case KeyEvent::KEY_2:
		case KeyEvent::KEY_3:
			mActiveCam = event.getCode() - KeyEvent::KEY_1;
			break;
		default:
			break;
	}
}
开发者ID:Maff-,项目名称:CinderProjectionTest,代码行数:12,代码来源:CinderProjectionTestApp.cpp

示例14: keyUp

void AvalancheApp::keyUp( KeyEvent event )
{
	if(event.getCode()==KeyEvent::KEY_RIGHT){
		player.setRight(false);
	}
	if(event.getCode()==KeyEvent::KEY_LEFT){
		player.setLeft(false);
	}
	if(event.getCode()==KeyEvent::KEY_UP){
		player.setJump(false);
	}
}
开发者ID:jonahryandavis,项目名称:Cinder-Stuff,代码行数:12,代码来源:AvalancheApp.cpp

示例15: keyDown

void CinderBoxFunApp::keyDown(KeyEvent event)
{
    // Cast the mouse position to a constant
    ConstVec pos = mLastMousePos;
    if (event.getCode() == KeyEvent::KEY_b) {
        addBox(pos);
    } else if (event.getCode() == KeyEvent::KEY_c) {
        addCircle(pos);
    } else if (event.getCode() == KeyEvent::KEY_t) {
        addTriangle(pos);
    }
}
开发者ID:samgreen,项目名称:Cinder-SimpleBox2D,代码行数:12,代码来源:CinderBoxFunApp.cpp


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