# Perfect Sine Movement Animation

255pages on
this wiki

This tutorial describes how to calculate a perfect sine movement as demonstrated in this Flipnote.

## Overview

This tutorial will show you how to animate an object in a sine wave-like fashion. The oscillation of a sine wave can be illustrated by having an object move up and down in a continuous fashion, in addition to a continuous moving background to simulate the movement of the object along a wavelength. In addition, the tutorial emphasizes the conformation to continuity, in order to animate in a truly smooth fashion as characteristic of a sine wave. This is accomplished by making very small incremental movements in your animation, and this tutorial will utilize some mathematical formulas to help you create a smooth animation.

## Create the Position Table

First we create a table with all the absolute pixel positions for the object. You need this input parameters for the following formulas. Best is you take a sheet of paper and write everything down.

Parameter Description
P The number of pages for a full cycle. It works best if you use values which are a power of 2 (8, 16, 32, 64, ...). This will create a Flipnote with a good final size for some background music loop. See Flipnote Speed for more details.
H The size of the moving object. This can be the height or width, depending of the movement direction.
S The size of the screen for your animation direction. This is 192 pixels for the high (vertical) or 256 for the width (horizontal).
G The gap in pixels at the border of the screen. If you like that the object touches exactly the border of the screen, use here a value of 0. But I recommend a value of 2, because touching the screen will have some negative visual impact, and maybe you wanna create some border around your object later.

Now you have to prepare some values first:

$\text{C} = \frac{\left( \text{S} - \text{H} \right)}{2}$

$\text{M} = \text{C} - \left( \text{G} \cdot 2 \right)$

The parameter C is the center of your animation. If the top or left side of your object is at this position, it should be in the middle of the screen.

The parameter M is the size of the movement on the screen, without the gaps.

Take a paper and draw a table with the number of pages you like to create for the animation (your parameter P). Make three columns and number the first column, starting from 0. This table should look like this:

Index Result Movement
0
1
2
3
...

We call this number in the first column index (I).

Now you have to calculate the result (X) for each row in the table. Use a calculator for this. Make sure it has the sinus function (called "sin"). Check if the sinus function uses degrees as input. You can do this by calculating the sinus for the value 90. You should get 1, then everything is fine.

$\text{X} = \text{C} + \sin\left( -180 + \frac{ 360 \cdot \text{I} }{ \text{P} } \right) \cdot \text{M} + 0.5$

Important: Ignore all digits after the decimal point, just write down the number before the decimal point.

## Fill the Movement Column

Now write the resulting movement into the third column. You calculate it just by subtracting the previous value from the current one. Example:

Index Result Movement
0 6
1 3 -3
2 6 3
3 12 6
...

You see this is quite simple. Use a calculator if you are unsure about the minus prefix in the calculations.

## Animate the Object

After you have everything prepared for your animation, the really work intense part is following.

1. Create an empty page at the end of your Flipnote with just the object on it which you like to animate. Make sure at the top or left side is some good mark which which you easily can see the correct position on the screen.
2. Move the object at the top or left border (depending on the animation direction) that it exactly touches the border without any gap. Move always the whole screen to position your object. This is much faster than select and copy it with the selection tools.
3. Move the object to the absolute position you calculated for index 0. You press and hold [L] and use the D-Pad to move your object pixel by pixel to the destination position. Just count every pixel movement until you reach the calculated value.
4. Enable the copy page mode.
5. Create the next page, and move your object by the calculated movement value. A negative number means left or up, a positive number means right or down (depending on your animation direction). Repeat this for all index positions.
6. Done! That's it; you created a perfect sinus movement animation.