Android - No consigo mejorar o cambiar algunas cosas de mi juego Java hecho Android Studio

 
Vista:

No consigo mejorar o cambiar algunas cosas de mi juego Java hecho Android Studio

Publicado por Dhanen (1 intervención) el 08/05/2023 18:03:33
Buenas a todos,

Ante todo, espero estar abriendo este hilo en el sitio adecuado.

Mi app es un juego "Simón Dice" hecho en Android Studio en lenguaje de programación Java y ambientado en Star Wars (Vader Says). Soy muy novato programando todavía a pesar de haberme sacado una titulación y quiero mejorar. Ahora mismo me siento lerdísimo tras días y días intentando lo que expondré sin éxito.

Lo que quiero cambiar o conseguir:

1.- La tabla de puntuaciones se muestra en un scroll vertical, moviéndose de abajo a arriba (cuando termina vuelve a empezar). Lo ideal y que no he conseguido a pesar de haberme tirado días es que el efecto sea más como Star Wars y se muestre sesgado, como yendo hacia el fondo (como en los créditos de inicio de las pelis, vamos).
He intentado con librerías como CreditsRoll, pero tiene 8 años y no he conseguido aplicarla ni usarla.
He intentado traducir del Kotlin (no conozco Kotlin, resultado desastroso como podréis prever).
He intentado adaptar otros proyectos y librerías similares sin éxito.
He intentado servirme de ChatGPT y... resultado más que desastroso.

2.- He visto que algunas "Activity" no son "responsive": amigos han probado el juego en su dispositivo y, por ejemplo en la que insertas el nombre, el botón y el campo de texto salen de pantalla. No sé cómo asegurarme de que se redimensione correctamente.

3.- Quiero ordenar la puntuación de mayor a menor. El nombre y la puntuación de esa tabla viene de dos "Activities" distintas, por lo que no he sabido cómo ordenarlo sin intercambiar nombres y puntos.


Parte del código en sí.

La "Scoreboard Activity":

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import android.content.Intent;
import android.graphics.Typeface;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.SoundPool;
import android.os.Bundle;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.method.ScrollingMovementMethod;
import android.text.style.StyleSpan;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.TextView;
 
import androidx.appcompat.app.AppCompatActivity;
 
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
 
public class ScoreBoard extends AppCompatActivity{
 
    TextView scoreboard, title;
    int scoreBoardSound;
    private SoundPool soundPool;
    private static final String FILENAME = "scoreboard.txt";
    MediaPlayer mMediaPlayer = new MediaPlayer();
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.scoreboard);
        mMediaPlayer = MediaPlayer.create(this, R.raw.thronethemescore);
        mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
        mMediaPlayer.setLooping(true);
        mMediaPlayer.start();
        instantiateElements();
        setElementsToListener();
        readFile();
    }
 
    private void setElementsToListener() {
        scoreboard.setOnClickListener(listener);
        title.setOnClickListener(listener);
    }
 
    private void instantiateElements() {
        scoreboard = (TextView) findViewById(R.id.pointslist);
        scoreboard.setMovementMethod(new ScrollingMovementMethod());
        title = (TextView) findViewById(R.id.title);
    }
 
    View.OnClickListener listener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            switch(v.getId()) {
                case R.id.pointslist:
                    screenTapped(v);
                    break;
                case R.id.title:
                    screenTapped(v);
                    break;
                default:
                    screenTapped(v);
                    break;
            }
        }
    };
 
    public void screenTapped(View view){
        mMediaPlayer.stop();
        Intent backmain = new Intent(ScoreBoard.this, VaderSaysActivity.class);
        startActivity(backmain);
    }
 
    private void readFile(){
        FileInputStream fis = null;
        try{
            fis = openFileInput(FILENAME);
            InputStreamReader isr = new InputStreamReader(fis);
            BufferedReader bufferedReader = new BufferedReader(isr);
            String scoreline;
            StringBuilder strBuilder = new StringBuilder();
            while ((scoreline = bufferedReader.readLine()) != null){
                strBuilder.append(scoreline).append("\n");
            }
            Animation translatebu= AnimationUtils.loadAnimation(this, R.anim.animationfile);
            scoreboard.setText(strBuilder);
            scoreboard.startAnimation(translatebu);
            scoreboard.setText(strBuilder);
            Spannable span = new SpannableString(scoreboard.getText());
            span.setSpan(new StyleSpan(Typeface.BOLD), 100, 0, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
            scoreboard.setText(span);
        }catch (Exception e){
            e.printStackTrace();
        }finally{
            if(fis != null){
                try{
                    fis.close();
                }catch (Exception e){
                    e.printStackTrace();
                }
            }
        }
    }
}


La "Scoreboard layout":

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/bkgrscoreboard"
    android:soundEffectsEnabled="false"
    android:onClick="screenTapped">
 
    <TextView
        android:id="@+id/title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:textSize="50dp"
        android:fontFamily="@font/jedifont"
        android:soundEffectsEnabled="false"
        android:textColor="#d5d900"
        android:text="tabla de puntuaciones" />
 
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="40dp"
        android:soundEffectsEnabled="false"
        android:src="@drawable/linesaber" />
 
    <TextView
        android:id="@+id/pointslist"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:textSize="14dp"
        android:soundEffectsEnabled="false"
        android:fontFamily="@font/jedifont"
        android:textColor="#fffda6"
        android:scrollbars="vertical"
        android:text="" />
 
</LinearLayout>


El "layout" donde se inserta el nombre (el que no es responsive):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:background="#000"
    android:soundEffectsEnabled="false"
    android:orientation="vertical" >
 
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
 
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:soundEffectsEnabled="false"
            android:orientation="vertical">
 
            <ImageView
                android:id="@+id/chokinglost"
                android:layout_width="match_parent"
                android:layout_height="473dp"
                android:soundEffectsEnabled="false"
                android:src="@drawable/vaderchoke2" />
 
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:fontFamily="@font/jedifont"
                android:text="introduce tu nombre, escoria rebelde"
                android:soundEffectsEnabled="false"
                android:textAlignment="center"
                android:textColor="#d5d900"
                android:textSize="30dp" />
        </LinearLayout>
    </RelativeLayout>
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent">
 
        <EditText
            android:id="@+id/inputnicktext"
            android:layout_width="257dp"
            android:layout_height="85dp"
            android:ems="10"
            android:fontFamily="@font/jedifont"
            android:inputType="textPersonName"
            android:textColor="#d5d900"
            android:soundEffectsEnabled="false"
            android:textSize="32dp"
            android:text="anónimo"
            tools:ignore="SpeakableTextPresentCheck" />
 
        <Button
            android:id="@+id/inputnickbutton"
            android:layout_width="149dp"
            android:layout_height="90dp"
            android:background="#172438"
            android:fontFamily="@font/jedifont"
            android:text="0k"
            android:textAlignment="center"
            android:textColor="#d5d900"
            android:soundEffectsEnabled="false"
            android:textSize="50dp" />
 
    </LinearLayout>
 
</LinearLayout>


Si hace falta más código o lo que sea, pedidlo.

He de decir que intenté preguntar en Stackoverflow, me han hecho reescribir el post 80 veces, pero no me han ayudado aún. Pensé que sería más fácil expresarme en un foro hispanohablante. Siento el tochazo y ser tan lerdo ahora mismo, espero que quede claro y podáis ayudarme. Gracias de antemano.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder