all have the same error, "is never assigned to and will always have its default value". But I do think I am assigning them each in my classes.
//This is My Computer Class Constructor Which Inherits from the BasePaddle Class
public ComputerPaddle(Texture2D texture, Rectangle screenBounds, Vector2 direction, Vector2 position, SpriteManager spriteManager)
: base(texture, screenBounds, direction, position)
{
this.texture = texture;
this.screenBounds = screenBounds;
this.direction = direction;
this.position = position;
this.spriteManager = spriteManager;
}
//This is my Player Paddle Class Constructor Which Inherits from the BasePaddle Class
public PlayerPaddle(Texture2D texture, Rectangle screenBounds, Vector2 direction, Vector2 position)
: base(texture, screenBounds, direction, position)
{
this.texture = texture;
this.screenBounds = screenBounds;
this.direction = direction;
this.position = position;
}
So what I am i doing wrong? I don't know why my SpriteManager has null fields when I (I think) i am assigning them, I am sorry that I am asking so many questions, I don't have anyone other than you to ask.
So my question is why are my SpriteManager fields null? I don't understand what I am doing wrong/ I don't know what I didn't do.
First question. Why are the private variables for the cpupaddle and the playerpaddle different? Secondly, we'll have to see how you are calling the two constructors to know why they are showing up null.
Are the JongPaddle images actually being found? IE. playerPaddleTexture != null? Also, where are you assigning or initializing screenRectangle, direction, and position?
The JongPaddles are being found, but nothing else is. So I don't know what the issue there is. Also to answer your other question I think I am doing the assigning or intializing in the basePaddle Class.
namespace JONG_PongClone_
{
public abstract class BasePaddle
{
//Texture For the Block
protected Texture2D texture;
//position of the Block
protected Vector2 position;
//Directoin of the Block
protected Vector2 direction;
//Collision Rectangle for the block
protected Rectangle screenBounds;
That is my problem right there. I just realized I never assigned any value to my variables. That is problem I think. Thanks for kind of walking me through this.
All I see there are variable declarations. No initializations or assignments.
Show the code where you are actually setting the values for screenRectangle, position, and direction.
Okay I can't declare these values right. My screenRectangle is supposed to be my Window diminsions, my positions is supposed to keep track of the paddle location.