Android – how to make users choose to use pictures to be used in the library, libgdx

I’m a beginner, learning LibGDX. I’m developing my first game in LibGDX, you can replace the enemy’s ball (such as someone’s head) with a selected picture and then You dodge the enemy. In my main menu I have a stage2d button. I want to have a button that allows the user to choose the picture he wants to use in the game. So I created a button and added a CLickListner to it. I Where do I start now? Is there a way to open the gallery in LibGDX and let the user choose the picture he wants to use?

Edit:

So, suppose I have an interface in my core project:

public interface OpenGallery {< br />public void openGallery();
)

In my android directory, I created a Platform-specific class to start the intent

import android.content.Intent;

import com.kubas.zaidimas.OpenGallery;

public class GalleryOpener extends AndroidLauncher implements OpenGallery {

private static final int SELECT_PICTURE = 1;

@Override
public void openGallery() {
Intent intent = new Intent();
intent.setType( "image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,
"Select Picture"), SELECT_PICTURE);
}

What should I do from this point on? So I can call it in my main menu?

I created a sample libgdx project which contains android-specific code to call the library And retrieve the file path of the image selected by the user. Hope this helps you understand how the integration works. I tested it on several Android devices.
See https://github.com/miket-ap/libgdx -platform-specific-example

I am a beginner, learning LibGDX. I am developing my first game in LibGDX. You can replace the enemy’s ball with a selected picture (e.g. a certain Human head) and you avoid the enemy. In my main menu I have a stage2d button, I want to have a button that allows the user to choose the picture he wants to use in the game. So I created a button and A CLIckListner has been added. Where do I start now? Is there a way to open the gallery in LibGDX and let the user choose the picture he wants to use?

Edit:

So, suppose I have an interface in my core project:

public interface OpenGallery {< br />public void openGallery();
)

In my android directory, I created a Platform-specific class to start the intent

import android.content.Intent;

import com.kubas.zaidimas.OpenGallery;

public class GalleryOpener extends AndroidLauncher implements OpenGallery {

private static final int SELECT_PICTURE = 1;

@Override
public void openGallery() {
Intent intent = new Intent();
intent.setType( "image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,
"Select Picture"), SELECT_PICTURE);
}

What should I do from this point on? So I can call it in my main menu?

I created a sample libgdx project with android-specific code to call the library and retrieve the file path of the image selected by the user. Hope this Help you understand how the integration works. I tested it on several Android devices.
See https://github.com/miket-ap/libgdx-platform-specific-example

Leave a Comment

Your email address will not be published.