链接椭圆图像与类

时间:2014-10-08 13:30:17

标签: c# wpf xaml

我正在制作一个游泳池游戏作为我的项目。我有麻烦声明椭圆图像与类链接,以便我可以在以后使用它与物理引擎。我留下了这个代码来完成,我已经研究了5个小时才发现这个问题。


在XAML

<Ellipse Canvas.Left="314" Canvas.Top="305" Height="35" Name="Ball1" Stroke="Black" Width="35" StrokeThickness="0.01">
            <Ellipse.Fill>
                <ImageBrush ImageSource="/FYPJ;component/Images/Balls/1.png" />
            </Ellipse.Fill>
        </Ellipse>

  public Point Position { get; set; }
  public int BallNum
    {
        get
        {
            return ballNum;
        }
        set
        {
            if (value <= 7)
                IsSolid = true;
            else
                IsSolid = false;
            ballNum = value;
        }
    }
public Ball(int ballNumber, Point position)
    {
        this.BallNum = ballNumber;
        this.Position = position;
        // TODO: rember to add physics behavior later
    }

在XAML.cs

private void Page_Loaded(object sender, RoutedEventArgs e)
    {
        // init ball position
        foreach (Ball ball in balls)
        {
            Ellipse ballImage = this.GetBallImage(ball);
            Console.WriteLine("ball " + ball.BallNum); // For Testing according to my teacher
            ball.Position.X = ; // Unfinished Code
            ball.Position.Y = ; // Unfinished Code


        }

}

如果您认为我仍然错过了这个问题的代码。随意评论出来。谢谢。

0 个答案:

没有答案