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

  • Home
  • SEARCH
  • 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 7528147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:17:52+00:00 2026-05-30T04:17:52+00:00

I’m having a hard time making the chase camera follow the a car body.

  • 0

I’m having a hard time making the chase camera follow the a car body. I am tinkering the Racer Game example project. The Tile Map is 1024 x 786 and the Camera is set to chase the Car Body. Here’s the code:

@Override
    public Scene onCreateScene() {
        this.mEngine.registerUpdateHandler(new FPSLogger());

        this.mScene = new Scene();
        //this.mScene.setBackground(new Background(0, 0, 0));

        /** Tiled Map Test **/
        try {
            final TMXLoader tmxLoader = new TMXLoader(this.getAssets(), this.mEngine.getTextureManager(), TextureOptions.BILINEAR_PREMULTIPLYALPHA, 
                    this.getVertexBufferObjectManager(), new ITMXTilePropertiesListener() {
                @Override
                public void onTMXTileWithPropertiesCreated(final TMXTiledMap pTMXTiledMap, final TMXLayer pTMXLayer, final TMXTile pTMXTile, 
                        final TMXProperties<TMXTileProperty> pTMXTileProperties) {
                    /* We are going to count the tiles that have the property "box=true" or "boxBool=true" set. */
                    if(pTMXTileProperties.containsTMXProperty("box", "true")) {
                        SpeedsterGameActivity.this.numBoxes++;
                    }
                }
            });
            // Load the TMX file into an Object
            this.mTMXTiledMap = tmxLoader.loadFromAsset("tmx/level3.tmx");

            this.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    Toast.makeText( SpeedsterGameActivity.this, "Box count in this TMXTiledMap: " + SpeedsterGameActivity.this.numBoxes, Toast.LENGTH_LONG).show();
                }
            });
        } catch (final TMXLoadException e) {
            Debug.e(e);
        }

        // Get the first TMX Layer and add it to the scene
        final TMXLayer tmxLayer = this.mTMXTiledMap.getTMXLayers().get(0);
        this.mScene.attachChild(tmxLayer);

        /* Make the camera not exceed the bounds of the TMXEntity. */
        this.mBoundChaseCamera.setBounds(0, 0, tmxLayer.getHeight(), tmxLayer.getWidth());
        this.mBoundChaseCamera.setBoundsEnabled(true);

        /* Debugging stuff */
        Debug.i( "Game Info", "Height & Width: " + tmxLayer.getHeight() + " x " + tmxLayer.getWidth() );

        int[] maxTextureSize = new int[1];
        GLES20.glGetIntegerv( GLES20.GL_MAX_TEXTURE_SIZE, maxTextureSize, 0);
        Debug.i("Game Info", "Max texture size = " + maxTextureSize[0]);
        /**********/

        /* Calculate the coordinates for the face, so its centered on the camera. */
        final float centerX = (CAMERA_WIDTH - this.mVehiclesTextureRegion.getWidth()) / 2;
        final float centerY = (CAMERA_HEIGHT - this.mVehiclesTextureRegion.getHeight()) / 2;

        /* Create the sprite and add it to the scene. */
        final AnimatedSprite player = new AnimatedSprite(centerX, centerY, this.mVehiclesTextureRegion, this.getVertexBufferObjectManager());
        this.mBoundChaseCamera.setChaseEntity(player);
        /********************/

        this.mPhysicsWorld = new FixedStepPhysicsWorld(30, new Vector2(0, 0), false, 8, 1);

        //this.initRacetrack();
        //this.initRacetrackBorders();

        this.initCar();
        this.initObstacles();
        this.initOnScreenControls();

        this.mScene.registerUpdateHandler(this.mPhysicsWorld);

}
  • 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-30T04:17:54+00:00Added an answer on May 30, 2026 at 4:17 am

    A possible cause of the problem is that your camera size is 1024×786 too, therefore the full camera rectangle is shown and since you enabled bounds, the camera does not follow the car.

    Omit the line this.mBoundChaseCamera.setBoundsEnabled(true);.

    Another problem is – the camera follows the player object to which you lose the reference once onCreateScene finishes executing. You are not connecting the player object to a physics body using PhysicsConnector class, so it has no reason to move.

    Otherwise if the car body & entity are created in initCarmethod, you are not setting the car as the chase entity.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
i got an object with contents of html markup in it, for example: string
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I'm making a simple page using Google Maps API 3. My first. One marker
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.