Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am developing an Android game. In this game some trains are moving on tracks. I am able to move trains horizontally and vertically using two train images for horizontal train and vertical train separately.

Now I want to move a train that is coming on horizontal track to vertical, I want to visualize it as it is now taking turn and moving on vertical track.

How can I do this, do I need to use so many images for each turning pixel, or is there any other way to turn the train?

Please suggest.

share|improve this question
add comment

1 Answer 1

You can rotate the whole Canvas Object. Just look at the Canvas documentation in Android SDK Documentation Canvas.

You might want to to something like:

canvas.save();
canvas.rotate(90);
canvas.drawBitmap(...);
canvas.restore();

First, you save the current Canvas (or Matrix), then you rotate the whole thing, draw the image, and then you restore the Canvas orientation. Your drawing operations will be saved. One more thing: There is a method

canvas.rotate(degree, px, py)

this will rotate the canvas around the point (px,py). Could be better suited for your needs.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.