示例#1
0
文件: Deck.cpp 项目: jbobrow/Set
Deck::Deck()
{
    bWithReplacement = false;
    bDrawHeatmap = false;

    numProperties = 4;
    numOptions = 3;

    poRandSeed();

    createCards();
    //printDeck();

    dealCards(12);
    updateNeededCards();
    printNeededRatios();

    addEvent(PO_KEY_DOWN_EVENT, this);
}
示例#2
0
// APP CONSTRUCTOR.
// Create all objects here.
DictionariesApp::DictionariesApp() {
	
	// Add a camera
	addModifier(new poCamera2D(poColor::black));
	
	// Show poCode lesson image in the background
    poImageShape* BG = new poImageShape("bg.jpg");
    addChild( BG );
	
	
	// A. Create a poDictionary and get data from it ///////////////////////
	
	poDictionary A;												// Create a poDictionary
	A.set("textSize", 25);										// Set an integer value called "textSize"
	A.set("text", "This text and its properties "				// Set a string value called "text"
				  "are stored in the poDictionary A");	
	A.set("textColor", poColor::orange);						// Set a poColor value called "textColor"
	A.set("textPosition", poPoint(60, 180));					// Set a poPoint value called "textPosition"
	
	poTextBox* text = new poTextBox(300, 130);
	text->setFont( poGetFont("Helvetica", "Regular") );
	text->setText( A.getString("text") );						// Get the value of the string "text" in A
	text->textColor = A.getColor("textColor");					// Get the value of the poColor "textColor" in A
	text->setTextSize( A.getInt("textSize") );					// Get the value of the integer "textSize" in A
	text->doLayout();
	text->position = A.getPoint("textPosition");				// Get the value of the integer "textPosition" in A
	addChild(text);
	
	
	// B. Use of poDictionary in events ///////////////////////
	
	poRandSeed();												// Do this to seed the random color generator
	
	for(int i=1; i < 9; i++) {									// Create 8 rectangles
		
		poRectShape* rect = new poRectShape(30,30);					
		rect->fillColor = poColor::random();					// Assign a random color to each one
		rect->position.set(388 + (i * 40), 280, 0);
		addChild(rect);
		
		poDictionary B;											// Create a poDictionary for each rectangle
		B.set("rectID", i);										// Save the ID in the dictionary
		B.set("rectColor", rect->fillColor);					// Save the random poColor in the dictionary
		
		rect->addEvent(PO_MOUSE_DOWN_INSIDE_EVENT, this, 		// Add a mouse press event to each rectangle with
					   "rect clicked", B);						// a message and a poDictionary attached to it
	}
	
	bigRect = new poRectShape(310, 90);							// Draw a big rectangle that will change color
	bigRect->fillColor = poColor::ltGrey;
	bigRect->position.set(428, 180, 0);
	addChild(bigRect);
	
	rectTextBox = new poTextBox(310, 90);						// Create a text box
	rectTextBox->setFont( poGetFont("Helvetica", "Regular") );
	rectTextBox->setText("Click on the colored rectangles to change color");
	rectTextBox->setTextSize(18);
	rectTextBox->setTextAlignment(PO_ALIGN_CENTER_CENTER);
	rectTextBox->doLayout();
	rectTextBox->position.set(428, 180, 0);
	addChild(rectTextBox);
}