Ejemplo n.º 1
0
const std::string EvtMouse::getAsString() const
{
    std::string event = "mouse";

    // Add the button
    if( m_button == kLeft )
        event += ":left";
    else if( m_button == kMiddle )
        event += ":middle";
    else if( m_button == kRight )
        event += ":right";
    else
        msg_Warn( getIntf(), "unknown button type" );

    // Add the action
    if( m_action == kDown )
        event += ":down";
    else if( m_action == kUp )
        event += ":up";
    else if( m_action == kDblClick )
        event += ":dblclick";
    else
        msg_Warn( getIntf(), "unknown action type" );

    // Add the modifier
    addModifier( event );

    return event;
}
Ejemplo n.º 2
0
const string EvtKey::getAsString() const
{
    string event = "key";

    // Add the action
    if( m_action == kDown )
        event += ":down";
    else if( m_action == kUp )
        event += ":up";
    else
        msg_Warn( getIntf(), "Unknown action type" );

    // Add the key
    char *keyName = KeyToString( m_key );
    if( keyName )
    {
        event += (string)":" + keyName;
        free( keyName );
    }
    else
        msg_Warn( getIntf(), "Unknown key: %d", m_key );

    // Add the modifier
    addModifier( event );

    return event;
}
Ejemplo n.º 3
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;
}
Ejemplo n.º 4
0
TestObj::TestObj() {
	addModifier(new poCamera2D(poColor::green));
    
    poRectShape *testRect = new poRectShape(200, 200);
    testRect->position.set(200,200,0);
    testRect->fillColor.set255(255, 255, 255);
    testRect->drawBounds = true;
    
    testRect->addEvent(PO_TOUCH_BEGAN_EVERYWHERE_EVENT, this);
    testRect->addEvent(PO_TOUCH_MOVED_EVERYWHERE_EVENT, this);
    testRect->addEvent(PO_TOUCH_ENDED_EVERYWHERE_EVENT, this);
    testRect->addEvent(PO_TOUCH_BEGAN_INSIDE_EVENT, this);
    testRect->addEvent(PO_TOUCH_ENDED_INSIDE_EVENT, this);
    
    addChild(testRect);
//    
//    shape = addChild(new poRectShape("apple.jpg"));
//    shape->fillColor.set255(255,0,0);
//    shape->alignment(PO_ALIGN_CENTER_CENTER);
//    shape->addEvent(PO_TOUCH_BEGAN_INSIDE_EVENT, this);
//	
//	poShape2D *mask = new poOvalShape(100, 100, 100);
//	mask->offset = shape->getBounds().getSize()/2.f;
//	shape->addModifier(new poGeometryMask(mask));
//
//	text = addChild(new poTextBox(200));
//	text->font(getFont("Maharam-Regular.otf",""));
//	text->textSize(20);
//	text->textColor = poColor::red;
//	text->text("hello world!!");
//	text->layout();
	
}
Ejemplo n.º 5
0
// APP CONSTRUCTOR. Create all objects here.
UpdateApp::UpdateApp() {

    // 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. Update scale ///////////////////////

    A = new poRectShape(5, 5);							// Draw a rectangle that scales up and down
    A->fillColor.set(0.6, 0.8, 0.4);
    A->position.set(125, 240, 0);
    A->setAlignment(PO_ALIGN_CENTER_CENTER);
    addChild(A);

    isScalingUp = true;									// Boolean to determine if the rectangle
    // is getting bigger or smaller

    // B. Update position ///////////////////////

    B = new poOvalShape(30, 30, 30);					// Draw a bouncing ball
    B->fillColor.set(0.6, 0.8, 0.4);
    B->position.set(310, 240, 0);
    B->setAlignment(PO_ALIGN_CENTER_CENTER);
    addChild(B);

    velocity = poPoint(0.5, 1, 0);						// Store the velocity (direction) of the ball
    // to add to the position at each frame

    // C. Update rotation ///////////////////////

    C = new poRectShape(4, 70);							// Draw a clock hand that rotates each second
    C->fillColor.set(0.6, 0.8, 0.4);
    C->position.set(490, 240, 0);
    C->setAlignment(PO_ALIGN_BOTTOM_CENTER);
    addChild(C);


    // D. Update text ///////////////////////

    D = new poTextBox(140, 140);						// Draw a text box that shows the current time
    D->setTextSize(25);
    D->textColor.set(0.6, 0.8, 0.4);
    D->position.set(674, 240, 0);
    D->useTextBoundsAsBounds( true );
    D->setAlignment(PO_ALIGN_CENTER_CENTER);
    D->doLayout();
    addChild(D);
}
Ejemplo n.º 6
0
FileLoadingApp::FileLoadingApp() {
	addModifier(new poCamera2D(poColor::black));    
    
    poFileLoader loader;
    //std::cout << loader.getFileAsString("http://www.vargatron.com") << std::endl;
    
    loader.getFile("http://www.vargatron.com/index.html");
}
Ejemplo n.º 7
0
// APP CONSTRUCTOR. Create all objects here.
poMessageCenterExampleApp::poMessageCenterExampleApp() {
	addModifier(new poCamera2D(poColor::black));
    
    addEvent(PO_MOUSE_DOWN_EVENT, this);
    
    s = new Square();
    s->position.set(getWindowWidth()/2 - s->getWidth()/2, getWindowHeight()/2 - s->getHeight()/2, 0.0f);
    addChild(s);
}
TCHAR *StreamParameters::addPrefix(TCHAR *dst, bool withPrecision) const {
  *(dst++) = _T('%');
  dst = addModifier(dst);
  dst = addWidth(dst);
  if(withPrecision) {
    dst = addPrecision(dst);
  }
  return dst;
}
Ejemplo n.º 9
0
ExampleApp::ExampleApp() {
	// you must have at least 1 camera
	addModifier(new poCamera2D());
	
	// make a rectangle with the size of the requested image
	poRectShape *shape = addChild(new poRectShape("img1.png"));
	shape->drawBounds = true;
	// re-orient the shape around its own center point
	shape->alignment(PO_ALIGN_CENTER_CENTER);
	// and place it in the center of the screen
	shape->position = getWindowCenter();
	
	// attach enter and leave events to the shape
	shape->addEvent(PO_MOUSE_ENTER_EVENT, this);
	shape->addEvent(PO_MOUSE_LEAVE_EVENT, this);
	
	// up and down events
	shape->addEvent(PO_MOUSE_DOWN_INSIDE_EVENT, this);
	shape->addEvent(PO_MOUSE_UP_EVERYWHERE_EVENT, this);

	// a drag event starts when you click on an object
	shape->addEvent(PO_MOUSE_DRAG_EVENT, this);
	
	// key events will go to all interested parties
	addEvent(PO_KEY_DOWN_EVENT, this);
	// and if you care about the window being resized
	addEvent(PO_WINDOW_RESIZED_EVENT, this);
	
	// initialize this variable for safty
	mask = NULL;
	
	// initial text for the mouse coords
	std::string coords = (text_fmt % 0 % 0).str();
	
	// create a text box with a blah size
	poTextBox *text = addChild(new poTextBox(400,20));
	text->text(coords);
	// you must call layout after reconfiguring a text box
	text->layout();
	
	// its a ... mouse move event
	addEvent(PO_MOUSE_MOVE_EVENT, this);
	
	// also hopefully self-explanitory
	shape->addEvent(PO_MOUSE_DOWN_OUTSIDE_EVENT, this);
	
	// all poObjects have a couple of property tweens
	// see poObject.h and also poTween.h
	shape->rotation_tween.setTweenFunction(linearFunc).setDuration(10.f).setRepeat(PO_TWEEN_REPEAT_REGULAR);

	// a global dictionary that reads from and writes to "common.xml"
	poDictionary *common = poCommon::get();
	if(common->has("rotation"))
		shape->rotation = common->getFloat("rotation");
}
Ejemplo n.º 10
0
void ModifierTile::onHit(Spell* spell) {
	if (m_state == GameObjectState::Active) return;
	switch (spell->getSpellID()) {
	case SpellID::Telekinesis:
		addModifier();
		spell->setDisposed();
		break;
	default:
		break;
	}
}
Ejemplo n.º 11
0
imageShape_testApp::imageShape_testApp() {
	setCurrentPath(applicationGetResourceDirectory());
	setWindowMouseMoveEnabled(false);

	addModifier(new poCamera2D());

	poImageShape *shp = new poImageShape("test.png");
	shp->addEvent(PO_MOUSE_DOWN_INSIDE_EVENT, this);
	shp->setAlignment(PO_ALIGN_CENTER_CENTER);
	shp->position = getWindowCenter();
	addChild(shp);
}
Ejemplo n.º 12
0
SplitTextApp::SplitTextApp() 
{
	addModifier(new poCamera2D());
	
	std::string s = "In the late 1930s, Max Marcus ran a general merchandise auction house out of one of the basement storefronts at 97 Orchard Street. His entire life was shaped by doing business on the Lower East Side. By the late 1980s, Marcus was running a botanica at the nearby Essex Street indoor market.";
	
	t = new flyingText(s, 250, 400, 0, 1.f, 5.f);
	t->position.set(200,25,0);
	addChild(t);
	
	addEvent(PO_KEY_DOWN_EVENT, this);
}
Ejemplo n.º 13
0
StarShapeApp::StarShapeApp() {
	addModifier(new poCamera2D(poColor::black));
    
    addEvent(PO_KEY_DOWN_EVENT, this);
    
    numPoints = 5;
    radius = 100;
    depth = 40; 
    
    s = new poStarShape(radius, numPoints, depth); 
    s->position = poPoint(300,150);
    addChild(s);
}
Ejemplo n.º 14
0
AlphaTestTextureApp::AlphaTestTextureApp() {
	addModifier(new poCamera2D(poColor::green));
	
	poRectShape *shape = addChild(new poRectShape(getImage("1_Dry Dock 1.png")->texture()));
	
	
	shape->position.set(100,100,0);
	shape->drawBounds = true;
	shape->alphaTestTexture = true;
	shape->addEvent(PO_MOUSE_DOWN_INSIDE_EVENT, this);
	shape->addEvent(PO_MOUSE_ENTER_EVENT, this);
	shape->addEvent(PO_MOUSE_LEAVE_EVENT, this);
}
Ejemplo n.º 15
0
ParticlesApp::ParticlesApp() {

    // Add a camera
    addModifier(new poCamera2D(poColor::black));

    // Show poCode lesson image in the background
    poImageShape* BG = new poImageShape("bg.jpg");
    addChild( BG );

    for(int i=0; i < 200; i++) {
        Particle* P = new Particle();
        addChild(P);
    }
}
Ejemplo n.º 16
0
// APP CONSTRUCTOR. Create all objects here.
spatialMediaApp::spatialMediaApp() {
    
    // add the 2D camera with a black background
	addModifier(new poCamera2D(poColor::black));
    
    // initialize our variables (see variables declared in .h file)
    lastKeyDown = '1';
    mouseX = 0;
    mouseY = 0;
    
    // register for "mouse move" and "key down" events
    addEvent( PO_MOUSE_MOVE_EVENT, this );
    addEvent( PO_KEY_DOWN_EVENT, this );
}
Ejemplo n.º 17
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);
}
Ejemplo n.º 18
0
AdvancedTweensApp::AdvancedTweensApp()
:float_tween_x(&x_tween_val),
float_tween_y(&y_tween_val)
{
	addModifier(new poCamera2D(poColor::black));
	
	// a shape to move on screen
	shape = new poOvalShape(10,10,50);
	addChild(shape);
	
	// a function to set the tween properties
	animate();
	
	// a little key control
	addEvent(PO_KEY_DOWN_EVENT, this);
}
Ejemplo n.º 19
0
const string EvtScroll::getAsString() const
{
    string event = "scroll";

    // Add the direction
    if( m_direction == kUp )
        event += ":up";
    else if( m_direction == kDown )
        event += ":down";
    else
        msg_Warn( getIntf(), "Unknown scrolling direction" );

    // Add the modifier
    addModifier( event );

    return event;
}
Ejemplo n.º 20
0
GoldenRatioApp::GoldenRatioApp() {
	addModifier(new poCamera2D(poColor::black));
    
    poObject *bloom = new poObject();
    bloom->position.set( getWindowWidth()/2, getWindowHeight()/2, 0);
    addChild(bloom);
    
    for(int i=1; i<3000; i++){
        seeds.push_back(new poOvalShape(SEEDSIZE,SEEDSIZE,NUMSIDES));
        seeds.back()->matrixOrder = PO_MATRIX_ORDER_RST;
        seeds.back()->rotation = i*360*PHI;
        seeds.back()->position.set( sqrt(i)*SPACING, 0, 0 );
    }
    
    for(int j=0; j<seeds.size(); j++){
        bloom->addChild(seeds[j]);
    }
    
    addEvent(PO_MOUSE_MOVE_EVENT, this, "mouseMove");
}
Ejemplo n.º 21
0
TextureAlignmentApp::TextureAlignmentApp() {
    addModifier(new poCamera2D(poColor::black));

    portrait = new poTexture("portrait.jpg");
    landscape = new poTexture("landscape.jpg");

    currentFit = 0;
    currentAlign = 0;

    TB = new poTextBox(200, 100);
    TB->setFont(new poFont("Lucida Grande"));
    TB->setText("FIT 0 - ALIGN 0");
    TB->setTextSize(20);
    TB->textColor = poColor::white;
    TB->doLayout();
    TB->position.set(getWindowWidth() - 200, getWindowHeight() - 50, 0);
    addChild(TB);

    addEvent(PO_KEY_DOWN_EVENT, this);
}
Ejemplo n.º 22
0
CRAFTING_NAMESPACE

