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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:47:57+00:00 2026-06-09T17:47:57+00:00

Hi in my application I have an explosion animation that comes up extremely often.

  • 0

Hi in my application I have an explosion animation that comes up extremely often. when creating an explosion I load 3 images from resources then once the explosion animation is over I recycle those 3 images. I am constantly doing this and have noticed framerate drops. Is their a better way of doing this like static bitmaps or something?

  • 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-09T17:47:59+00:00Added an answer on June 9, 2026 at 5:47 pm

    I once made an application, a simple canvas on which bombs exploded.
    I used a tiled bitmap composed of each step of the explosion and drew only a part of it, which changes often in order to create the animation effect.
    It updates steps automatically following currentTimestamp

    So this is the explosion class:

    public class ExplosionAnimated {
    
    private static final String TAG = ExplosionAnimated.class.getSimpleName();
    
    private Bitmap mBitmap;
    private Rect mSourceRect;
    private int mFrameCountX;
    private int mFrameCountY;
    private int mCurrentFrame;
    private long mFrameTicker;
    private int mFramePeriod;
    
    private int mSpriteWidth;
    private int mSpriteHeight;
    
    private int mX;
    private int mY;
    
    private boolean mFinished = false;
    
    public ExplosionAnimated(Bitmap pBitmap, int pX, int pY, 
            int pFrameCountX, int pFrameCountY, int pFps) {
    
        this.mBitmap = pBitmap;
        this.mX = pX;
        this.mY = pY;
        this.mCurrentFrame = 0;
        this.mFrameCountX = pFrameCountX;
        this.mFrameCountY = pFrameCountY;
        this.mSpriteWidth = pBitmap.getWidth() / pFrameCountX;
        this.mSpriteHeight = pBitmap.getHeight() / pFrameCountY;
        this.mSourceRect = new Rect(0, 0, this.mSpriteWidth, this.mSpriteHeight);
        this.mFramePeriod = 1000 / pFps;
        this.mFrameTicker = 0l;
    }
    
    public void update(long gameTime) {
    
        if (gameTime > this.mFrameTicker + this.mFramePeriod) {
            this.mFrameTicker = gameTime;
    
            this.mCurrentFrame++;
            if (this.mCurrentFrame >= this.mFramePeriod) {
                this.mCurrentFrame = 0;
                this.mFinished = true;
            }
        }
    
        if (!this.mFinished) {
    
            this.mSourceRect.left = this.mCurrentFrame * this.mSpriteWidth;
            this.mSourceRect.right = this.mSourceRect.left + this.mSpriteWidth;
        }
    }
    
    public void draw(Canvas canvas) {
    
        Rect destRect = new Rect(this.mX, this.mY, 
                this.mX + this.mSpriteWidth, 
                this.mY + this.mSpriteHeight);
        canvas.drawBitmap(this.mBitmap, this.mSourceRect, destRect, null);
    }
    
    public boolean isFinished() {
        return this.mFinished;
    }
    }
    

    These are methods from an object (Bomb.java for exemple) that starts explosion and draw it:

    public void explode(Context pContext, Canvas pCanvas) {
    
        this.mState = State.EXPLODING;
        this.mExplosion = new ExplosionAnimated(this.mExplosionBitmap, 
                (int) this.mX, (int) this.mY, 7, 3, 7);
    }
    
    public void doDraw(Canvas pCanvas) {
    
        if (this.mState == State.EXPLODING) {
    
            if (this.mExplosion.isFinished()) {
                this.mState = State.EXPLODED;
            } else {
                this.mExplosion.update(System.currentTimeMillis());
                this.mExplosion.draw(pCanvas);
            }
        } else {
            pCanvas.drawBitmap(this.mBombBitmap, this.mX, this.mY, null);
        } 
    }
    

    I used a Thread and a SurfaceView to continually draw the bomb (or the explosion), giving just the currentTimestamp to update the explosion.

    I hope it helps, and if you need I can show and explain more code

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

Sidebar

Related Questions

I have Silverlight application that retrieves data from the database through a WCF Service.
In My application have time consuming process.There fore i try to do that operation
My Application has 3 activities (MainActivity,SampleActivity,TempActivity) and Application have to start from MainActivity because
My application have some problem on opening 32bit BMP images. some image has alpha
I have a Delphi application that communicates with web servers on the Internet using
My problem is that my application have around 12-13 screen, and all of that
I have a web application, written in PHP that incorporates Javascript and JQuery, that
I am creating one application in that i want to give background effect like
I have PHP application that contain three small applications. Each application have own users
I have an application with an NSMenuItem that launches a separate window and I

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.