我正在Silverlight中开发简单的捕获应用程序(在Blend 4中)。你知道如何简单地解决掉落物体从顶部到底部的物体碰撞到白色矩形吗?图片 - http://img94.imageshack.us/img94/8200/svlk.jpg
由于
当前代码:
public partial class MainPage : UserControl
{
int skore=0;
public MainPage()
{
InitializeComponent();
chytac.Visibility=Visibility.Collapsed;
}
private void UserControl_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
String k=e.Key.ToString();
klavesa.Content=k;
if(e.Key.ToString().Equals("Left")){
double x=Canvas.GetLeft(chytac);
x=x-20;
if(x>0){
Canvas.SetLeft(chytac,x);
}
}
if(e.Key.ToString().Equals("Right")){
double x=Canvas.GetLeft(chytac);
x=x+20;
if(x<650){
Canvas.SetLeft(chytac,x);
}
}
}
private void start_Click(object sender, System.Windows.RoutedEventArgs e)
{
chytac.Visibility=Visibility.Visible;
start.Visibility=Visibility.Collapsed;
}
private void random_Click(object sender, System.Windows.RoutedEventArgs e)
{
Random random = new Random();
//pocitadlo++;
//score.Content=pocitadlo.ToString();
telefon novy = new telefon();
LayoutRoot.Children.Add(novy);
Canvas.SetTop(novy, 0);
Canvas.SetLeft(novy, random.Next(0,650));
Canvas.SetZIndex(novy, -50);
bomba bomba=new bomba();
LayoutRoot.Children.Add(bomba);
Canvas.SetTop(bomba, 0);
Canvas.SetLeft(bomba, random.Next(0,650));
Canvas.SetZIndex(bomba, -50);
}
}