对象引用未设置为对象xna的实例

时间:2014-11-29 18:14:07

标签: c# xna

我有几个精灵,当他们见面时,我希望他们改变颜色。但是当我尝试运行程序时,我得到了这个错误:"对象引用未设置为对象的实例"

我的功能checkCollisions:

private void checkCollisions()
        {
            Rectangle kogel = new Rectangle((int)bullet.position.X, (int) bullet.position.Y, 25, 25); //error is here

            foreach (ISprite s in allSpriteObstakels)
            {
                Rectangle blokjes = new Rectangle((int)s.position.X, (int)s.position.Y, 10, 10);
                Rectangle overlap = Rectangle.Intersect(kogel, blokjes);
                if (overlap.IsEmpty == false)
                {
                    s.CollisionWith(bullet);
                    bullet.CollisionWith(s);
               }
            }
        }   

0 个答案:

没有答案