Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8883405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:48:16+00:00 2026-06-14T20:48:16+00:00

I have a game where the user is moving around on a canvas and

  • 0

I have a game where the user is moving around on a canvas and can interact with an item in this scenario a dog which triggers a battle.

This loads up a dialog giving the user the option to fight or run away. The user clicks fight, which then brings up another dialog, this displays some text (your details and the dogs details), and underneath that text there is an attack buttons.

When you click the attach button a few things happen (not relvent), which essentially mean the user and dog details change (e.g. DogHP drops to 18).

So my question is:

  • The first dialog box that I load has dynamic information ‘Dog HP’.
  • After the attack button is clicked then that information is changed.
  • Therefore, I need to update the first dialog box with the new information which I am currently displaying using builder.setMessage()
  • e.g. orginal HP = 20 … attack button clicked … new HP = 10

Please see some code snippet below, any ideas or guidence would be much appreciated:

Code Snippet:

void Fight()
{
    final int DogHP = 25;
    final int DogAtk = 15;
    final int DogDef = 5;
    final int DogSpeed = 20;

    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(context.getText(R.string.monster_dog_title));
    LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.fight, null);
    builder.setView(view);
    final AlertDialog DogBattle = builder.create();

    View FightBtn = view.findViewById(R.id.dog_fight);
    FightBtn.setOnClickListener(new OnClickListener()
    {
        boolean attacked = false;
        @Override
        public void onClick(View clicked)
        {
            if(clicked.getId() == R.id.dog_fight)
            {
                AlertDialog.Builder builder = new AlertDialog.Builder(context);
                builder.setTitle(context.getText(R.string.monster_fight));
                builder.setMessage("Your Current Battle Details:\n" + "HP = " + UserHP + "  Def = " + UserDef + "  Atk = " + UserAtk + "\n\n" + "Your Enemy:\n" + "HP = " + DogHP + "  Def = " + DogDef + "  Atk = " + DogAtk);

                LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                View view = inflater.inflate(R.layout.monsterbattle, null);
                builder.setView(view);
                final AlertDialog BattleRun = builder.create();
                BattleRun.show();
                View LeaveBattle = view.findViewById(R.id.Attack);
                LeaveBattle.setOnClickListener(new OnClickListener()
                {
                    @Override
                    public void onClick(View clicked)
                    {
                        if(clicked.getId() == R.id.Attack)
                        {
                            // SOME CODE GOES HERE
                        }
                    }
                });
            }
        }
    });
}

Thanks in Advance for any help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T20:48:17+00:00Added an answer on June 14, 2026 at 8:48 pm

    I decided to completly scrap the idea above, as it was too much happening in the dialog and ended up creating a new class along with using objects instead of variables.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a game which displays an array of colored blocks. The user can
I have created a game where the user can upload their high score and
Imagine that HTML page is a game surface (see picture). User can have n
I am developing an android game, in which i have some trains moving on
I have this animation I've made which is an arm moving from above some
I have a game where user controls a character (with his finger) and i
I am making a game, and have a Game model and a User model.
I have this game where balloons are coming from bottom and player has to
I'm working on a Windows game, and I have this: bool game_cont; LRESULT WINAPI
I m working on a word scramble game which allows user to move the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.