LoginSignup
0
0

More than 1 year has passed since last update.

【Android Kotlin】RPGの戦闘シーンを再現してみる

Last updated at Posted at 2021-07-02

完成イメージ

スクリーンショット 2021-04-03 8.55.13.png

デザインの一例

スクリーンショット 2021-04-03 11.12.49.png

レイアウト

サンプルコード

activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#222222"
    android:orientation="vertical"
    tools:context=".MainActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"
        android:background="@drawable/forest"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="#52222222"
            android:orientation="horizontal"
            android:padding="8dp">

            <TextView
                android:id="@+id/hpCaption"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingStart="4dp"
                android:text="HP:"
                android:textColor="#FFFFFF"
                android:textSize="48sp" />

            <TextView
                android:id="@+id/hpText"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="10"
                android:textColor="#FFFFFF"
                android:textSize="48sp" />
        </LinearLayout>

        <ImageView
            android:id="@+id/imageView"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            app:srcCompat="@drawable/slime" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:padding="4dp">

        <Button
            android:id="@+id/attackButton"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_margin="4dp"
            android:layout_weight="1"
            android:backgroundTint="#222222"
            android:text="こうげき"
            app:strokeColor="#FFFFFF"
            app:strokeWidth="1dp" />

        <Button
            android:id="@+id/itemButton"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_margin="4dp"
            android:layout_weight="1"
            android:backgroundTint="#222222"
            android:text="もちもの"
            app:strokeColor="#FFFFFF"
            app:strokeWidth="1dp" />
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:padding="4dp">

        <Button
            android:id="@+id/defenceButton"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_margin="4dp"
            android:layout_weight="1"
            android:backgroundTint="#222222"
            android:text="ぼうぎょ"
            app:strokeColor="#FFFFFF"
            app:strokeWidth="1dp" />

        <Button
            android:id="@+id/escapeButton"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_margin="4dp"
            android:layout_weight="1"
            android:backgroundTint="#222222"
            android:text="にげる"
            app:strokeColor="#FFFFFF"
            app:strokeWidth="1dp" />
    </LinearLayout>
</LinearLayout>

HPを減らす処理

工事中
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0