1
I’m having a hard time delimiting the character’s movement to the edge of the screen.
In class Game1
which is my main I can use Window.ClientBounds
, but when I use this function within the class Player1
makes the mistake:
'The name 'Window' does not exist in the Current context'`.
Code snippet of class Player1
:
public void Update(GameTime gameTime)
{
position += velocity;
if (Keyboard.GetState().IsKeyDown(Keys.Up))
{
velocity.Y = -3f;
if (position.Y + texture.Height > (Game as Game1).Window.ClientBounds.Height)
velocity.Y += 3f;
}
...
}
When I use (Game as Game1)
can use Window.ClientBounds
, but he makes a mistake that says:
'Microsoft.Xna.Framework.Game' is a 'type' but is used like a 'variable'
And present code? Or something that you can analyze...
– CesarMiguel
Ajuda ae Cesarmiguel!
– Anézio
I’m not really in those classes, but it seems to me that the mistake
'The name 'Window' does not exist in the current context'
means that the Window you are using is not part of your context. Check if you have– CesarMiguel