Example #1
0
// APP CONSTRUCTOR. Create all objects here.
OrientationTestApp::OrientationTestApp() {
	addModifier(new poCamera2D(poColor::red));
    
    bg = new poRectShape(getWindowWidth(), getWindowHeight());
    bg->fillColor.set255(255,0,0);
    addChild(bg);
    addEvent(PO_TOUCH_BEGAN_EVENT, this);
    
    arrow = new poRectShape("resource/arrow-up.png");
    addChild(arrow);
    centerArrow();
    
    friction = 0.98;
    circle = new poOvalShape(50,50,100);
    circle->fillColor = poColor::grey;
    addChild(circle);
    
    addEvent(PO_ROTATION_EVENT, this);
    
    poStartAccelerometer(10.0f);
    addEvent(PO_ACCELEROMETER_EVENT, this);
    
    //Show Accel Info
    accelInfo = new poTextBox(150);
    accelInfo->setText("Info");
    accelInfo->setFont(poGetFont("resource/Arial.ttf"));
    accelInfo->setTextSize(16);
    accelInfo->textColor = poColor::white;
    accelInfo->useTextBoundsAsBounds(true);
    accelInfo->doLayout();
    addChild(accelInfo);
    
    bLockOrientation = false;
}
Example #2
0
Title::Title(std::string _text){
    
    std::string text = _text;
    
    titleText = new poTextBox(100,100);
    titleText->setText( text );						// Set the text based on the value of the node
    titleText->setFont( poGetFont("Times New Roman", "Regular") );
    titleText->setTextSize(13);
    titleText->textColor = poColor::white;
    titleText->doLayout();
    
    //give our text a random position
    float posX = poRand(0,300);
    float posY = poRand(-300,0);
    titleText->position.set(posX, posY, 0);
    addChild(titleText);

}
Example #3
0
// APP CONSTRUCTOR. Create all objects here.
AdvancedTextBoxesApp::AdvancedTextBoxesApp() {
	
	// Add a camera
	addModifier(new poCamera2D(poColor::black));
	
	// Show poCode lesson image in the background
    FILE* F = fopen("bg.jpg", "r");
	if(!F) {
		printf("RESOURCES NOT FOUND!\nPlease open the Xcode menu, click on 'Preferences' and select the 'Locations' tab. Click on 'Advanced' and make sure that the 'Legacy' option is checked. If it's not, check it and try running this example again.");
		exit(0);
	}
	else fclose(F);
	
    poRectShape* BG = new poRectShape("bg.jpg");
    addChild( BG );
	
	
	// A. poTextBox with rich text ///////////////////////
	
	poTextBox* A = new poTextBox(280, 120);
	A->setRichText(true);
	A->setFont(poGetFont("OpenSans-Italic.ttf"), PO_TEXT_ITALIC);
	A->setFont(poGetFont("OpenSans-Bold.ttf"), PO_TEXT_BOLD);
	A->setFont(poGetFont("ATLASSOL.TTF"), "retro");
	A->setFont(poGetFont("bitwise.ttf"), "computer");
	A->setFont(poGetFont("SaloonExt.ttf"), "western");
	A->setFont(poGetFont("Old Script.ttf"), "calligraphy");
	A->setText("This is a poTextBox with rich text. You can use html-style tags to make text <i>italic</i>, <b>bold</b>, <retro>retro</retro>, <computer>computery</computer>, <western>western</western>, <calligraphy>Calligraphic</calligraphy>.");
	A->setTextSize(18);
	A->textColor = poColor::black;
	A->doLayout();
	A->position.set(75, 180, 0);
	addChild(A);
	
	
	// B. poTextBox leading and tracking ///////////////////////
	
	poTextBox* B = new poTextBox(280, 120);
	B->setText(poToUpperCase("This is a regular text with some leading and tracking."));
	B->setTextSize(16);
	B->textColor = poColor::black;
	B->setLeading(2.0);
	B->setTracking(1.45);
	B->setTextAlignment(PO_ALIGN_CENTER_CENTER);
	B->doLayout();
	B->position.set(445, 180, 0);
	addChild(B);
}
Example #4
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);
}