Hi im developing a game with libgdx for android. My problem is that code:
button = new TextButton("SEND", skin);
button.setPosition(300,200);
button.setSize(200, 40);
button.setTransform(true);
button.setRotation(90);
user = new TextField("", skin);
user.setPosition(300,250);
user.setSize(200, 40);
user.setRotation(90);
user isnt rotating with setRotation. I would like to rotate this textfield. thanks for every suggestion
You need to call setTransform(true) on Actors to enable rotation. If Textfield doesn't have that method, wrap it in a Group.
Related
When I add a button in an AnchorPane (not in a PopUp like in this other test No detection of a touchScreen Button event in a modal window on Android), I have a kind of real time problem.
The test conditions are:
I often touch the same button. If the deltaOfTime between two touchScreen is greater than 1 second, the processing under the button is taken into account. When the deltaOfTime is lower, there is no action
I use JavaFXPorts (Gluon), with Eclipse and Gradle.
public void start() {
Button button = new Button("Action do do"));
HBox.setMargin(button , new Insets(10, 30, 10, 30));
button .setOnAction(e -> {
actionToDo();
});
Scene scene = new Scene (button, 100, 200);
Stage stage = new Stage();
stage.setScene(scene);
stage.show();
}
An idea? Does that mean that JavaFxPorts takes a lot of time to get events?
My application is a video game. Therefore, the final aim is to use the touchScreen for shooting, for instance, ... with deltaOfTime < 500 ms
Thanks
I want to create a map from some opengl code that I wrote :
In order to do that I though about taking a screen shot of the upperview of the gl screen.
Yet I cant seem to find how to do that...
any suggestions?
Similar problem has been solved in OSG example code here.
First you need to set your view such that you are looking at center from the TOP VIEW.
osg::Vec3 center = scene->getBound().center();
double radius = scene->getBound().radius();
view->getCamera()->setViewMatrixAsLookAt( center - lookDir*(radius*3.0), center, up );
view->getCamera()->setProjectionMatrixAsPerspective(
30.0f, static_cast<double>(width)/static_cast<double>(height), 1.0f, 10000.0f );
Then, you need to use some OS specific API to do similar to logic below:
osgViewer::ScreenCaptureHandler* scrn = new osgViewer::ScreenCaptureHandler();
osgViewer::ScreenCaptureHandler::WriteToFile* captureOper = new osgViewer::ScreenCaptureHandler::WriteToFile(tmpStr.m_szBuffer, "png");
scrn->setCaptureOperation(captureOper);
scrn->captureNextFrame(*_viewer);
_viewer->frame();
Of course if you are not using OSG then you need to find equivalent APIs (of library you are using) to achieve the same task.
I found this example and I am making some filters on realtime camera. When I use GlassSphereFilter or SphereRefractionFilter I get sphere on black background, and I want to achieve something like this. Can anyone help me?
Here is part of the code:
view = new FastImageProcessingView(this);
pipeline = new FastImageProcessingPipeline();
view.setPipeline(pipeline);
setContentView(view);
input = new CameraPreviewInput(view);
filter = new SphereRefractionFilter(new PointF(0.43f, 0.5f), 0.25f, 0.71f, 0.5f);
screen = new ScreenEndpoint(pipeline);
input.addTarget(screen);
filter.addTarget(screen);
pipeline.addRootRenderer(input);
pipeline.startRendering();
Is there a way ti show two surfaceViews with camera in same time? One to show normal image and other to show sphere?
I think you should use this library :
https://github.com/CyberAgent/android-gpuimage
I'm playing with stage2d.ui...
Just creating an empty stage with only a button, and it happens this in android (screenshot directly from a Nexus5):
Also, it looks ok in desktop, but if you resize the screen, you can see the image of the button flickering at its previous position like this (image after making the window a bit more width):
I'm not sure if I'm doing something wrong or it's just a graphic issue...
For the button widget, I'm using the test data like this:
stage = new Stage(new ScreenViewport());
Skin skin = new Skin(Gdx.files.internal("uiskin.json"));
TextButton button = new TextButton("Button 1", skin);
button.setSize(100, 50);
button.setPosition(10, 10);
stage.addActor(button);
And then in the main render method, stage.act(delta) and stage.draw() are called, of course.
For the resize part... here's the code
public void resize(int width, int height) {
stage.getViewport().update(width, height);
}
I have other stages without ui widgets working fine, but this is my first time with ui and I'm not sure about what's happening here...
Moved from comment above.
My guess is you are not clearing the screen at the start of your render method. Try adding Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); if it isn't there already.
There is something what I can use to rotate object without ending? I want start game and start rotate sprite with some speed but I don't want to end rotate. There is any way to use: new RotationModifier(20f, 0, 360), but with no end of rotation? Or there is any other way?
I think you can use LoopEntityModifier, something like (haven't tried it out):
LoopEntityModifier EntityModifier = new LoopEntityModifier(
new RotationModifier(1,0,360));