I am sorry if this question has been answered before, but I searched this forum. I searched the web, and I haven’t found any fix. I know what the solution is supposed to be, but it’s not working. Even the png fiiles used in examples such as [these][1] are showing solid instead of transparent.
Here is my code, which is just the beginning:
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace Game1_WindowsPhone8xaml
{
/// <summary>
/// This is the main type for your game.
/// </summary>
public class Game1 : Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
// my Sprites
Texture2D myButton_START;
// Set the coordinates to draw the sprite at
Vector2 myButtonPos = Vector2.Zero;
public Game1()
{
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
}
/// <summary>
/// Allows the game to perform any initialization it needs to before starting to run.
/// This is where it can query for any required services and load any non-graphic
/// related content.
/// The Initialize method is where you can initialize any assets that do not require a
/// GraphicsDevice to be initialized.
/// Calling base.Initialize will enumerate through any components and initialize
/// them as well.
/// </summary>
protected override void Initialize()
{
// TODO: Add your initialization logic here
base.Initialize();
}
/// <summary>
/// LoadContent will be called once per game and is the place to load
/// all of your content.
/// The LoadContent method is where you load any necessary game assets
/// such as models and textures.
/// </summary>
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
// use this.Content to load your game content here
myButton_START = Content.Load<Texture2D>("earth");
}
/// <summary>
/// UnloadContent will be called once per game and is the place to unload
/// game-specific content.
/// The UnloadContent method is where any game assets can be released.
/// Generally, no extra code is required here, as assets will be released
/// automatically when they are no longer needed.
/// </summary>
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}
/// <summary>
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
/// The Update loop is the best place to update your game logic.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Update(GameTime gameTime)
{
// TODO: Add your update logic here
base.Update(gameTime);
}
/// <summary>
/// This is called when the game should draw itself.
/// The Draw loop is the best place to render all of your objects and backgrounds on
/// the screen.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.Black); // start with a black background
// Add your drawing code here
// Draw the button sprite.
/// </summary>
/// Begins a sprite batch operation using the specified sort and blend state object
/// and default state objects (DepthStencilState.None, SamplerState.LinearClamp,
/// RasterizerState.CullCounterClockwise). If you pass a null blend state,
/// the default is BlendState.AlphaBlend.
/// This method must be called before any calls to Draw. When all the sprites have
/// been drawn, call End.
/// </summary>
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);
spriteBatch.Draw(myButton_START, myButtonPos, Color.White);
spriteBatch.End();
base.Draw(gameTime);
}
}
}
Here is what I get
…from this
Hope someone can help. I am only just beginning, and I am stuck.
[1]: http://rbwhitaker.wikidot.com/spritebatch-basics-resources