Android 3D Game Development tutorial-Part III

Source: Internet
Author: User

Developed by these Android 3D gamesArticleThe original article was written by Martin, a German at droidnova.com. lixinso was translated into Chinese.

In the third part of this series, I will show you how to stop the rotation of the triangle and tell you that the original rotation is actually only the rotation of the triangle, instead of rotating on the camera "camera.

We hope to have more control over the rotation. Therefore, this matrix is reset every time the ondrawframe () method is called. This will reset the angle of the triangle so that it can always rotate to the given angle.

In the vortexview class, you should delete "divided by 10" so that it can be rotated in a larger range.

If you try this, you will see that the rotation will only rotate according to the position of the touch. If you do not touch the screen, the rotation will not change.

Next thing: Do we rotate the triangle itself or the view/camera of rotation?

To verify it, the easiest way is to create a second non-rotating triangle for comparison.

The fastest and most stupid method is the copy & Paste inittriangle () method as a new method initstatictriangle (), copy & paste, copy & paste, and modify ondrawframe () the last four rows in the method.

Don't forget to change the color of the second triangle and change the coordinates of the second triangle, so that we can see two triangles. I changed 0.5f in every place to 0.4f.

Here is the entire class:

If you do the above, you will see that only one triangle can be rotated. If you want to rotate both of them, you only need to add a line next to the comment "Draw the static triangle ".CodeYou can.

Compile and run thisProgram, You can see that the green triangle is rotating, while the red triangle is still in the original place.

This fully verifies our answer. We rotate only triangles rather than the entire scenario.

Eclipse projectSource codeDownload: vortex Part III

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.