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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:18:14+00:00 2026-05-19T01:18:14+00:00

First let me explain my goal. I am trying to make an Animation that

  • 0

First let me explain my goal. I am trying to make an Animation that changes the properties of an ArcShape. An ArcShape's constructor takes two fields: startAngle and sweepAngle. I want to animate the sweepAngle so that it appears on screen as a continuously shrinking circle.

You can picture this animation by imagining PacMan. Imagine his mouth is closed. This animation would be akin to him opening his upper jaw more and more until there was no more PacMan.

Now… I have a couple of issues with implementing this. First, once an ArcShape is created, there are no built in methods of changing it’s sweepAngle. This brings me to my first question: Is there any way to override ArcShape and implement some setSweepAngle method? Or will I have to create a new ArcShape for each sweepAngle I wish to display?

Now on to the second issue… Assuming I found a solution to the first issue, how could I create this Animation? This is the gist of what I have now:

public class OpenPacman extends Animation {
  public OpenPacman(float startAngle, float sweepAngle) {
    mStartAngle = startAngle;
    mSweepAngle = sweepAngle;
  }

  @Override
  protected void applyTransformation(float interpolatedTime, Transformation t) {
    /* This represents the current sweepAngle */
    float currAngle = mStartAngle + ((mSweepAngle - mStartAngle) * interpolatedTime);

    //Now I need to update the ArcShape's sweepAngle to currAngle. But HOW?
  }
}
  • 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-19T01:18:15+00:00Added an answer on May 19, 2026 at 1:18 am

    I have found a solution. I have a class that extends View We’ll call this Pacman I nested my custom Animation within this Pacman class. This allowed me to access the member variables of the Pacman class.

    public class Pacman extends View {
      float mSweepAngle;
      ...
      //include constructors
      //override onMeasure
      ...
    
      /* Here we override onDraw */
      @Override
      protected void onDraw(final Canvas canvas) {
        Paint p = new Paint(Paint.ANTI_ALIAS_FLAG);
        RectF oval = new RectF(canvas.getClipBounds());
        canvas.drawArc(oval, 0, mCurrAngle, true, p);
      }
    
      /* Here we define our nested custom animation */
      public class OpenPacman extends Animation {
        float mStartAngle;
        float mSweepAngle;
    
        public OpenPacman (int startAngle, int sweepAngle, long duration) {
          mStartAngle = startAngle;
          mSweepAngle = sweepAngle;
          setDuration(duration);
          setInterpolator(new LinearInterpolator());
        }
    
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
          float currAngle = mStartAngle + ((mSweepAngle - mStartAngle) * interpolatedTime);
          Pacman.this.mCurrAngle = -currAngle; //negative for counterclockwise animation.
        }
      }
    }
    

    Now when the custom animation updates the container classes mCurrAngle, onDraw is automatically called, which draws the appropriate ArcShape.

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

Sidebar

Related Questions

First let me explain. I have several addresses on the page that I put
Let me first explain what's I'm trying to do. So I have a entity
Quite new to maven here so let me explain first what I am trying
First let me explain that I've created a million lib directories scouring out all
Let me first explain what I'm trying to achieve using some pseudo-code (JavaScript). //
Let me explain the context first. There are two databases sitting on two distinct
That's the first time i get an error like this one, let me explain
First let me explain that I have this script that should let users enter
First off, let me explain that I am well aware of what this exception
First let me explain that I am on a hosted solution, and there is

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.