CPointsModifier::CPointsModifier(
    int speedPoints, int efficiencyPoints, int qualityPoints,
    PointFunction speedFn,
    PointFunction efficiencyFn,
    PointFunction qualityFn)
{
    speedFn = speedFn ? speedFn : CPointsModifier::defaultSpeedCalc;
    efficiencyFn = efficiencyFn ? efficiencyFn : CPointsModifier::defaultEffCalc;
    qualityFn = qualityFn ? qualityFn : CPointsModifier::defaultQualityCalc;

    m_speed = speedFn(speedPoints);
    m_efficiency = efficiencyFn(efficiencyPoints);
    m_quality = qualityFn(qualityPoints);

    for (int i = 0; i < kNumMods; i++) {
        const float value = m_quality * kStatSigns[i];
        const ModifierType type = static_cast<ModifierType>(i);
        addModifier(CModifier(type, value));
    }
}
Ejemplo n.º 23
0
AlignmentApp::AlignmentApp() {
	addModifier(new poCamera2D(poColor::black));
    
    poRectShape* p;
    poOvalShape* o;
    
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            p = new poRectShape(getWindowWidth()/6, getWindowHeight()/6);
            p->position.set(100+j*(getWindowWidth()/3),50+i*(getWindowHeight()/3),1.f);
            p->generateStroke(5);
			p->strokeColor = poColor::magenta;
			p->fillColor = poColor::dk_grey;
			
            switch (i*3+j) {
                case 0: p->alignment(PO_ALIGN_TOP_LEFT);  break;
                case 1: p->alignment(PO_ALIGN_TOP_CENTER);  break;
                case 2: p->alignment(PO_ALIGN_TOP_RIGHT);  break;
                case 3: p->alignment(PO_ALIGN_CENTER_LEFT);  break;
                case 4: p->alignment(PO_ALIGN_CENTER_CENTER);  break;
                case 5: p->alignment(PO_ALIGN_CENTER_RIGHT);  break;
                case 6: p->alignment(PO_ALIGN_BOTTOM_LEFT);  break;
                case 7: p->alignment(PO_ALIGN_BOTTOM_CENTER);  break;
                case 8: p->alignment(PO_ALIGN_BOTTOM_RIGHT);  break;
                default: break;
            }
			
            addChild(p);
            
            //creating an oval to be a reference for the object alignment
            o = new poOvalShape(10, 10, 20);
            o->position.set(100+j*(getWindowWidth()/3),50+i*(getWindowHeight()/3),1.f);
			o->alignment(PO_ALIGN_CENTER_CENTER);
            o->fillColor = poColor::white;
            addChild(o);
        }
    }
}
Ejemplo n.º 24
0
// APP CONSTRUCTOR. Create all objects here.
MovingImageApp::MovingImageApp() {
	addModifier(new poCamera2D(poColor(.9,.9,.9)));
	
	sprite = new MovingImage("sprites/shifty/", "PT_Shifty");
	sprite->setFrameRate(30);
	sprite->position.set(100,100,0);
	addChild(sprite);
	
	control = new poControlPanel("controls", poColor( 0,.1,.1,.8 ), 9);
	control->addSliderI("framerate", 1, 60, this);
	control->addButton("play", this);
	control->addButton("pause", this);
	control->addButton("reset", this);
	control->addButton("stop", this);
	control->addButton("step forward", this);
	control->addButton("step backward", this);
	control->addToggle("loop", this);
	control->addSliderI("goto frame", 0, sprite->getNumFrames()-1, this);
	
	addChild(control);
	
	addEvent(PO_KEY_DOWN_EVENT, this);
}
Ejemplo n.º 25
0
FBO_TestApp::FBO_TestApp() {
	fancyDraw = false;
	
	addModifier(new poCamera2D());
	fbo = new poFBO(500,500,poFBOConfig().setNumMultisamples(4));
	
	poRectShape *shp = new poRectShape(400,400);
	shp->placeTexture(poTexture(getImage("pitbull.jpeg")));
	shp->position.set(50,50,0);
	shp->addModifier(fbo);
	addChild(shp);
	
	poRectShape *shp2 = new poRectShape(500,500);
	shp2->placeTexture(fbo->colorTexture());
	shp2->position.set(50,50,0);
	addChild(shp2);

	poRectShape *shp3 = new poRectShape(400,400);
	shp3->placeTexture(poTexture(getImage("pitbull.jpeg")));
	shp3->position.set(650,50,0);
	addChild(shp3);
	
	addEvent(PO_KEY_DOWN_EVENT, this);
}
Ejemplo n.º 26
0
MouseEventsApp::MouseEventsApp() {
    addModifier(new poCamera2D(poColor::grey));

    float width = getWindowWidth();
    float height = getWindowHeight();

    rectangle = new poRectShape(width-100,height-100);
    rectangle->name = "rectangle";
    rectangle->fillColor = poColor::lt_grey;
    rectangle->position = poPoint(50,50, 0.f);
    addChild(rectangle);

    rectangle->addEvent(PO_MOUSE_DOWN_EVENT, this);
    rectangle->addEvent(PO_MOUSE_DOWN_INSIDE_EVENT, this);
    rectangle->addEvent(PO_MOUSE_UP_EVENT, this);
    rectangle->addEvent(PO_MOUSE_DRAG_EVENT, this);
    rectangle->addEvent(PO_MOUSE_ENTER_EVENT, this);
    rectangle->addEvent(PO_MOUSE_LEAVE_EVENT, this);
    rectangle->addEvent(PO_MOUSE_OVER_EVENT, this);

    addEvent(PO_KEY_DOWN_EVENT, this);
    addEvent(PO_KEY_UP_EVENT, this);

}
Ejemplo n.º 27
0
// APP CONSTRUCTOR. Create all objects here.
ImageLoaderTestApp::ImageLoaderTestApp() {
	addModifier(new poCamera2D(poColor::black));
}
Ejemplo n.º 28
0
// APP CONSTRUCTOR.
// Create all objects here.
AdvancedShapesApp::AdvancedShapesApp() {
	
	// Add a camera
	addModifier(new poCamera2D(poColor::black));
	
	// poCode template image in the background
    poImageShape* BG = new poImageShape("bg.jpg");
    addChild( BG );
	
	
	// A. poShape2D ///////////////////////
	
	poShape2D* A = new poShape2D();							// Create a poShape2D
	A->addPoint(-40,-10);									// Add a point to the shape, x and y coordinates
	A->addPoint(50,-50);
	A->addPoint(30,40);
	A->addPoint(-20,30);
    A->fillColor = poColor::orange;
	A->position.set(120, 240, 0);
	addChild( A );
	
	
	// B. poShape2D using math ///////////////////////
	
	poShape2D* B = new poShape2D();							// Create a poShape2D
	
	for ( int i=0 ; i<=120 ; i++ ) {   
        
        float dirX,dirY;									// Set variables to control the progression
        float scale = 0.05;									// of the mathematical formula
        int val;
		
        if (i<=60) {
            dirX = -1;
            dirY = -1;
            val = i;
        } 
        else {
            dirX = 1;
            dirY = -1;
            val = (int)(i-60);
        } 
													// Mathematical equation to calculate x and y of a point
        float x = dirX*scale*(-powf(val, 2)+40*val+1200)*sin(M_PI*val/180); 
        float y = dirY*scale*(-powf(val, 2)+40*val+1200)*cos(M_PI*val/180);
		
        poPoint P = poPoint(x, y);					// Create the poPoint
		
        B->addPoint(P);								// Add the poPoint to the shape B
    }
    B->fillColor = poColor::orange;
	B->position.set(310, 280, 0);
	addChild( B );
	
	
	// C. poStarShape ///////////////////////
	
	poShape2D* C = new poShape2D();					// Create a poShape2D
	
	C->addPoint(0,0);								// Add a point to the shape C
	
	C->curveTo(poPoint(50,-50), poPoint(50,0));		// curveTo() allows you to define a curve when drawing a shape
	C->curveTo(poPoint(0,0), poPoint(0,-50));		// Define an end point and control point to describe the curve
	C->curveTo(poPoint(-50,-50), poPoint(0,-50));	// Alternatively define a curve sergment using 2 control points: 
	C->curveTo(poPoint(0,0), poPoint(-50,0));		// curveTo( poPoint pt, poPoint control1, poPoint control2 )
	C->curveTo(poPoint(-50,50), poPoint(-50,0));
	C->curveTo(poPoint(0,0), poPoint(0,50));
	C->curveTo(poPoint(50,50), poPoint(0,50));
	C->curveTo(poPoint(0,0), poPoint(50,0));
	
	C->fillColor = poColor::orange;
	C->position.set(490, 240, 0);
	addChild( C );
	
	
    // D. poShape2D from a SVG file ///////////////////////
	
	poShape2D* D;
	
	std::vector<poShape2D*> shapes = createShapesFromSVGfile("mouth.svg");	// createShapesFromSVGfile(file.svg) 
																			// returns a std::vector list of 
																			// poShape2D pointers
	
	D = shapes.back();					// Since we know there is only 1 shape, we can get only the last one
	D->fillColor = poColor::orange;
    D->position.set(600, 190, 0);
    addChild( D );
}
Ejemplo n.º 29
0
// APP CONSTRUCTOR. Create all objects here.
homework4seedApp::homework4seedApp() {
	addModifier(new poCamera2D(poColor::black));
}
Ejemplo n.º 30
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);
}