hey
im using CC_SYNTHESIZE to create getter and setters for my CCSprite extended class
when i create new instannces and preform ccTouchBegan on the object its gives me the same ( first object ) results
for example :
class Gem :public CCSprite , public CCTargetedTouchDelegate
{
public:
Gem();
~Gem();
CC_SYNTHESIZE(std::string,gemId,GemId);
virtual bool init ();
CREATE_FUNC (Gem);
virtual bool ccTouchBegan(CCTouch* touch, CCEvent* event);
}
bool Gem::ccTouchBegan(CCTouch* touch, CCEvent* event)
{
if (m_state != kPaddleStateUngrabbed)
{
return false;
}
if ( !containsTouchLocation(touch) )
{
return false;
}
m_state = kPaddleStateGrabbed;
CCLOG("Gem Touched! %s %s",getImageName().c_str(),getGemId().c_str()); // this is allways prints the same values
return true;
}
and now i have the GameLayer that creates the gems :
void GameLayer::loadGemsIntoBoard()
{
for(int i=0;iinitWithSpriteFrameName(spritename);
thisGem->setRowNum(row);
thisGem->setColNum(col);
thisGem->setGemType((GemType)gemNum);
thisGem->setGemState(kGemNew);
std::string ss(spritename);
thisGem->setImageName(ss);
thisGem->setGameLayer(this);
thisGem->setGemId(spriteid);
thisGem->setTag(ObjOnLayer::typeGEM);
thisGem->setPosition(setPositionForGem(row,col,thisGem->getSize()));
this->addChild(thisGem,kGem);
m_GemsInPlay->addObject(thisGem);
thisGem->release();
}
is there any static variable im missing in the CC_SYNTHESIZE ?
that cause the instances return me the same gemId?