Note that there are some explanatory texts on larger screens.

plurals
  1. POC# image collision
    text
    copied!<p>Hi guys basically this is a code for zombies walking now what I want to do is when I click the zombies they disappear, how can I do that? Or how can I do if the zombies walking when collided with another image they would disappear? Like when a bullet hits them. </p> <pre><code>public class Gaston { public double X { get; set; } public double Y { get; set; } public Image Image { get; set; } public int Colspan { get; set; } public int Rowspan { get; set; } } /// &lt;summary&gt; /// An empty page that can be used on its own or navigated to within a Frame. /// &lt;/summary&gt; public sealed partial class MainPage : Page { DispatcherTimer dispatcherTimer; List&lt;Gaston&gt; Gastons; int timesTicked = 0; int timesToTick = 10; Image zombieImg; public MainPage() { this.InitializeComponent(); Gastons = new List&lt;Gaston&gt;(); DispatcherTimerSetup(); Zombie(); } protected override void OnNavigatedTo(NavigationEventArgs e) { } private void Zombie() { Gaston newGaston = new Gaston { Colspan = -10, Image = new Image(), Rowspan = -10, X = -10, Y = -10 }; BitmapImage bmp; bmp = new BitmapImage(new Uri (this.BaseUri, "/Assets/zombie.png")); newGaston.Image.Source = bmp; Gastons.Add(newGaston); Grid.Children.Add(newGaston.Image); } private void ZombieWalks() { foreach (Gaston me in Gastons) { me.Image.Margin = new Thickness(me.Image.Margin.Left - 10, me.Image.Margin.Bottom - 10, me.Image.Margin.Right + 10, me.Image.Margin.Top + 10); } } public void DispatcherTimerSetup() { dispatcherTimer = new DispatcherTimer(); dispatcherTimer.Tick += dispatcherTimer_Tick; dispatcherTimer.Interval = new TimeSpan(0, 0, 1); dispatcherTimer.Start(); } void dispatcherTimer_Tick(object sender, object e) { AddZombie(); timesTicked++; ZombieWalks(); if (timesTicked &gt; timesToTick) { } } private void AddZombie() { if (timesTicked == 5) { Zombie(); DispatcherTimerSetup(); } } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload