我设法用 xna 在 F# 中拼凑出一个合适的示例游戏实现。但是,当我尝试实例化我的派生游戏类时,代码会抛出 FileNotFound 异常,试图访问 Microsoft.Xna.Framework 程序集。为什么会这样?
代码:
#light
open System
open Microsoft.Xna.Framework
open Microsoft.Xna.Framework.Audio
open Microsoft.Xna.Framework.Content
open Microsoft.Xna.Framework.Design
open Microsoft.Xna.Framework.GamerServices
open Microsoft.Xna.Framework.Graphics
open Microsoft.Xna.Framework.Input
type SampleGame() as self =
class
inherit Game()
let mutable manager : GraphicsDeviceManager = null
let mutable spriteBatch : SpriteBatch = null
do
manager <- new GraphicsDeviceManager(self)
override Game.Initialize() =
base.Initialize()
override Game.LoadContent() =
spriteBatch <- new SpriteBatch(manager.GraphicsDevice)
base.LoadContent()
override Game.Update(gameTime) =
base.Update(gameTime)
if GamePad.GetState(PlayerIndex.One).Buttons.Back = ButtonState.Pressed then
self.Exit()
override Game.Draw(gameTime) =
manager.GraphicsDevice.Clear(Color.CornflowerBlue);
base.Draw(gameTime)
end
let game = new SampleGame()
game.Run()
顺便说一句,我已经添加了正确的参考。编辑:经过一番探索,我发现我的 F# 项目正在编译为 64 位,这不适用于 32 位 XNA dll。但是 VS 2010 不允许我更改解决方案平台。我该如何解决?