Hello. I'm learning F#, and decided to try making simple XNA games for windows using F# (pure enthusiasm) , and got a window with some images showing up.
Here's the code:
(*Methods*)
member self.DrawSprites() =
_spriteBatch.Begin()
for i = 0 to _list.Length-1 do
let spentity = _list.List.ElementAt(i)
_spriteBatch.Draw(spentity.ImageTexture,new Rectangle(100,100,(int)spentity.Width,(int)spentity.Height),Color.White)
_spriteBatch.End()
(*Overriding*)
override self.Initialize() =
ChangeGraphicsProfile()
_graphicsDevice <- _graphics.GraphicsDevice
_list.AddSprite(0,"NagatoYuki",992.0,990.0)
base.Initialize()
override self.LoadContent() =
_spriteBatch <- new SpriteBatch(_graphicsDevice)
base.LoadContent()
override self.Draw(gameTime : GameTime) =
base.Draw(gameTime)
_graphics.GraphicsDevice.Clear(Color.CornflowerBlue)
self.DrawSprites()
And the AddSprite Method:
member self.AddSprite(ID : int,imageTexture : string , width : float, height : float) =
let texture = content.Load<Texture2D>(imageTexture)
list <- list @ [new SpriteEntity(ID,list.Length, texture,Vector2.Zero,width,height)]
The _list object has a ContentManager, here's the constructor:
type SpriteList(_content : ContentManager byref) =
let mutable content = _content
let mutable list = []
But I can't minimize the window, since when it regains its focus, i get this error:
ObjectDisposedException
Cannot access a disposed object.
Object name: 'GraphicsDevice'.
What is happening?