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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:33:37+00:00 2026-05-26T05:33:37+00:00

I am working on a sample game demo in which i just put an

  • 0

I am working on a sample game demo in which i just put an image in canvas and on android device sensor changes the canvas translate and move for appropriate position. I want to translate canvas just on y-axis (up-down), and rotate it on x-axis. but when i rotate the canvas first time my y-axis coordinates changes and the transformation done on x-axis.

I know the problem with angle of the canvas rotation and calculation of new x,y coordinates but i don’t know how to do it.

this is the sample code:

in my activity class

@Override
public void onSensorChanged(int sensor, float[] values) {
    // TODO Auto-generated method stub

              rotateX = values[0]; 
    translateY = values[1];
    Game.setDirection(rotateX,translateY);
}

now in Game view class in onDraw() method

canvas.rotate(rotateX, imageCenterX, imageCenterY);
canvas.translate(0,translateY);

Thanx in advance.

  • 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-26T05:33:37+00:00Added an answer on May 26, 2026 at 5:33 am

    I solved my problem.

    I just swap the method of canvas.

    Like

    canvas.translate(0,translateY); 
    canvas.rotate(rotateX, imageCenterX, imageCenterY); 
    

    Then it works fine.

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

Sidebar

Related Questions

I m working on a word scramble game which allows user to move the
I'm working on a simple multiplayer game in which 2-4 players are placed at
I am working with the sample Home application project on http://developer.android.com/resources/samples/Home/index.html I've added another
I am currently working on a sample application which uses QNetworkAccessManager to send the
I am working on a simple platform game in HTML5/Canvas/Javascript/jQuery. You can see it
I'm working on a simple demo for collision detection, which contains only a bunch
I'm working on a simple 2D game (birds eye view). I have projectiles, which
I'm working on a simple JavaScript game using HTML5 canvas. It's a very typical
I'm working on a simple 2D game engine in Java, and having no trouble
I'm working on a very simple game (essentially an ice sliding puzzle), for now

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.