Annoying sprite drawing problem (cocos2d-2.1beta3-x-2.1.0)

Annoying sprite drawing problem (cocos2d-2.1beta3-x-2.1.0)
0.0 0


I try to recreate an animation that simulates a turning sunlight into the center of the screen, between two “layers” (foreground and background).

The background will be a “sky” (now, the green sprite).
The foreground will be a “island” (now, the blue sprite).
In between these two sprites I have 10 sprites with a “ray” everyone (now, the white sprite) rotating around the center.

The expected behavior is to display the rays, over the green (sky) sprite but under the blue (island) sprite.
But there is a problem annoying iOS: ray sprites are drawn incorrectly, passing the sprite of the island. In Android not seen any strange behavior.

This is my code ( bellow the init() of my TestLayer.cpp, a CCLayer child).
(I’m using the VisibleRect “helper” class from TestCPP)

    CCSprite* sky = CCSprite::create("Img/HomeMenuLayer_Cielo.png");
    sky->setPosition(ccpAdd(VisibleRect::top(), ccp(0, -sky->getContentSize().height/2)) );
    this->addChild(sky, -50);

    CCSprite* island = CCSprite::create("Img/HomeMenuLayer_Isla.png");
    island->setPosition(ccpAdd(VisibleRect::bottom(), ccp(0, island->getContentSize().height/2)) );

    this->addChild(island, -10);

    // Rayos de sol
    int nRayos = 10;
    float radio;
    CCRotateBy* rotate;

    CCNode* nodoRayos = CCNode::create();    
    CCSprite* rayo;

    for(int i = 0; i < nRayos; i++)
        rayo = CCSprite::create("Img/HomeMenuLayer_Brillo.png");

        radio = rayo->getContentSize().width;


        rayo->setAnchorPoint(ccp(-0.1, 0.5f ));

        nodoRayos->addChild(rayo, -(15+i));

        rotate = CCRotateBy::create(30, CC_RADIANS_TO_DEGREES(2*M_PI));

    this->addChild(nodoRayos, -15);

Some screenshots:

Resources in Img/:

Tested with:
* iPhone 4s (FAIL)
* Samsung Galaxy S3, I9300

(I have not tried in cocos2d-2.0-x-2.0.4)


Here are a couple of things you can try…

Change the ordering of how you add the children to the root node.


Try to enable Depth Test.