Solved

cant figure this out!

Posted on 2010-09-12
7
405 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 150 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 250 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 100 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
API v SOA 8 42
Reactjs with .NET 3 78
Header Font Size in Grid View 6 27
Visual C# Windows Project - Clone Form 4 26
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

730 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