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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:52:37+00:00 2026-05-23T03:52:37+00:00

This is about animation in JAVA. I had success when using same dimension on

  • 0

This is about animation in JAVA. I had success when using same dimension on all picture. But if i keep all picture dimension on same size(width and height) i get some bug which when player punch. Before player’s hand touch enemy body, enemy died

But others with my case where idle, run, and punch has an different
dimension. Punching animation facing to the left became very strange.
Should his hand hit to the left but his body shifts to the right. This
is because I draw on the x & y are the same.

How can I fix it? Need instructions 😀

I use png coz support transparent

I think this can fix with 2 option
1. Fix my collision detection
2. Fix of drawing position my image when some condition occur

  • 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-23T03:52:38+00:00Added an answer on May 23, 2026 at 3:52 am

    Trying to picture your problem, hope this helps.
    I am typeing directly from my head, so there are might errors in code

    1. fixing coalision decection
      i would try this

       Image fist
       Image enemy
          //in paint
      
      g2D.drawImage(fist,x,y,this);
      
      g2D.drawImage(enemy,x1,y1,this);
      
      Rectangle2D myFist = new Rectangle2D.Double(x,y,fist.getWidth(this),fist.getHeight(this));
      Rectangle2D myEnemy = new Rectangle2D.Double(x1,y1,enemy.getWidth(this),enemy.getHeight(this));
      if (myEnemy.contains(myFist){
      //action u want to happend
      }
      

    I think something like this should fix coalision problems
    I am seeing this as mario a game on sega

    1. Fix of drawing position

      //arm image can be the same image if u want
          Image leftArm;
          Image rightArm;
          image headLegsAndTorsoLeft;
          image headLegsAndTorsoRight;
          //where am i looking in game if true i look to the leftside of user thats playing
          boolean turnedLeft
          //in paint
          if(turnedLeft){
          //this lets it look like he is turned to the left with his right arm in the visible behind his left.
          //draw right arm
          g2D.drawImage(rightArm,x,y,this);
          //draw body moved a bit in x coor
                      g2D.drawImage(headLegsAndTorsoLeft,x-3,y,this);
         // draw left arm a bit more in x coor
          g2D.drawImage(leftArm,x-6,y,this);
          }else{
           //this lets it look like he is turned to the right with his left arm in the visible behind his right.
          // draw left arm
              g2D.drawImage(leftArm,x,y,this);
           //draw body moved a bit in x coor
              g2D.drawImage(headLegsAndTorsoRight,x-3,y,this);
       //draw right arm a bit more in x coor
              g2D.drawImage(rightArm,x-6,y,this);
              }
      

      same order for animation of arms, ultimatly i would use different methods animations for torso, leftarm, rightarm
      something like keypressed leftarrow torso does walking animation left, hit left arm key moves left arm,hit right arm key moves right arm,thats 3 for lets say left arm, now u need another 3 for when ur char is moved to the right.

      Thats how i would try to do things.

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

Sidebar

Related Questions

This question is similar to this one about animation queues , but the answers
This is about a web app that serves images. Since the same request will
A java program that does frequent swing/awt painting animation (but nothing more advanced than
This is about an iPhone App using MKMapKit: I created a custom MKAnnotationView for
This is about an iPhone App using MKMapKit: I created a custom MKAnnotationView for
I did some digging around about this, but nothing really seems to answer my
First of all, I know there are a few other StackOverflow questions about this
I just noticed this about a week ago. I'm storing data about the current
The MySQL 5.4 documentation, on Optimizing Queries with EXPLAIN , says this about these
This is about when a .NET remoting exception is thrown. If you take a

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.