//--------------------------------------------------------
void InteractionInterview::doubleTouched(ofVec2f touchpos) {
	
	for(int i=0; i<bubbles.size(); i++) {
		if(bubbles[i]==NULL) continue;
		ContentBubble * bubble = bubbles[i];
		ofVec2f p1  = touchpos;
		ofVec2f p2  = bubble->rigidBody->getPosition();
		float	dis = p1.distance(p2);
		
		if(dis < bubble->radius + 10.0) {
			//bubble->setRadius(150);
			bubble->doubleTouched();
			printf("hit this bubble: %p\n", bubble);
			break;
		}
	}
}
//--------------------------------------------------------
void InteractionInterview::newBubbleRecieved(Donk::BubbleData * data) { 
	
	if(bAnimateOut) return;

	float   radius = ofRandom(160,220);//180;
	ofVec3f center(interactiveRect.width/2, 0, 0);
	ofVec3f startPos(center.x + ofRandom(-300, 300), interactiveRect.height+radius, ofRandom(-100, 100));
	
	
	ContentBubble * bubble = new ContentBubble();
	
	bubble->data	  = data;
	bubble->radius    = radius;
	bubble->startRadius = radius;
	bubble->maxRadius = 240;
	
	bubble->rigidBody = bullet->createSphere(startPos, radius, 1);
	bubble->createContentBubble();
	bubble->setTarget(center.x + ofRandom(-300, 300), startPos.y-radius, 0 );//ofRandom(500, interactiveRect.height-300), 0);
	
	bubble->setContentSideUp();
	
	bubbles.push_back(bubble);
};
示例#3
0
//--------------------------------------------------------
void BubbleProjection::touchUp(float x, float y, int touchId) {

    for (int i=0; i<touches.size(); i++) {
        if(touches[i].id == touchId) {
            //printf("*** %p\n", touches[i].secondTouch);
            if(touches[i].secondTouch) {

                touches[i].secondTouch->bChildOfGesture = false;
                touches[i].secondTouch->radiusDes = 30;
                touches[i].secondTouch->touchAlphaDes = 200;
            }
        }
    }

    bTouchDown = false;

    ofVec2f pos = mapToInteractiveArea(ofVec2f(x, y));

    if(activeInteraction) {

        InteractionVote * voteInteraction = NULL;
        bool bInVoteMode = false;
        if(activeInteraction->name == "vote") {
            voteInteraction = (InteractionVote*)activeInteraction;
            if(voteInteraction) {
                bInVoteMode = true;
            }
        }


        if(bInVoteMode) {
            for(int i=0; i<2; i++) {

                if(voteInteraction->bMadeVoteBubbles) {
                    ContentBubble * bubble = (ContentBubble*)voteInteraction->voteBubbles[i];
                    if(bubble != NULL) {
                        if(bubble->bTouched) {

                            bubble->bTouched = false;
                            removeTouchConstraint(bubble);

                        }
                    }
                }
            }

        }


        else {

            for(int i=0; i<activeInteraction->bubbles.size(); i++) {

                ContentBubble * bubble = activeInteraction->bubbles[i];

                if(bubble != NULL) {

                    if(bubble->bTouched) {

                        bubble->releaseTouch();

                        if (activeInteraction->name == "interview") {
                            bubble->setTarget(pos.x, pos.y);
                            bubble->setLoopStart( getHeight() );
                        }

                        if (activeInteraction->name == "inspiration") {
                            bubble->setTarget(pos.x, pos.y);
                        }


                        if (activeInteraction->name == "buzz") {
                            if( !activeInteraction->bAnimateOut ) bubble->setTarget(pos.x, pos.y);
                        }

                        if (activeInteraction->name == "performance") {
                            bubble->setTarget(pos.x, pos.y);
                            bubble->performanceStartTarget = bubble->target;
                        }

                        bubble->bTouched = false;
                        removeTouchConstraint(bubble);
                    }
                }
            }

        }
    }


    // remove old touches...
    for (int i=0; i<touches.size(); i++) {
        if(touches[i].id == touchId) {
            touches[i].bRemove = true;
        }
    }


}