Example #1
0
void Koppa::minionPhysics() {
	if(minionState == 3) {
		if(flyDirection) {
			if(iDistance > 0) {
				fYPos -= 2;
				iDistance -= 2;
			} else {
				iDistance = 7*32;
				flyDirection = !flyDirection;
			}
		} else {
			if(iDistance > 0) {
				fYPos += 2;
				iDistance -= 2;
			} else {
				iDistance = 7*32;
				flyDirection = !flyDirection;
			}
		}
	}
	else if (jumpState == 1) {
		if(minionState == 0) {
			updateYPos(-2);
			currentJumpDistance += 2;

			if (jumpDistance <= currentJumpDistance) {
				jumpState = 2;
			}
		} else {
			Minion::physicsState1();
		}
	} else {
		if (!CCore::getMap()->checkCollisionLB((int)fXPos + 2, (int)fYPos + 2, iHitBoxY, true) && !CCore::getMap()->checkCollisionRB((int)fXPos - 2, (int)fYPos + 2, iHitBoxX, iHitBoxY, true) && !onAnotherMinion) {
			if(minionState == 0) {
				updateYPos(2);

				jumpState = 2;

				if (fYPos >= CCFG::GAME_HEIGHT) {
					minionState = -1;
				}
			} else {
				Minion::physicsState2();
			}
		} else {
			jumpState = 0;
			onAnotherMinion = false;
		}
	}
}
 void NotificationManager::deleteNotification( Notification *n ){
     //possibly remove the connected signal here?
     //ci::app::console() << mNotifications.size() << "- about to remove :" << n->message << std::endl;
     mNotifications.remove(n);
     //ci::app::console() << mNotifications.size() << "- removed: " << n->message << std::endl;
     updateYPos();
     //delete n; //currently throws an error.
 }
    Notification * NotificationManager::add(std::string message, float timeout, ci::ColorA bgColor, ci::ColorA fontColor){
        Notification *n = new Notification( message, bgColor, fontColor );
        mNotifications.push_back(n);
        
        n->animateIn();
        
        updateYPos();
        
        ci::app::timeline().apply( &n->time, timeout, timeout ).finishFn(std::bind( &Notification::animateOut, n));
        //n->signal_die.connect(std::bind( &NotificationManager::deleteNotification, this, n));
        n->signal_die.connect(std::bind( &NotificationManager::deleteNotification, this, std::placeholders::_1));
//        n->signal_die.connect([&](Notification * n){ deleteNotification(n);} );
        return n;
    }
Example #4
0
// ImageLayerNode
ImageLayerNode::ImageLayerNode(QQuickWindow *window, const QString file, bool mirroredType)
{
    QImage image(file);

    // NOTE this is a workaround to get the mirrored effect at the end of the image
    // ideally, do it using the shader program
    if (mirroredType) {
        QImage tempImage(image.width() * 2, image.height(), QImage::Format_ARGB32);
        QPainter p(&tempImage);
            p.drawImage(0, 0, image);
            p.drawImage(image.width(), 0, image.mirrored(true, false));
        p.end();

        image = tempImage;
    }

    QSGTexture *texture = window->createTextureFromImage(image);

    texture->setHorizontalWrapMode(QSGTexture::Repeat);
    texture->setVerticalWrapMode(QSGTexture::Repeat);
    texture->setFiltering(QSGTexture::Linear);

    m_width = texture->textureSize().width();
    m_height = texture->textureSize().height();

    QSGSimpleMaterial<ImageLayerState> *m = ImageLayerShader::createMaterial();
    m->state()->texture = texture;
    setMaterial(m);
    setFlag(OwnsMaterial, true);

    updateXPos(0);
    updateYPos(0);

    QSGGeometry *g = new QSGGeometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4);
    QSGGeometry::updateTexturedRectGeometry(g, QRect(), QRect());
    setGeometry(g);

    setFlag(OwnsGeometry, true);
}