Skip to main content
gamedev.net
🔒 Locked

null exception error

Started by turlisk 0 replies 650+ views
Original Post
turlisk
turlisk
I'm getting two null values with my code, both of them happen inside PlayerInput.cs

Basically i have a ball bouncing around a screen and when you click on it, it's suppose to move the ball to a new location and start moving again and increase the score by 1.

if you hit escape it's suppose to exit the game.

both of these are built into it's own file called PlayerInput

Now the values are not null but once i click on the game (anywhere) it becomes null and crashes.

and if i hit escape it becomes null and crashes.

I have not attached the source because it's long.

however have links you can goto.

http://mmo-dev.net/Game1.cs
http://mmo-dev.net/Sprite.cs
http://mmo-dev.net/PlayerInput.cs

will show you the code for the game.

any help would be great.
turlisk
turlisk
Quote:
Original post by turlisk
I'm getting two null values with my code, both of them happen inside PlayerInput.cs

Basically i have a ball bouncing around a screen and when you click on it, it's suppose to move the ball to a new location and start moving again and increase the score by 1.

if you hit escape it's suppose to exit the game.

both of these are built into it's own file called PlayerInput

Now the values are not null but once i click on the game (anywhere) it becomes null and crashes.

and if i hit escape it becomes null and crashes.

I have not attached the source because it's long.

however have links you can goto.

http://mmo-dev.net/Game1.cs
http://mmo-dev.net/Sprite.cs
http://mmo-dev.net/PlayerInput.cs

will show you the code for the game.

any help would be great.


guess it helps to post the errors:

when i hit escape:

System.NullReferenceException was unhandled
Message="Object reference not set to an instance of an object."
Source="Catch the Ball"
StackTrace:
at Catch_the_Ball.PlayerInput.exitGame() in F:\game stuff\game 140\Catch the Ball\Catch the Ball\PlayerInput.cs:line 69
at Catch_the_Ball.Game1.Update(GameTime gameTime) in F:\game stuff\game 140\Catch the Ball\Catch the Ball\Game1.cs:line 413
at Microsoft.Xna.Framework.Game.Tick()
at Microsoft.Xna.Framework.Game.HostIdle(Object sender, EventArgs e)
at Microsoft.Xna.Framework.GameHost.OnIdle()
at Microsoft.Xna.Framework.WindowsGameHost.ApplicationIdle(Object sender, EventArgs e)
at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FDoIdle(Int32 grfidlef)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Microsoft.Xna.Framework.WindowsGameHost.Run()
at Microsoft.Xna.Framework.Game.Run()
at Catch_the_Ball.Program.Main(String[] args) in F:\game stuff\game 140\Catch the Ball\Catch the Ball\Program.cs:line 14
InnerException:


when i click anywhere:

System.NullReferenceException was unhandled
Message="Object reference not set to an instance of an object."
Source="Catch the Ball"
StackTrace:
at Catch_the_Ball.PlayerInput.HandleInput() in F:\game stuff\game 140\Catch the Ball\Catch the Ball\PlayerInput.cs:line 32
at Catch_the_Ball.Game1.Update(GameTime gameTime) in F:\game stuff\game 140\Catch the Ball\Catch the Ball\Game1.cs:line 412
at Microsoft.Xna.Framework.Game.Tick()
at Microsoft.Xna.Framework.Game.HostIdle(Object sender, EventArgs e)
at Microsoft.Xna.Framework.GameHost.OnIdle()
at Microsoft.Xna.Framework.WindowsGameHost.ApplicationIdle(Object sender, EventArgs e)
at System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FDoIdle(Int32 grfidlef)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Microsoft.Xna.Framework.WindowsGameHost.Run()
at Microsoft.Xna.Framework.Game.Run()
at Catch_the_Ball.Program.Main(String[] args) in F:\game stuff\game 140\Catch the Ball\Catch the Ball\Program.cs:line 14
InnerException:

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.