Ejemplo n.º 1
0
void GameState::keyDown(app::KeyEvent event)
{
    int keycode = event.getCode();

    if (keycode == app::KeyEvent::KEY_ESCAPE) {
        mManager.setActiveState("title");
    }
    else if (keycode == app::KeyEvent::KEY_SPACE) {
        mManager.setActiveState(string("editor"));
    }
}
Ejemplo n.º 2
0
bool BasicViewTests::keyDown( app::KeyEvent &event )
{
	bool handled = true;
	switch( event.getCode() ) {
		case app::KeyEvent::KEY_c: {
			app::timeline().apply( mContainerView->getBackground()->getColorAnim(), ColorA( randFloat(), randFloat(), randFloat(), 1.0f ), ANIM_TIME, EaseInOutExpo() );
			break;
		}
		case app::KeyEvent::KEY_SPACE: {
			app::timeline().apply( mContainerView->animPos(), vec2( randFloat( -PADDING, PADDING ), randFloat( -PADDING, PADDING ) ), ANIM_TIME, EaseOutExpo() );
			break;
		}
		case app::KeyEvent::KEY_a: {
			float nextAlpha = mContainerView->getAlpha() > 0.4f ? 0.4f : 1.0f;
			app::timeline().apply( mContainerView->animAlpha(), nextAlpha, 2.0f, EaseInOutExpo() );
			break;
		}
		case app::KeyEvent::KEY_r: {
			if( ! mContainerView->getSubviews().empty() ) {
				auto lastChild = mContainerView->getSubviews().back();
				lastChild->removeFromParent();
			}
			break;
		}
		case app::KeyEvent::KEY_o: {
			float nextBorderWidth = randFloat( 1, 30 );
			app::timeline().apply( mBorderView->getLineWidthAnim(), nextBorderWidth, 0.6f, EaseOutExpo() );
			break;
		}
		case app::KeyEvent::KEY_w: {
			CI_LOG_V( "world positions, root: " << mContainerView->getWorldPos() );
			app::console() << "subviews: " << endl;
			for( const auto &view : mContainerView->getSubviews() )
				app::console() << "(" << view->getLabel() << ") " << view->getWorldPos() << endl;

			break;
		}
		case app::KeyEvent::KEY_i: {
			auto nextMode = ui::ImageScaleMode( ( (int)mImageView->getScaleMode() + 1 ) % ui::ImageScaleMode::NUM_MODES );
			CI_LOG_I( "setting scale mode to: " << nextMode );
			mImageView->setScaleMode( nextMode );
			break;
		}
		default:
			handled = false;
	}

	return handled;
}