Post: Label Movements :)
05-21-2015, 08:49 PM #1
Antonio96C
Do a barrel roll!
(adsbygoogle = window.adsbygoogle || []).push({}); Hi NGU
Label Movements

In Timer . Interval = 50;
bool movement;

You must login or register to view this content.
    if (labelXX.Left < this.ClientSize.Width - labelXX.Width + 10 && movement)
{
labelXX.Left++;
if (labelXX.Left == this.ClientSize.Width - labelXX.Width - 10)
{
movement= false;
}
}
if (labelXX.Left > -10 && !movement)
{
labelXX.Left--;
if (labelXX.Left == -10)
{
movement= true;
}
}


Thanks Antonio96 :p
Last edited by Antonio96C ; 05-21-2015 at 08:53 PM.

The following user thanked Antonio96C for this useful post:

jagex
05-22-2015, 02:27 AM #2
jagex
Gym leader
Nice job!

Here is another way with only 2 lines of code using ThicknessAnimation.

    private void moveLabel(Label label, double duration, double fromLeft, double fromTop, double fromRight, double fromBottom, double toLeft, double toTop, double toRight, double toBottom)
{
var moveLeft = new ThicknessAnimation(new Thickness(fromLeft, fromTop, fromRight, fromBottom), new Thickness(toLeft, toTop, toRight, toBottom), TimeSpan.FromSeconds(duration));
label.BeginAnimation(BorderThicknessProperty, moveLeft);
}

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo