This error is wierd because I dont get this problem on my computer at work.
I brought the solution home with me to work on it and imported the classes into a new project and now I get this error message:
error C2259: 'VButton' : cannot instantiate abstract class
error C2259: 'VPad' : cannot instantiate abstract class
Both these classes inherit from CCTargetedTouchDelegate.
An example of the output while compiling these classes, I get:
1>VPad_Constructors.cpp
1>c:\users\marc\desktop\cocos2d\siftheads\classes\tools\vpad\vpad_constructors.cpp(5) : error C2259: 'VPad' : cannot instantiate abstract class
1> due to following members:
1> 'void cocos2d::CCTouchDelegate::touchDelegateRetain(void)' : is abstract
1> c:\users\marc\desktop\cocos2d\cocos2dx\include\cctouchdelegateprotocol.h(77) : see declaration of 'cocos2d::CCTouchDelegate::touchDelegateRetain'
1> 'void cocos2d::CCTouchDelegate::touchDelegateRelease(void)' : is abstract
1> c:\users\marc\desktop\cocos2d\cocos2dx\include\cctouchdelegateprotocol.h(78) : see declaration of 'cocos2d::CCTouchDelegate::touchDelegateRelease'
Here is my class decleration for the VPad. It may help find reasons why I’m getting this error. But what I find strange is that I do not get this error on my computer at work.
#ifndef __VPAD_H__
#define __VPAD_H__
#include "cocos2d.h"
using namespace cocos2d;
#include "../../Resources.h"
#include "../../GlobalSettings.h"
class VPad: public CCNode, public CCTargetedTouchDelegate
{
////////////////////////////
//VPad_Constructors.cpp
////////////////////////////
public:
//Initializer
static VPad* InitVPad();
//Functions
virtual void onEnter();
virtual void onExit();
protected:
//Desctructor and constructor
virtual ~VPad();
VPad();
////////////////////////////
//VPad.cpp
////////////////////////////
public:
virtual bool ccTouchBegan(CCTouch* touch, CCEvent* event); //Called when the screen is touched
virtual void ccTouchEnded(CCTouch* touch, CCEvent* event); //Called when the thumpad is released
virtual void ccTouchMoved(CCTouch* touch, CCEvent* event); //Called when the thumpad is moved
////////////////////////////
//VPad_Accessors.cpp
////////////////////////////
public:
void SetRadiusForThumbpad(float radius); //Sets the radius of the thumpad and scales the texture accordingly
void SetRadiusForThumbpadLimiter(float radius); //Sets the raidus of the limiter and scales the texture accordingly
//Input Accessors
float GetThumbpadStrengthPercentage();
CCPoint GetThumpadUnitVector();
bool GetThumpadIsNeutral();
protected:
void SetRadiusForSprite(float radius, CCSprite* sprite);
void SetInputToNeutral();
void ViewInput();
////////////////////////////
//Member Variables
////////////////////////////
protected:
//Member variables
//Sprites
CCSprite* m_thumbpad; //Sprite representing the thumbpad
CCSprite* m_thumbpadLimiter; //Sprite representing the limiter
//When the thumbpad is clicked and held, this is set to true
bool m_grabbed;
//Bounding circle for the thumbpad
float m_radiusForThumbpad;
float m_radiusForThumbpadLimiter;
float m_limiterBoundry;
//Input Variables
float m_thumbpadStrengthPercentage;
CCPoint m_thumbpadUnitVector;
bool m_thumbpadIsNeutral;
};
#endif //__VPAD_H__
This is how I instantiate this class and where it says the error is:
#include "VPad.h"
VPad* VPad::InitVPad()
{
VPad* vPad = new VPad(); //ERROR ON THIS LINE :S
vPad->autorelease();
return vPad;
}