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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:28:32+00:00 2026-06-14T00:28:32+00:00

I really need help with this one. I am working with a game and

  • 0

I really need help with this one. I am working with a game and have encountered a problem where it lags everytime an element is getting removed from my lists with objects. I have searched for solutions and found out about using iterators to reduce lag, but still, it lags. I have used both ArrayList and LinkedList, but they both end up with the same result.

This is an example of the code I am using for my lists:

Initialize:

private LinkedList<Background> bg = new LinkedList<Background>();

Render:

for (Iterator<Background> iterator = bg.iterator(); iterator.hasNext();) {
            Background back = iterator.next();
            if (back.getX()-(-width-1) > 0) {
                if ((back.getX() < width) || (back.getX()+width > 0)) {
                    back.draw(canvas);
                } else {
                    iterator.remove();
                }
            }
        }

This is the draw function inside the object class in which back.draw(canvas); is calling from:

    public void draw(Canvas canvas) {
    // where to draw the sprite
    Rect destRect = new Rect(getX(), getY(), getX() + spriteWidth, getY() + spriteHeight);
    canvas.drawBitmap(bitmap, sourceRect, destRect, null);
    //canvas.drawBitmap(bitmap, 20, 150, null);
    //Paint paint = new Paint();
    //paint.setARGB(50, 0, 255, 0);
    //canvas.drawRect(20 + (currentFrame * destRect.width()), 150, 20 + (currentFrame * destRect.width()) + destRect.width(), 150 + destRect.height(),  paint);
}

Maybe there is something that has to be changed in the MainThread that handles the FPS? Or is there any other solution? I have heard about sets, but can’t seem to find any good example try it out.

Something to point out is that I am using Canvas, not OpenGL.
Something else to point out is that each element in the above array has an image size of 800×480. I have tried to reduce the quality of the image, but it doesn’t make much of a difference.

Thank you.

  • 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-14T00:28:33+00:00Added an answer on June 14, 2026 at 12:28 am

    Its probably with the amount of computation you are doing in draw. I am sure its nothing to do with the collection you use.

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

Sidebar

Related Questions

I really need help with this one. I have written an adding that adds
I really need help on this one. I am having a simple login form
We Really need some help on this one: We've Struggled with all the Apple
I really need some help with this as I have been trying to fix
I really need help here. I'm desperate at this point. I have NSOperation that
I need help with this batch file I'm working on, Basically everytime it does
I have a problem I could need some help with. I am working on
guys i really REALLY need some help on this one. 2 days i've been
I really need help this time - Joomla 2.5 and latest K2. I'm using
I really need help with this last part of my program. I need to

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.