“RUN” それは魔法の言葉

私とコンピュータの思い出を、だらだらと綴ります。最近はHSP3でのゲーム作り日記です

268.LCD風ゲームを作ろう 月面鮫 その6

ゲーム部以外を整えていく。
もう、フォーマットが決まってきたので、昔のソースを流用しつつ、ゲームセレクトや、マニュアル表示、音量調整などを作っていった。
特筆すべき事項は、やっぱりないww

今回は最初から液晶パターンの濃さを二段階に変更できるようにした。gmode 3がちゃんと使えるようになったので、画像の差し替えが不要になり、Android版にも機能として盛り込めた。

今回は開発にHSP標準のエディタではなく、VS Codeを使ったので、apkファイルにするためだけに、Dish Helplerを使った。
ここで、前回トライしてダメだった、アプリアイコンの調整にチャレンジした。
この先は、備忘録もかねてw

Dish Helperでも、512x512のpng画像を用意するだけで、自動的にアプリ用のアイコンを作る機能があるんだけど、どうしても周りに余白ができてしまう。

そこでAndroid Studioを使って、アプリアイコンだけ作成する。
操作方法、作り方は、このブログを参考にした。
hirokuma.blog

肝心のアプリアイコンの絵は、自分で描けるわけないww。ということで今回は、ChatGPTに描いてもらった絵を利用した。

ChatGPTに描いてもらった

月面が舞台なのに、背景に月があるのはご愛敬ww

この絵をAndroid StudioのImage Asset機能に読み込んでアイコンを作る。

このように円形のアイコンにも、四角のアイコンにも対応するように、絵を当てはめていく。
これを出力すると、resフォルダが作られる。


こんな感じ。

ただ、このフォルダ構成とフォルダ名は、Dish Helperで出力されるものと違っている。
そのため、AndroidManifest.xmlを書き換える。

Android Studioで書き出されたAndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">

    <application
        android:allowBackup="true"
        android:dataExtractionRules="@xml/data_extraction_rules"
        android:fullBackupContent="@xml/backup_rules"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.Getsumenzame"
        tools:targetApi="31">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:label="@string/app_name"
            android:theme="@style/Theme.Getsumenzame">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Dish Helperで書き出されたAndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">


    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true">
        <uses-library android:name="org.apache.http.legacy" android:required="false"/>
        <meta-data
            android:name= "com.google.android.gms.ads.APPLICATION_ID"
            android:value= "ca-app-pub-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" />
        <meta-data
            android:name= "com.google.android.gms.ads.flag.OPTIMIZE_AD_LOADING"
            android:value= "true" />

        <activity android:name="tv.hsp.HspActivity"
            android:exported="true"
            android:resizeableActivity="false"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
            android:label="@string/app_name">
        <meta-data android:name="android.app.lib_name"
            android:value="hspproj" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
    <uses-feature android:name="android.hardware.vibrate" android:required="false" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.VIBRATE"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="com.google.android.gms.permission.AD_ID"/>

</manifest>

前回ビルドに失敗したときに、エラーをよく見ていれば、すぐ原因は分かっていただろう…
フォルダ構成が全然違ってた。

android:icon="@drawable/ic_launcher" の @drawable がフォルダ名の先頭部分を表している。
Android Studioで出力したフォルダは、drawableフォルダもあるが、「mipmap」フォルダ内に、実際のアイコン画像が保存されていた。
あと、丸いアイコンの記述がないので追加した。

resフォルダをそのまま差し替えると、また動かなくなりそうなので、「drawable」の派生名フォルダ(アイコン画像が保存されているフォルダ)のみ削除し、「mipmap」の派生名フォルダを選んでコピーした。

神頼みしながらビルド!
無事通った♪
apkファイルをGoogleドライブ経由でインストールしてアイコンを確認。

インストール時のアイコン

期待通り♪ 右にある「鮫蛸獣」のアイコンと比べると、違いがよくわかる。
今後のアプリもこの方法でアイコンを作ろう。

aabファイルもリリースビルドで作成できて、Google先生におまじないをし、無事公開されました。
play.google.com

今年のHSPプログラムコンテストにも応募して、これで参加賞は確定したw

調子に乗ってPVも作ってみたので、お暇な方は見てくださいねー。
youtu.be