Jump to content
  • Advertisement
Sign in to follow this  
diepnghitinh

motion a canvas with wpf

This topic is 2444 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hello, this my code:



<Window x:Class="FIGHT.Main"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="FIGHT" Height="530" Width="681" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" WindowState="Maximized">
<Canvas Background="CornflowerBlue" Width="700" Height="500" >


<Canvas Name="char_a" Canvas.Left="50" Canvas.Top="50" Width="50" Height="100" Background="Aqua">
</Canvas>

</Canvas>
</Window>


I will make it move in the direction the earth gravity ( the free fall )


DispatcherTimer dispatcherTimer = new DispatcherTimer();
dispatcherTimer.Tick += new EventHandler(
delegate(object s, EventArgs ev)
{
double current_num = (double)Globals.Canvas.Lay("char_a").GetValue(Canvas.TopProperty); //get top value current
Globals.Canvas.Lay("char_a").SetValue(Canvas.TopProperty, (double)current_num+1); //Globals.Canvas.Lay("char_a") will return a object Canvas have name is "char a"
}
);
dispatcherTimer.Interval = TimeSpan.FromMilliseconds(500); //set time
dispatcherTimer.Start();


with my code, it not have the smoothness ... please help me

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!