Inbal
Inbal

Reputation: 1

Problem with interface in XNA game project

Here is a part mof my code:

using System;  
using System.Collections.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?

Upvotes: 0

Views: 542

Answers (2)

Neil Knight
Neil Knight

Reputation: 48547

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.

Upvotes: 2

Euphoric
Euphoric

Reputation: 12849

2DICollidable

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

Upvotes: 1

Related Questions