Visual studio will open the C# script file that’s linked to this app and then add the Canvas_KeyDown event. Right click and then click on Go to Definition. By clicking on this option Visual Studio will add the event got us. Right click on the Canvas_KeyDown and you will see the option Go to Definition. Lastly we end the canvas as we will not need to add anything else to it. We also have a TAG property in them, this is important because we will use this to detect the collision between these and the rec1. Each of them has their own names, height, width and location. I you look inside these tags you will notice they all have similar properties inside the rectangle tag. We can set it to where we want it so in this case, we want this rectangle to be 307 pixels from the left and 51 pixels from the top.Ībove the are 3 platforms for this app. We give its width and height of 50, when we declare a number inside of this it calculates in pixels so this rectangle will be 50 pixels wide and 50 pixels high. We need to give it a name and, in this case, its rec1. This is the first rectangle inside the tag we are giving this rectangle some properties. We will use them to see which platform the player character lands on.
#TEST OPEN CANVAS 6 CODE#
These two lines of code above will add two labels to the screen. This is the open canvas code, inside this tag we have several options included such as key down and key up events, whether this canvas is focusable when its loaded, margin, horizontal alignment and width.
Title=”MainWindow” Height=”600″ Width=”525″ FocusManager.FocusedElement=”“>įirst inside the title put the code above, this code will focus right on the Canvas when the app is loaded, this part of code will allow the program to respond key down and key up event.