Solved

cant figure this out!

Posted on 2010-09-12
7
403 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
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 35

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
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.

770 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