Posts Tagged ‘Rotation’

Android: how to rotate a View element

Click here to read Android: how to rotate a View element

Another Android programming tutorial, this time, explaining how to rotate a View element using two distinct approaches. Not only that, but this post also presents a brief explanation on the advantages and disadvantages of each approach. The code featured here has been tested on both the emulator and on a real device running Android 2.1 . Before going any further, please bear in mind that from Android 3.0 (API level 11), a setRotation() method has been added to the View class, therefore, it should be used instead of the code described in this article, which focuses on lower level APIs.

The first and perhaps most direct method of rotating a View element is to create a class that inherits from a View widget that needs to be rotated, for example, the TextView or the Button. Then, inside this class, the onDraw() method must be overridden. (more…)

Unity: Rotation Controller

Click here to read Unity: Rotation Controller

Another day, another Unity3D programming post. This tutorial contains not just one, but two scripts that rotates a game object around another one, based on the keyboard input. Again, like the previous tutorial, this was also inspired by retro games, such as S.T.U.N. Runner or the special stages from Sonic 2, where the player controls the main character by pressing left or right, making it complete a full circle in the screen. However, unlike those games, the below scripts aren’t applying gravity to the player, for the sake of simplicity. Everything explained here is available for download at the end of the tutorial.

(more…)