I'm attempting my first 2D vertical scroller and can't seem to get the background size to work. For some reason, it stays small. I think in the beginning of the parallax scrolling class, I was told to initialize variables and I know which ones I have to change.
public Texture2D picture;
public Vector2 position = Vector2.Zero;
public Vector2 offset = Vector2.Zero;
public float depth = 0.0f;
public float moveRate = 0.0f;
public Vector2 pictureSize = Vector2.Zero;
public Color color = Color.White;
I think I must change pictureSize
to make it bigger, as the current sizing I get this:
Finally, how can I remove the whitespace from the ship image?
EDIT: Here is the code for the rendering of the actual ship:
public void Render(SpriteBatch batch)
{
batch.Begin();
batch.Draw(shipSprite, position, null, Color.White, 0.0f, spriteOrigin, 1.0f,
SpriteEffects.None, 0.0f);
batch.End();
}
The whitespace seems to be provided by XNA as I've tried clearing it using Photoshop. Because I can't directly upload to the site, I have put it here
This renders the background:
public void Draw()
{
layerList.Sort(CompareDepth);
batch.Begin();
for (int i = 0; i < layerList.Count; i++)
{
if (!moveLeftRight)
{
if (layerList[i].position.Y < windowSize.Y)
{
batch.Draw(layerList[i].picture, new Vector2(0.0f,
layerList[i].position.Y), layerList[i].color);
}
if (layerList[i].position.Y > 0.0f)
batch.Draw(layerList[i].picture, new Vector2(0.0f,
layerList[i].position.Y - layerList[i].pictureSize.Y),
layerList[i].color);
else
batch.Draw(layerList[i].picture, new Vector2(0.0f,
layerList[i].position.Y + layerList[i].pictureSize.Y),
layerList[i].color);
}
else
{
if (layerList[i].position.X < windowSize.X)
{
batch.Draw(layerList[i].picture, new Vector2(layerList[i].position.X,
0.0f), layerList[i].color);
}
if (layerList[i].position.X > 0.0f)
batch.Draw(layerList[i].picture, new Vector2(layerList[i].position.X -
layerList[i].pictureSize.X, 0.0f), layerList[i].color);
else
batch.Draw(layerList[i].picture, new Vector2(layerList[i].position.X +
layerList[i].pictureSize.X, 0.0f), layerList[i].color);
}
}
batch.End();
}
(It's from a XNA tutorial book I'm reading.)