Beispiel #1
0
void ObjectScene::componentEdited(Kite::KEntity *Entity, Kite::KComponent *Component, const QString &PName) {
	if (Component->getType() == Kite::CTypes::Transform) {
		auto tr = static_cast<Kite::KTransformCom *>(Component);
		syncTransform(tr);
	}

	if (Component->getType() == Kite::CTypes::Quad) {
		auto qcom = static_cast<Kite::KQuadCom *>(Component);
		syncQuad(qcom);
	}
}
Beispiel #2
0
void ObjectScene::resSelect(Kite::KResource *Scene) {
	if (currScene == (Kite::KScene *)Scene) return;

	if (Scene->getType() != Kite::RTypes::Scene) return;

	currScene = (Kite::KScene *)Scene;
	clear();
	for (auto it = layers.begin(); it != layers.end(); ++it) {
		(*it) = nullptr;
	}

	// quads
	auto quadContiner = currScene->getEManager()->getComponentStorage<Kite::KQuadCom>(Kite::CTypes::Quad);
	for (auto it = quadContiner->begin(); it != quadContiner->end(); ++it) {
		auto ent = currScene->getEManager()->getEntity(it->getOwnerHandle());
		auto tr = (Kite::KTransformCom *)ent->getComponent(Kite::CTypes::Transform);

		// check layer
		if (layers.at(ent->getLayer()) == nullptr) {
			layers[ent->getLayer()] = new QGraphicsItemGroup();
			addItem(layers[ent->getLayer()]);
		}

		auto rect = new QGraphicsPixmapItem(layers[ent->getLayer()]);
		tr->setSceneItem(rect);
		it->setSceneItem(rect);

		syncQuad(&(*it));
		syncTransform(tr);
	}

	// tile maps
	/*auto tmapContiner = currScene->getEManager()->getComponentStorage<Kite::KOrthoMapCom>(Kite::CTypes::OrthogonalMapView);
	for (auto it = tmapContiner->begin(); it != tmapContiner->end(); ++it) {
		auto ent = currScene->getEManager()->getEntity(it->getOwnerHandle());
		auto tr = (Kite::KTransformCom *)ent->getComponent(Kite::CTypes::Transform);

		// check layer
		if (layers.at(ent->getLayer()) == nullptr) {
			layers[ent->getLayer()] = new QGraphicsItemGroup();
			addItem(layers[ent->getLayer()]);
		}

		Kite::KRectF32 brect;
		it->getBoundingRect(brect);
		auto rect = new QGraphicsRectItem(layers[ent->getLayer()]);
		rect->setRect(QRect(brect.left, brect.bottom, brect.right - brect.left, brect.top - brect.bottom));
		rect->setTransformOriginPoint(tr->getCenter().x, tr->getCenter().y);
		rect->setRotation(tr->getRotation());
		rect->setTransform(QTransform::fromScale(tr->getScale().x, tr->getScale().y), true);
		rect->setPos(tr->getPosition().x, tr->getPosition().y);
	}*/
}
void GraphicsComponent::setPosition(sf::Vector2f vec) {

    sf::Transformable::setPosition(vec);
    syncTransform();
}