Ok, I’m going to post the entirety of my code here, even though I don’t believe that’s the problem. I’ve got only two classes, Game1.cs and Sprite.cs. They are posted in that order below. All I’m trying to do is load a sprite. I don’t know why it’s not working, but I think the problems lies with the pipeline tool. I tried another PNG and it worked fine. I’ve also tried reinstalling, but it seems to make no difference.
This is what it’s supposed to look like. This is also what it looks like if I click view INSIDE the monogame pipeline.
This is what it always ends up looking like.
I briefly got it to look like this after deleting the PNG, remaking it… AND THEN reloading it into the pipeline tool.Doing that again has only ever resulted in the second image.
GAME1.CS
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
namespace AvoidTheStroids
{public class Game1 : Game { GraphicsDeviceManager graphics; SpriteBatch spriteBatch;
private Texture2D texture; private Vector2 position;
private Sprite sprite;
public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; }
protected override void Initialize() {
base.Initialize(); }
protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); texture = Content.Load<Texture2D>("avoider");
sprite = new Sprite(texture) { Position = new Vector2(0, 100), }; }
protected override void UnloadContent() { }
protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) Exit();
base.Update(gameTime); }
protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.Black);
spriteBatch.Begin(); sprite.Draw(spriteBatch); spriteBatch.End();
base.Draw(gameTime); } }
}
SPRITE.CS
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AvoidTheStroids
{
class Sprite
{
private Texture2D _texture;
public Vector2 Position;
public Sprite(Texture2D texture) { _texture = texture; }
public void Draw(SpriteBatch spriteBatch) { spriteBatch.Draw( _texture, Position, Color.White); } }
}