c# - Is it possible to add hit detection to elements in a canvas? - Windows Phone 8.1 -
i'm in process of creating app windows phone 8.1, , involves canvas element. i'm spawning shapes onto canvas element , 'player' shape controllable via accelerometer.
what want know is, can add hit test each rectangle when 'player' shape goes on rectangle trigger event? i'm adding rectangles using following code:
public void addenemy() { double canvaswidth = ballbox.actualwidth; double canvasheight = ballbox.actualheight; if(i >= 20){ } else { random rand = new random(); x = rand.next(0, (int)canvaswidth - 50); y = rand.next(0, (int)canvasheight - 50); rectangle rec = new rectangle(); rec.width = 20; rec.height = 20; rec.stroke = new solidcolorbrush(windows.ui.colors.red); rec.strokethickness = 5; rec.tag = "rec" + i.tostring(); displaycanvas.children.add(rec); canvas.setleft(rec, x); canvas.settop(rec, y); i++; } this addenemy function called every second using timer.
thanks.
Comments
Post a Comment