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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:22:12+00:00 2026-05-22T01:22:12+00:00

My application fires up sprite instances around a Canvas which then move across the

  • 0

My application fires up sprite instances around a Canvas which then move across the screen towards a x/y coordinate. I would like to be able to rotate the sprite around its center so that it faces its destination coordinates. I am using a sprite-sheet and have had issues with clipping. I have also found a lot of good examples but nothing seems to cover exactly what I’m looking for. This example is very close but for efficiency I am using an ImagePooler class and cannot reload an image on each draw/rotation. So if someone had an idea on how to rotate the preloaded image w/out cutting my sprite-sheet I would be very grateful.

  • 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-22T01:22:13+00:00Added an answer on May 22, 2026 at 1:22 am

    First it is easy to rotate a sprite you can use canvas or matrix:

    Matrix matrix = new Matrix();
    matrix.postRotate(angle, (ballW / 2), (ballH / 2)); //rotate it
    matrix.postTranslate(X, Y); //move it into x, y position
    canvas.drawBitmap(ball, matrix, null); //draw the ball with the applied matrix
    
    // method two 
    canvas.save(); //save the position of the canvas
    canvas.rotate(angle, X + (ballW / 2), Y + (ballH / 2)); //rotate the canvas' matrix
    canvas.drawBitmap(ball, X, Y, null); //draw the ball on the "rotated" canvas
    canvas.restore(); //rotate the canvas' matrix back
    //in the second method only the ball was roteded not the entire canvas
    

    To turn it towards a destination you need to know the angle between the sprite and the destination:

    spriteToDestAngle =  Math.toDegrees(Math.atan2((spriteX - destX)/(spriteY - destY)));
    

    Now all you need to do is to use this angle for the sprite rotation plus ajust it with a constant like angleShift which depends to where your sprite initially points.

    I am not sure if this will work but hope it may give you some ideas…

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

Sidebar

Related Questions

I'm building a specialized viewer application which loads external SWFs. var content:Sprite = ...
From what I gather, AppEngine fires up Application Instances (for a lack of better
I have application which loads images like this: someImage = Image.FromFile(@picture.png); and another application
I need to know which event fires within an WPF application if I cancel
In my application I have a drop-down form that fires up an AJAX request
My iPhone application downloads large files from the internet (videos, for instance). I'd like
I'm building a utility application that synchronizes files across two systems for Mac OSX.
We use OpenFileDialog across our application to select files. So far, we never used
I have an application that fires 2 threads, the 1st launches another class to
I have a TTimer in my application that fires every 2 seconds and calls

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.