Tell me more ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

So i was trying to add tIDE to my project but i hit a Keyntfoundexception

map.Draw(mapDisplayDevice, viewport);

Any help would be usefull here is the rest of the class:

using System;
using System.Threading;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

//xTile
using xTile;
using xTile.Dimensions;
using xTile.Display;

namespace ScreenManager
{
 class GameScreen : Screen
{
    Boolean isloading = true;

    SpriteBatch spriteBatch;
    GraphicsDeviceManager graphics;

    ContentManager content;

    GraphicsDevice Device;

    //xtile shit
    Map map = new Map();
    IDisplayDevice mapDisplayDevice;
    xTile.Dimensions.Rectangle viewport;

    public GameScreen(GraphicsDevice device, ContentManager Content)
        : base(device, "GameScreen")
    {
        content = Content;
        Device = device;
        //initialize



    }

    public override bool Init()
    {
        ThreadPool.QueueUserWorkItem(new WaitCallback(Loading));
        return base.Init();
    }

    public override void Shutdown()
    {
        base.Shutdown();
    }

    public override void Draw(GameTime gameTime)
    {
        //not loading VVVV
        if (!isloading)
        {
            map.Draw(mapDisplayDevice, viewport);
        }
            //loading VVVV
        else
        {
            _device.Clear(Color.Aqua);
        }
        base.Draw(gameTime);
    }

    void Loading(Object state)
    {
        //loada contenið mitt hér baby ;)
        viewport = new xTile.Dimensions.Rectangle(new Size(Device.Viewport.Width, Device.Viewport.Height));

        mapDisplayDevice = new XnaDisplayDevice(this.content, this._device);

        map.LoadTileSheets(mapDisplayDevice);

        spriteBatch = new SpriteBatch(_device);

        map = content.Load<Map>("Maps\\test");
        //
        isloading = false;
    }

    public override void Update(GameTime gameTime)
    {
        map.Update(gameTime.ElapsedGameTime.Milliseconds);
        viewport.X++;

        base.Update(gameTime);
    }
}
}
share|improve this question
1  
You're going to need to give us a little more info. Do you have a stack trace of the error? – Cameron Fredman Feb 21 at 1:31
Is mapDisplayDevice ever initialized or referenced to anything? No? Well... – Dialock Feb 21 at 6:38
Author of tIDE/xTile here.. did you get the KeyNotFoundException on compilation of the assets or at runtime? – colinvella Mar 23 at 23:09

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.