Overidding setposition of ccsprite

I am trying to override the setposition function but it is not called when running the code.
//player.h file

class player : public CCSprite
{
public:
virtual void setPosition(const CCPoint& pos);
}

//player.cpp

void player::setPosition(const CCPoint& pos)
{

CCSprite::setPosition(pos);

}

Maybe you have pointer to CCNode and not CCSprite? Post more code.

//player.h

#ifndef FirstProject_player_h
#define FirstProject_player_h
#include “define.h”
#include “cocos2d.h”
using namespace cocos2d;

class player : public CCSprite
{
public:

virtual bool init();
Movement state;
CCRect body;
float x;
int flag;
void jump(float);
void slide();
void scale(float);
void move(float,float);
void applyMovement(float);
virtual void setPosition(const CCPoint& pos);
void backToNormal();

};

#endif

//player.cpp

//
// player.cpp
// FirstProject
//
// Created by Unanimous studio on 05/02/13.
//
//

#include “player.h”
#include “SimpleAudioEngine.h”
#include “HelloWorldScene.h”

using namespace cocos2d;
using namespace CocosDenshion;

// on “init” you need to initialize your instance
bool player::init()
{
//////////////////////////////
// 1. super init first
if ( !CCSprite::init() )
{
return false;
}

return true;
// CCLOG (“player ka init”);
};

void player::jump(float a)
{

this~~>state=Jump;
CCJumpBy* jump = CCJumpBy::create;
this~~>runAction(CCSequence::create(jump,CCCallFuncN::create(this,callfuncN_selector(player::backToNormal)),NULL));
//this~~>runAction;

}

void player::slide
{
// CCLOG ("slide ");
flag=0;
x=1;
//CCLOG;
this~~>schedule(schedule_selector(player::scale),0.1);
}

void player::scale(float dt)
{
// CCLOG (“update %f”,x);

if(x>=0.5 && flag0)
{
x=x-0.1;
this->setScaleY(x);
}

else if(x\<0.5 || flag1)

{
flag=1;
x=x+0.1;
if(x1)
{
flag=0;
this->unscheduleAllSelectors();
}

    this-\>setScaleY(x);

}

}

void player::move(float v , float swipVel)
{

int rightmove=0;
if(v\>0)
{
    //right move
     rightmove=1;

}

// CCLOG(“Rightmove value %d”,rightmove);
CCSize size = CCDirector::sharedDirector()->getWinSize();

if((this-\>getPositionX()\>size.width/4 && rightmove0) || (rightmove==1 && this~~\>getPositionX\< size.width/1.4))

{
float moveFactor = swipVel/80;
CCLOG (“moveFactor = %f”,moveFactor);
int x=v*moveFactor;
if+x < size.width/1.4 || this~~>getPositionX()+x > size.width/4)
{
this~~>state=Move;
CCMoveTo* walk = CCMoveTo::create+x,this~~>getPositionY()));
//this~~>runAction;
this~~>runAction(CCSequence::create(walk,CCCallFuncN::create(this,callfuncN_selector(player::backToNormal)),NULL));
}
}
}

void player::backToNormal()
{
state = Normal;
}

void player::setPosition(const CCPoint& pos)
{

CCSprite::setPosition(pos);
body = CCRectMake(this~~>getPositionX, this~~>getPositionY(), this~~>getContentSize.width, this~~>getContentSize().height);
}

//helloworld.cpp

player* shadow = (player*)player::create(“Prisoner_shadow.png”);

shadow->setPosition( ccp(size.width/2, size.height/2-t) );

//when the above code in “HelloWorld” executes it goes to the setposition of “ccsprite” rather than goin to my overriden method in “player class”.

You don’t have a create method in your player class so in this line:
player* shadow = (player*)player::create(“Prisoner_shadow.png”);
you are creating a CCSprite so when you call setPosition then it calls setPosition from CCSprite. You should not be doing this type of casting here. You should override the create method so it will create a player object and not a CCSprite. And when you post your code please use pre tag.

Thanks Leszek for your reply
it’s been a great help for me

Is tere any In-built library for gesture recognition….for swipe left , right , up , down

For now i am using the following code to find out the gesture:-
@ float xDistance = abs(midX - beginX); // beginx,beginy are touch location in touch began method
float yDistance = abs(midY - beginY); //midx,midy are touch location in touch moved method

if (xDistance > yDistance)
{
if (beginX > midX)
{
CCLOG (“swipe left”);
}
else
{
CCLOG (“swipe right”);
}
}
else
{
if (beginY < midY)
{
CCLOG (“swipe up”);
} }
else
{
CCLOG (“swipe down”);
} }
}
@