Solved

cant figure this out!

Posted on 2010-09-12
7
401 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
7 Comments
 
LVL 65

Accepted Solution

by:
rockiroads earned 150 total points
Comment Utility
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 35

Assisted Solution

by:Miguel Oz
Miguel Oz earned 250 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
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 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.

762 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now