开发者

Problem with interface in XNA game project

Here is a part mof my code:

using System;  
using System.C开发者_开发百科ollections.Generic;  
using System.Linq;  
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;

.
.
.

    public virtual bool CheckCollision(ICollidable i_Source)
    {
        bool collided = false;
        ICollidable2D source = i_Source as 2DICollidable; 
        if (source != null)
        {
            collided = source.Bounds.Intersects(this.Bounds);
        }

        return collided;
    }

For some reason, there is an error about using ICollided2D. Why does it don't recognize this kind of variable? Do I miss any "using" statment?


Either this is a typing mistake:

ICollidable2D source = i_Source as 2DICollidable;

Or you a missing an _ before 2DICollidable, so it becomes _2DICollidable as you can't start an identifier with a number.


2DICollidable

What is this? I dont think normal identifiers can start with number. Heck even SO code-highlighter shows it in red.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