Skip to content Skip to sidebar Skip to footer

Android Studio - How to Create Android Games & Upload to Google Play

Android Studio - How to Create Android Games & Upload to Google Play

How to Create Android Games

How to Create Your Own Android Games Quickly and Easily - As smartphones get more sophisticated, people of all ages are becoming more and more interested in playing mobile games. Because of this, many game developers now create their games for mobile platforms. For instance, one of the most popular and trending mobile games right now is Mobile Legend.

Android Studio

Even though many of them lack programming language abilities, many young people are interested in trying to create their own mobile games in addition to game developers. Depending on your creativity and programming prowess, you can create a wide variety of game kinds or genres. We provided you the sort of quiz example below using Android Studio. Hopefully, this example will pique your curiosity in becoming a game developer and helping you start earning money online.

The official Integrated Development Environment (IDE) for creating Android applications is called Android Studio, and it is based on IntelliJ IDEA. Android Studio has a number of features in addition to its robust code editor and IntelliJ developer tools that boost your efficiency when developing Android games or apps. Here is the link to Download Android Studio.

Process to create a game:

Requirements

  • Install Java JDK, Install Android Studio
  • Android Studio Interface Introduction
  • Linear Layout and Relative Layout
App Description
  • Multiple choice quiz app
  • If the choice is correct, an alert dialog will appear
  • If wrong, a toast will be displayed
 Create Project

         Create a new project with the name example kuissederhana or you can customize your own for the          project name.

Create Project

    Layout Creation

          Create an interface with the following components and layouts:
  • RelativeLayout
  • TextView
  • RadioButton
  • RadioGroup

          Open activity_main.xml then type the following codes:

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout

    xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:id="@+id/activity_main"

    android:padding="15dp">

    <TextView

        android:text="Club sepak bola yang memenangkan liga champions adalah :"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:id="@+id/textView"

        android:textSize="25sp"

        android:textColor="@android:color/black"

        android:layout_alignParentTop="true"

        android:layout_centerHorizontal="true"

        android:textStyle="bold"/>

    <RadioGroup

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:layout_below="@+id/textView"

        android:layout_centerHorizontal="true"

        android:layout_marginTop="39dp"

        android:id="@+id/radioGroup" >

        <RadioButton

            android:text="Real Madrid"

            android:foreground="?attr/selectableItemBackground"

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:id="@+id/radioButton"

            android:onClick="onRadioButton"

            android:layout_toLeftOf="@+id/radioGroup"

            android:layout_toStartOf="@+id/radioGroup"

            android:layout_below="@+id/radioGroup"/>

        <RadioButton

            android:text="Liverpool"

            android:foreground="?attr/selectableItemBackground"

            android:onClick="onRadioButton"

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_below="@+id/radioButton"

            android:layout_alignLeft="@+id/radioButton"

            android:layout_alignStart="@+id/radioButton"

            android:layout_marginTop="36dp"

            android:id="@+id/radioButton2"/>

        <RadioButton

            android:text="Barcelona"

            android:foreground="?attr/selectableItemBackground"

            android:onClick="onRadioButton"

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_marginTop="26dp"

            android:id="@+id/radioButton3"

            android:layout_below="@+id/radioButton2"

            android:layout_alignLeft="@+id/radioButton2"

            android:layout_alignStart="@+id/radioButton2"/>

        <RadioButton

            android:text="Juventus"

            android:foreground="?attr/selectableItemBackground"

            android:onClick="onRadioButton"

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_below="@+id/radioButton3"

            android:layout_alignLeft="@+id/radioButton3"

            android:layout_alignStart="@+id/radioButton3"

            android:layout_marginTop="39dp"

            android:id="@+id/radioButton4"/>

    </RadioGroup>

</RelativeLayout>

      Make sure you enter the programming code correctly then a layout will be formed as shown below:

programming code correctly

      5. Java Coding
      
Next step is give commands to the components that have been formed in activity_main.xml. Open MainActivity.java then enter the code below:

package badoystudio.com.kuissederana;

import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    AlertDialog.Builder builder;
    RadioGroup radiogroup;
    //deklarasi var or obj

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        //radiogroup inisialisasi
        radiogroup = (RadioGroup) findViewById(R.id.radioGroup);

    }

    //Memilih RadioButton

    public void onRadioButton(View view) {

        Boolean checked = ((RadioButton) view).isChecked();

        switch (view.getId()) {
            case R.id.radioButton:
                if (checked)
                    tampilDialog();
                break;

            case R.id.radioButton2:
                if (checked)
                    jawabanSalah();
                break;
            case R.id.radioButton3:
                if (checked)
                    jawabanSalah();
                break;
            case R.id.radioButton4:
                if (checked)
                    jawabanSalah();
                break;
        }

    }

    //menampilkan dialog
    public void tampilDialog() {

        builder = new AlertDialog.Builder(this);
        builder.setCancelable(false);
        builder.setTitle("Selamat !!!");
        builder.setMessage("Jawaban kamu benar : Real Marid");
 builder.setPositiveButton("OKE",new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                Toast.makeText(MainActivity.this, "Selamat", Toast.LENGTH_SHORT).show();
            }
        });

        builder.setNegativeButton("ULANGI", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                radiogroup.clearCheck();
            }
        });

        builder.create().show();

    }
    //menampilkan toast text jawaban salah
    public void jawabanSalah(){

        Toast.makeText(this, "Jawaban kamu Salah", Toast.LENGTH_SHORT).show();
    }
}

      6. Running Applications

The last step, please run the application that has been made using:
  • Android studio default emulator (android virtual device) or directly to the android smartphone, the results are as follows:

Display if True 

True

Display if False

False


BadgerN
BadgerN Welcome to my Blog where you find ideas of beauty arround the world.

Post a Comment for "Android Studio - How to Create Android Games & Upload to Google Play"