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 7591673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:42:33+00:00 2026-05-30T20:42:33+00:00

I want to move background with the bob(Android Game Character) moving for that I

  • 0

I want to move background with the bob(Android Game Character) moving for that I make a Dynamic object name Background

    public static int BACKGROUND_MOVE=0;
  public static int BACKGROUND_FALL=1;
 public static final float BACKGROUND_MOVE_VELOCITY =3.5f;
 public static float BOB_WIDTH =10.0f;
 public static float BOB_HEIGHT =15.0f;
 public static long startTime = 0;
 public int state;
 public float stateTime;
public BackGround(float x, float y)
 {
    super(x, y, BOB_WIDTH, BOB_HEIGHT);
    state = BACKGROUND_MOVE;
    stateTime = 0;
    accel.set(0,-2);
    velocity.y=3.5f;//55

 }  

public void update (float deltaTime)
 {
    //velocity.add(World.gravity.x, World.gravity.y * deltaTime);
    velocity.add(accel.x * deltaTime,accel.y*deltaTime);
            position.add(velocity.x * deltaTime, velocity.y * deltaTime);

    if (velocity.y > 0 && state==Bob.BOB_STATE_HIT)//BOB_STATE_HIT is bob running //condition
       {
            if (state != BACKGROUND_MOVE)
            {
                state = BACKGROUND_MOVE;
                stateTime = 0;
            }
        }

    if (velocity.y > 0 && state != Bob.BOB_STATE_HIT)
         {
        if (state != BACKGROUND_FALL)
         {
            state = BACKGROUND_FALL;
            stateTime = 0;
         }
       }
  //        if (velocity.y < 0 && state == BOB_STATE_HIT)
 //       {
  //            if (state != BOB_STATE_JUMP) {
 //             state = BOB_STATE_JUMP;
//              stateTime = 0;
//          }
    //}

    //if (position.y < 0) position.x = World.WORLD_WIDTH;
    //if (position.x > World.WORLD_WIDTH) position.x = 0;
    stateTime += deltaTime;
   }
 public void move()
    {
    if(state==BACKGROUND_MOVE)
    {
    startTime=System.nanoTime()/1000000000; 
  //        state = BACKGROUND_MOVE;
    velocity.y = BACKGROUND_MOVE_VELOCITY;
    stateTime = 0;
    }
 }

similar to bob I amke object in World class and make an ArrayList Add Backgroung into that arraylist and at time of drawing get from arraylist and draw it…but no any effect show simply screen show and cross the rangeand red screen shown…please anyone help..

       /*---------------background cam------*/

      this.bcam = new OrthographicCamera(FRUSTUM_WIDTH,FRUSTUM_HEIGHT);
       this.bcam.position.set(FRUSTUM_WIDTH,FRUSTUM_HEIGHT, 0);
       this.batch = batch;

          public void renderBackground()
          {
    GLCommon gl = Gdx.gl;
    gl.glClearColor(1, 0, 0, 1);
    gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
    bcam.update();
    batch.setProjectionMatrix(bcam.combined);
    batch.disableBlending();
    batch.begin();
    if (world.objbackground.state ==BackGround.BACKGROUND_MOVE)
    batch.draw(Assets.mainbackgroundRegion, cam.position.x - FRUSTUM_WIDTH / 2,       cam.position.y - FRUSTUM_HEIGHT / 2, FRUSTUM_WIDTH, FRUSTUM_HEIGHT);
        //       else
        //       {
        //       batch.draw(Assets.touchbackgroundRegion, cam.position.x -
        //       FRUSTUM_WIDTH / 2, cam.position.y - FRUSTUM_HEIGHT / 2,
        //       FRUSTUM_WIDTH, FRUSTUM_HEIGHT);
        //       if (elapsed == 5)
        //              changebackground = 0;
        //       }
      batch.end();
   }
  • 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-05-30T20:42:35+00:00Added an answer on May 30, 2026 at 8:42 pm

    Either you want to move the background with Bob (1) or you want to have a fixed background (2):

    (1): Set background’s position to Bob’s (probably with an offset, you can do that in the update function of the world), render using batch.draw(......, background.position.x, background.position.y).

    (2): Throw away your complicated update methods in the BackGround object and use the render method as you do now.

    But honestly, your intentions and explanations are not very clear, try to improve on that!

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

Sidebar

Related Questions

I have an object that have a background with background-position top right I want
I want to make a game where the playing pieces can move around. When
I want to move a file with Ruby. How do I do that?
I want to move my form window by left-clicking and holding on the background
i have this void function that moves two background imags horizontally, but i want
I want to make something similar to the CSS/JQUERY effect that you can see
What i want to do is make it so that the text of a
I have an image that is a sprite, I want to move the scroll
I am writing a web app that uses HTML5 audio. I want to make
I want to create a number of div s that I can move and

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.