I'm using the following code inside a Timer:
void dt_Tick(object sender, EventArgs e)
{
double x, y;
int cont = 0;
x = tt.X;
y = tt.Y;
while(cont < 5)
{
tt.X += cont;
tt.Y += cont;
cont++;
}
while(cont > 0)
{
tt.X -= cont;
tt.Y -= cont;
cont--;
}
tt.X = x;
tt.Y = y;
}
It would be for a button, change the position of your X and Y to give an effect as if it were shaking, how do I do it? With this code it stops, taking out the last two lines, it just goes up on the screen.
I tried this way to make a rough effect:
double x, y;
int cont = 0;
x = tt.X; //armazana varaivel X para manipulação
y = tt.Y; //backup da variavel Y
while (cont < 20)
{
if(dt.Interval.TotalSeconds % 2 == 0)
{
tt.X = (20 - cont);
}
else
{
tt.X = (20 - cont);
}
cont++;
}