Beispiel #1
0
KeyBackground::KeyBackground(const Vec2f& initPosition, const ci::gl::Texture& closeKeyboard, const ci::ColorA& color)	
	:alphaColorPlashka(0.0f),
	showing(false),
	initPosition(initPosition),
	plashkaHeight(592.0f),
	bgHeight(1920.0f - 592.0f - initPosition.x),
	closeKeyboard(closeKeyboard)
{
#ifdef PORTRAIT_RES
	auto positionY = 885.0f - closeKeyboard.getHeight() * 0.5f;
#else
	auto positionY = 600.0f - closeKeyboard.getHeight() * 0.5f;
#endif

	auto positionX = (1080.0f - closeKeyboard.getWidth()) * 0.5f;

	btn = ImageButtonSpriteRef(new ImageButtonSprite(closeKeyboard));
	btn->setPosition(initPosition + Vec2f(positionX, positionY));
	addChild(btn);
	mainColor = color;
}
Beispiel #2
0
void SpriteSheet::init(ci::gl::Texture spriteImage, std::string xmlPath, int DataFormat){
		__spriteData = SpriteDataParser::parseSpriteData(xmlPath, DataFormat);
		__spriteImage = spriteImage;
		__currentFrame = 0;
		__totalFrames = __spriteData.size();
		__textureWidth = spriteImage.getWidth();
		__textureHeight = spriteImage.getHeight();

		x = 0;
		y = 0;
		scale = 1.0f;
		rotation = 0.0f;
		alpha = 1.0f;

}
Beispiel #3
0
// Runs update logic
void UiApp::update()
{
	// Update frame rate
	mFrameRate = getAverageFps();

	// Toggle fullscreen
	if ( mFullScreen != isFullScreen() ) {
		setFullScreen( mFullScreen );
	}

	// Update device
	if ( mLeap && mLeap->isConnected() ) {		
		mLeap->update();
	}
	
	// Interact with first hand
	if ( mHands.empty() ) {
		mCursorType		= CursorType::NONE;
	} else {
		const Hand& hand = mHands.begin()->second;
		
		// Update cursor position
		mCursorPositionTarget	= warp( hand.getPosition() );
		if ( mCursorType == CursorType::NONE ) {
			mCursorPosition = mCursorPositionTarget;
		}
		
		// Choose cursor type based on number of exposed fingers
		switch ( hand.getFingers().size() ) {
			case 0:
				mCursorType	= CursorType::GRAB;
				break;
			case 1:
				mCursorType	= CursorType::TOUCH;
				break;
			default:
				mCursorType	= CursorType::HAND;
				break;
		}
	}
	
	// Smooth cursor animation
	mCursorPosition = mCursorPosition.lerp( 0.21f, mCursorPositionTarget );
	mCursorPosition.z = 0.0f;
	
	// Hit buttons
	for ( size_t i = 0; i < 3; ++i ) {
		mButtonState[ i ] = false;
		if ( mCursorType == CursorType::TOUCH &&
			mCursorPosition.distance( mButtonPosition[ i ] ) < (float)mButton[ 0 ].getSize().length() * 0.5f ) {
			mButtonState[ i ] = true;
		}
	}
	
	// Slider
	if ( mCursorType == CursorType::GRAB &&
		math<float>::abs( mCursorPosition.x - mSliderPosition.x ) < (float)mSlider.getWidth() * 0.5f &&
		math<float>::abs( mCursorPosition.y - mSliderPosition.y ) < (float)mSlider.getHeight() * 0.5f ) {
		float x1			= mTrackPosition.x;
		float x2			= mTrackPosition.x + (float)( mTrack.getWidth() - mSlider.getWidth() );
		mSliderPosition.x	= math<float>::clamp( mCursorPosition.x, x1, x2 );
	}
}