I currently have following code under my "Game1.cs"
protected override void Update(GameTime gameTime)
{
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
this.Exit();
Bounce();
base.Update(gameTime);
}
and my "Bounce" method under "GameMechanics.cs"
namespace Cannon4
{
class GameMechanics
{
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;
GameItem target;
public void Bounce()
{
//Bouncer target vekk fra nordre og søndre vegg
if (target.Position.Y <= 0)
{
Vector2 vecVar;
Vector2 posVar;
vecVar = target.Velocity;
vecVar.Y *= -1;
target.Velocity = vecVar;
posVar = target.Position;
posVar.Y = 0;
target.Position = posVar;
}
else if (target.Position.Y >= SCREEN_HEIGHT)
{
Vector2 vecVar2;
Vector2 posVar2;
vecVar2 = target.Velocity;
vecVar2.Y *= -1;
target.Velocity = vecVar2;
posVar2 = target.Position;
posVar2.Y = SCREEN_HEIGHT - target.Origin.Y;
target.Position = posVar2;
}
}
}
}
Why do I get the error "The "Bounce" does not exist in current context"?