Jump to content
Site Stability Read more... ×
  • Advertisement
Sign in to follow this  

motion a canvas with wpf

This topic is 2958 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"
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">


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

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

Share this post

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

  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!