XNA basic tut
Tutorials on how to use and create games in XNA.
1 post
Page 1 of 1
well this will be my first tut
before I start i have only worked with XNA for 3 days and c# for 3 days too but i will be sharing what i know so far
to start with you will need to put the images you want to have in your game into the content pipeline to do that right click content and add existing item and find your image.
next what you will be wanting to do is in the part where it says "public class Game1 : Microsoft.Xna.Framework.Game
{"
add in
{
what we now need to do is draw it in so under protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.Black);
.end shows where it will end
and in the middle is the .draw command this tells it to draw your image in a good thing to note is that color.white makes your object you made keep the colours it has any other colour will put a tint on it.
and there you go a basic image in xna i hope this helps you =]
Ps a like always helps so if i helped u please like =]
before I start i have only worked with XNA for 3 days and c# for 3 days too but i will be sharing what i know so far
to start with you will need to put the images you want to have in your game into the content pipeline to do that right click content and add existing item and find your image.
next what you will be wanting to do is in the part where it says "public class Game1 : Microsoft.Xna.Framework.Game
{"
add in
Code: Select all
Texture2D declares a 2D image but it currently is not anything so you will need to load it in the protected override void LoadContent()Texture2D yourimagenamecanbewhatever;
Rectangle canalsobewhatevertoo;
{
Code: Select all
this code pairs up the image to the refrence and the rectangle to the rectangle refyouimagename = content.load<Texture2D>("thefilenameitself e.g"image" you dont need / or anything like that");
your Rectangle = new Rectangle(x,y,x size of it,y size of it);
what we now need to do is draw it in so under protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.Black);
Code: Select all
.begin shows where it is going to start drawing so the things at the top go to the bottom of it like the back grounds will be at the top and the player will be at the bottom spriteBatch.Begin();
spriteBatch.Draw(yourimage,yourRectangle,Color.White);
spriteBatch.End();
.end shows where it will end
and in the middle is the .draw command this tells it to draw your image in a good thing to note is that color.white makes your object you made keep the colours it has any other colour will put a tint on it.
and there you go a basic image in xna i hope this helps you =]
Ps a like always helps so if i helped u please like =]
1 post
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023