Sprite not showing up, help?

So, I have a class that is called Gameboard. In it I have an array of CCSprite pointers.

class Gameboard : public CCNode
{
private:
    CCSprite* m_vSprites[6];
};

Inside the Gameboard’s init function (called in the constructor), I set the first of the Sprites (to test out).

    CCSprite * newSprite = new CCSprite();
    m_vSprites[0] = newSprite;
    m_vSprites[0]->spriteWithFile("Triangle01.png", CCRectMake(0, 0, 480, 320));
    m_vSprites[0]->setPosition(ccp(50, 50));
    this->addChild(m_vSprites[0]);

Then in my GameScene (where the game starts up and occurs), I have the Gameboard pointer as a member function.

    Gameboard* m_Gameboard;

And inside the GameScene’s init (like in the tutorial), I make the Gameboard and add the child of the Gameboard into it.

    if(!CCLayerColor::initWithColor(ccc4(0, 0, 255, 255)))
        return false;


    bool bRet = false;
    do
    {   
        m_Gameboard = new Gameboard();

        this->addChild(m_Gameboard);
        bRet = true;
    } while(0);

    return bRet;

But it doesn’t show up. Can anyone help me out? I’m really at a loss of why this isn’t showing up.

Try adding your sprites to the scene directly. An alternative would be to derive Gameboard from a class able to render its children, such as CCSpriteBatchNode.

Well, I want to utilize C++, so I’d like to have the Gameboard have CCSprite pointers and then use the Gameboard object in the scene’s CCSprite pointers to be rendered.

And when I attemped to derive Gameboard from CCSpriteBatchNode, it asserts in the addChild of CCSpriteBatchNode.

What I was looking at to hopefully get it to work is this page, which is for joysticks. The things regarding the player and the CCSprite *’s seems like my code should work with it.

Figured it out I do believe.

This is what I had…

    CCSprite * newSprite = new CCSprite();
    m_vSprites[0] = newSprite;
    m_vSprites[0]->spriteWithFile("Triangle01.png", CCRectMake(0, 0, 480, 320));
    m_vSprites[0]->setPosition(ccp(50, 50));
    this->addChild(m_vSprites[0]);

When I should have just had…

    m_vSprites[0] = CCSprite::spriteWithFile("Triangle01.png", CCRectMake(0, 0, 480, 320));
    m_vSprites[0]->setPosition(ccp(50, 50));
    this->addChild(m_vSprites[0]);