?
Solved

cant figure this out!

Posted on 2010-09-12
7
Medium Priority
?
409 Views
Last Modified: 2013-12-17
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.Input;

namespace VideoGame
{
    class UserControlledSprite : Sprite
    {


        public UserControlledSprite(Texture2D textureImage, Vector2 position,
            Point frameSize, int collisionOffset, Point currentFrame, Point sheetSize,
            Vector2 speed)
            : base(textureImage, position, frameSize, collisionOffset, currentFrame,
            sheetSize, speed)
        {
        }

        public UserControlledSprite(Texture2D textureImage, Vector2 position,
            Point frameSize, int collisionOffset, Point currentFrame, Point sheetSize,
            Vector2 speed, int millisecondsPerFrame)
            : base(textureImage, position, frameSize, collisionOffset, currentFrame,
            sheetSize, speed, millisecondsPerFrame)
        {
        }
    }
}



This is the error I got......

'VideoGame.UserControlledSprite' does not implement inherited abstract member 'VideoGame.Sprite.direction.get'      


C:\My XNA Games\Video Game\Video Game\UserControlledSprite.cs      Line 11      Column 11      VideoGame

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.Input;

namespace VideoGame
{
    class UserControlledSprite : Sprite
    {


        public UserControlledSprite(Texture2D textureImage, Vector2 position,
            Point frameSize, int collisionOffset, Point currentFrame, Point sheetSize,
            Vector2 speed)
            : base(textureImage, position, frameSize, collisionOffset, currentFrame,
            sheetSize, speed)
        {
        }

        public UserControlledSprite(Texture2D textureImage, Vector2 position,
            Point frameSize, int collisionOffset, Point currentFrame, Point sheetSize,
            Vector2 speed, int millisecondsPerFrame)
            : base(textureImage, position, frameSize, collisionOffset, currentFrame,
            sheetSize, speed, millisecondsPerFrame)
        {
        }
    }
}

Open in new window

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.Input;

namespace VideoGame
{
    class UserControlledSprite : Sprite
    {


        public UserControlledSprite(Texture2D textureImage, Vector2 position,
            Point frameSize, int collisionOffset, Point currentFrame, Point sheetSize,
            Vector2 speed)
            : base(textureImage, position, frameSize, collisionOffset, currentFrame,
            sheetSize, speed)
        {
        }

        public UserControlledSprite(Texture2D textureImage, Vector2 position,
            Point frameSize, int collisionOffset, Point currentFrame, Point sheetSize,
            Vector2 speed, int millisecondsPerFrame)
            : base(textureImage, position, frameSize, collisionOffset, currentFrame,
            sheetSize, speed, millisecondsPerFrame)
        {
        }
    }
}

Open in new window

Game1.cs
Program.cs
Sprite.cs
UserControlledSprite.cs
0
Comment
Question by:mike9380
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 65

Accepted Solution

by:
rockiroads earned 600 total points
ID: 33658872
maybe you need to implement the get method in your derived class

abstract methods you defined in the base class will have to be implemented in any subclasses eg public override ...
0
 
LVL 36

Assisted Solution

by:Miguel Oz
Miguel Oz earned 1000 total points
ID: 33659473
Your cpde defines this property an abstract:
        public abstract Vector2 direction
        {
            get;
        }
You must implement it in code  at (UserControlledSprite)
        private Vector2 GetDirection()
  {
   //return an object of type vector 2 based on your business logic
}
        public override Vector2 direction
        {
            get  GetDirection();
        }
0
 
LVL 8

Assisted Solution

by:Gururaj Badam
Gururaj Badam earned 400 total points
ID: 33682036
Looking at your attached code you've defined direction property in Sprite abstract class and have also marked it as abstract. You will have to define this in the derived class.

If that was not the intent, you can remove abstract keyword on the property in the sprite abstract class.
0
 
LVL 8

Expert Comment

by:Gururaj Badam
ID: 33707044
Hi Admin

Please refer to Comment/Response 33658872 & 33682036 point the same thing. Either or both of these should be accepted.
0
 

Author Comment

by:mike9380
ID: 33708671
I felt that both helped me because I implemented the get methods rockiroads suggested and also canceled the abstract in sprite.cs that novice novice suggested .They both helped me learn C# language better than Iknew before.
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question