Hello I am running IronPython 2.7A and trying to debug a Silverlight app. I am trying to figure out why my ship doesn't move when I press the Arrow keys.
here is the complete source minus most imports :D Any ideas from System.Windows.Input import * velocity = 10 class Gui(): def __init__(self): self.grid = Grid() self.canvas = Canvas(Background = SolidColorBrush(Colors.White)) self.canvas.Width = 640 self.canvas.Height = 432 self.bgImage = Image( Source = BitmapImage(Uri("images/background.jpg", UriKind.Relative)) ) self.canvas.SetTop(self.bgImage, 132) self.canvas.SetLeft(self.bgImage, 0) # self.textblock = TextBlock() ## self.textblock.FontSize = 24 ## self.textblock.Text = 'This Really Works!!' ## self.canvas.Children.Add(self.textblock) self.ship = Image( Source = BitmapImage(Uri("images/ship.png", UriKind.Relative)) ) self.canvas.SetTop(self.ship, 75) self.canvas.SetLeft(self.ship, 25) CompositionTarget.Rendering += EventHandler(self.ShootBG) ## self.GenerateStarField(350) self.canvas.Children.Add(self.bgImage) self.canvas.Children.Add(self.ship) self.grid.Children.Add(self.canvas) Application.Current.RootVisual = self.grid # This line should be something different Not sure what to use instead of this self.ship.KeyDown += KeyEventHandler(self.KeyDown_Control) def ShootBG(self, s, e): self.canvas.SetLeft(self.bgImage, self.canvas.GetLeft(self.bgImage) - 1) if self.canvas.GetLeft(self.bgImage) < -2110: self.canvas.SetLeft(self.bgImage, 0) def KeyDown_Control(self, s, e): if e.Key == Key.Right: self.canvas.SetLeft(self.ship, self.canvas.GetLeft(self.ship) + velocity) elif e.Key == Key.Left: self.canvas.SetLeft(self.ship, self.canvas.GetLeft(self.ship) - velocity) elif e.Key == Key.Up: self.canvas.SetTop(self.ship, self.canvas.GetTop(self.ship) - velocity) elif e.Key == Key.Down: self.canvas.SetTop(self.ship, self.canvas.GetTop(self.ship) + velocity) gui = Gui() gui
_______________________________________________ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com