I am developing an Android Game. In this game some trains are moving on tracks. am able to move trains horizontally and vertically using two train images for horizontal train and vertical train separately.
Now i want to move 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 train.
Please suggest
Thanks.
Edit:
am using draw to draw() image and update() to change its position.
public void draw(Canvas canvas) {
canvas.drawBitmap(bitmap, x - (bitmap.getWidth() / 2), y - (bitmap.getHeight() /2), null);
}
public void update() {
if (!touched && !paused && !isDrag) {
x += (speed.getXv() * speed.getxDirection());
y += (speed.getYv() * speed.getyDirection());
}
if (!touched && !paused && isDrag) {
x += (speed.getXv() * speed.getxDirection())* 2;
y += (speed.getYv() * speed.getyDirection())* 2;
}
}
Your question probably belong to
http://gamedev.stackexchange.com
But, assuming you are using some sort of Canvas, it has a method that applies rotation around a specific point.
http://developer.android.com/reference/android/graphics/Canvas.html#rotate%28float%29