Problem while creating a gameObject

Problem while creating a gameObject
0.0 0

#1

Hey,
I’m trying to create an animated GameObject.

Previously i was inheriting my gameObject from CCSprite, which works in case of a standard Sprite.
Now when I wish to create a CCSpriteBatchNode.
I cannot do something like

class gameObject : public CCSpriteBatchNode

as when i add it to the scene as a child, the game crashes with a CCNode exception.

Instead I tried to inherit from CCNode

now the object gets created from the batchnode, but a repeatforever animation doesn’t work now.

@
class gameObject: public CCNode, public CCTargetedTouchDelegate
{
CCSprite sprite;
CCSpriteBatchNode
spriteSheet;
CCAnimation moveAnimation;
CCAnimate
moveAnimate;

public:
gameObject(void);
~gameObject(void);
virtual void onEnter();
virtual void onExit();
virtual bool CCTouchBegan(CCTouch touch, CCEvente);
virtual void CCTouchEnded(CCTouch touch, CCEvente);
static gameObject* initialize();
void test();
};

gameObject::gameObject()
{
CCNode::node();
spriteSheet = CCSpriteBatchNode::batchNodeWithFile(“animation.png”);
sprite = CCSprite::spriteWithBatchNode(spriteSheet, CCRectMake(0, 0, 50, 40));
spriteSheet~~>addChild;

moveAnimation = CCAnimation::animation;
moveAnimation~~>setDelay(0.1f);

for (int i=0; i<4; i++) {
CCSpriteFrame frame = CCSpriteFrame::frameWithTexture, CCRectMake);
moveAnimation~~>addFrame;
//frame~~>autorelease;
}
moveAnimate = CCAnimate::actionWithAnimation;
CCCallFunc
callAction = CCCallFunc::actionWithTarget(this, callfunc_selector(gameObject::test));
CCRepeatForever repeatAction = CCRepeatForever::actionWithActionCCSequence::actions, NULL));
CCRepeatForever
repeatAnimation = CCRepeatForever::actionWithAction(moveAnimation);
sprite~~>runAction;
sprite~~>runAction(repeatAnimation);
sprite~~>retain;
spriteSheet~~>setPosition(ccp(400,300));
this~~>addChild;
}
gameObject* gameObject::initialize
{
gameObject *obj = new gameObject;
return obj;
}
void gameObject::test
{
CCLog;
}
@

In the scene file
@
gameObject o1 = gameObject::initialize;
this~~>addChild(o1);
@

The Log prints HERE just once.

How should I go about doing this?