use of com.talosvfx.talos.editor.addons.scene.logic.GameObject in project talos by rockbite.
the class SEPropertyPanel method showPanel.
@Override
public void showPanel(IPropertyHolder target, Iterable<IPropertyProvider> propertyProviders) {
super.showPanel(target, propertyProviders);
if (target instanceof GameObject) {
// add part with custom components
container.row();
Table table = new Table();
Label label = new Label("Add Component", TalosMain.Instance().getSkin());
SquareButton button = new SquareButton(TalosMain.Instance().getSkin(), label);
button.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
Popup popup = new Popup();
popup.show(button, (GameObject) target);
}
});
table.add(button).height(30).growX();
container.add(button).pad(10).growX();
}
}
use of com.talosvfx.talos.editor.addons.scene.logic.GameObject in project talos by rockbite.
the class MainRenderer method render.
// todo: do fancier logic later
public void render(Batch batch, GameObject root) {
updateLayerOrderLookup(root);
list.clear();
list = root.getChildrenByComponent(RendererComponent.class, list);
sort(list);
for (GameObject gameObject : list) {
TransformComponent transformComponent = getWorldTransform(gameObject);
if (gameObject.hasComponent(SpriteRendererComponent.class)) {
renderSprite(batch, gameObject);
} else if (gameObject.hasComponent(ParticleComponent.class)) {
renderParticle(batch, gameObject);
} else if (gameObject.hasComponent(SpineRendererComponent.class)) {
renderSpine(batch, gameObject);
}
}
}
use of com.talosvfx.talos.editor.addons.scene.logic.GameObject in project talos by rockbite.
the class TransformComponent method worldToLocal.
public static Vector2 worldToLocal(GameObject gameObject, Vector2 vector) {
if (gameObject.parent == null)
return vector;
tmp.clear();
tmp = getRootChain(gameObject, tmp);
for (int i = tmp.size - 1; i >= 0; i--) {
GameObject item = tmp.get(i);
if (item.hasComponent(TransformComponent.class)) {
TransformComponent transform = item.getComponent(TransformComponent.class);
vector.sub(transform.position);
vector.rotateDeg(-transform.rotation);
vector.scl(1f / transform.scale.x, 1f / transform.scale.y);
}
}
return vector;
}
use of com.talosvfx.talos.editor.addons.scene.logic.GameObject in project talos by rockbite.
the class SpriteImporter method makeInstance.
@Override
public void makeInstance(FileHandle asset, GameObject parent) {
if (!AssetImporter.getMetadataHandleFor(asset).exists()) {
createMetadataFor(asset);
}
SpriteMetadata metadata = AssetImporter.readMetadataFor(asset, SpriteMetadata.class);
SceneEditorWorkspace workspace = SceneEditorAddon.get().workspace;
Vector2 sceneCords = workspace.getMouseCordsOnScene();
GameObject gameObject = workspace.createSpriteObject(asset, sceneCords, parent);
if (metadata.borderData != null) {
SpriteRendererComponent component = gameObject.getComponent(SpriteRendererComponent.class);
component.renderMode = SpriteRendererComponent.RenderMode.sliced;
} else {
if (gameObject.hasComponent(TransformComponent.class)) {
TransformComponent component = gameObject.getComponent(TransformComponent.class);
Texture texture = new Texture(asset);
component.scale.x = texture.getWidth() / metadata.pixelsPerUnit;
component.scale.y = texture.getHeight() / metadata.pixelsPerUnit;
}
}
}
Aggregations