Sprites with Rotation

SwinGame does not support rotating or scaling images. This article shows how you can use rotated images with a sprite, the same process can be used with scaled images as well. The code shown here requires version 1.1.2 or later to work correctly.

Basic Outline
SwinGame does not provide the ability to rotate images at runtime, however similar results can be achieved by using pre-rendered images. You produce your artwork rotated as you require. The example shown here illustrates an aircraft with 12 different images, each rotated 30 degrees counter clockwise.

This image can be used within the Sprite, see CreateSprite, where you select the frame that matches the direction that the sprite is moving.

Sample Code
The following code illustrates how to implement this using the SwinGame API. To use this you need to do the following:


 * 1) Download one of the SDKs (ensure version 1.1.2+)
 * 2) Extract to your machine
 * 3) Download the [[Media:RotationHowToResources.zip|Rotation Resources]]
 * 4) Extract the files from the Rotation Resources into the Resources of the SDK from step 2.
 * 5) Download the source files below that matches the language of the SDK you downloaded. Use these to override the ones supplied with the SDK.

Download

 * Resources: [[Media:RotationHowToResources.zip|Rotation Resources]]
 * Source Code:
 * [[Media:RotationHowToPascal.zip|Pascal Source]]
 * [[Media:RotationHowToCSharp.zip|C# Source]]
 * [[Media:RotationHowToVBnet.zip|Visual Basic .NET Source]]