Пример #1
0
bool HelloPolycodeApp::Update() {
	if(lastEntity)
		lastEntity->setColor(1.0, 1.0, 1.0, 1.0);	
	Vector2 mouse = core->getInput()->getMousePosition();
	ScreenEntity * entity = screen->getEntityAtPosition(mouse.x, mouse.y);
	if(entity) {
		entity->setColor(1.0, 0.0, 0.0, 1.0);
		lastEntity = entity;
	}
    return core->Update();
}
Пример #2
0
//Handle events
void TGApp::handleEvent(Event *e) {
	if(e->getDispatcher() == core->getInput()) {
		InputEvent *inputEvent = (InputEvent*)e;		
		switch(e->getEventCode()) {
			case InputEvent::EVENT_KEYUP:
				switch (inputEvent->key) {					
					case KEY_SPACE:
						randomWorld();
					break;
				}
			break;
			case InputEvent::EVENT_MOUSEDOWN:
				float xx = inputEvent->mousePosition.x - XSIZ/2;
				float yy = inputEvent->mousePosition.y - YSIZ/2;
				ScreenEntity *e = screen->getEntityAtPosition(xx,yy);
				if(e == NULL) break;
				e->setColor(1,0,0,1);
				printf("%f",e->bBox.length());				
			break;
		}		
	}
}